diff --git a/install.sh b/install.sh index c74acd0..63d4c6e 100755 --- a/install.sh +++ b/install.sh @@ -2,10 +2,61 @@ # 20260912 - Hyperling # "Install" script to get this program runnable from anywhere on the system. +## Variables ## + DIR="$(cd "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" LOCAL=~/bin +GLOBAL=/usr/local/bin -mkdir -pv $LOCAL +name_short="nomad" +name_long="nomadic-weather" +name_abs="weather-list" -ln -svf "$DIR"/prototype.js $LOCAL/nomad -ln -svf "$DIR"/prototype.js $LOCAL/nomadic-weather +## Functions ## + +## Parameters ## + +while getopts ":gslah" arg; do + case $arg in + g) global="Y" ;; + s) short="Y" ;; + l) long="Y" ;; + a) abstract="Y" ;; + h) usage ;; + *) echo "ERROR: Parameter $OPTARG was not recognized." && usage 1 ;; + esac +done + +## Processing ## + +name="" +if [[ "$short" == "Y" ]]; then + name="$name $name_short" +fi +if [[ "$long" == "Y" ]]; then + name="$name $name_long" +fi +if [[ "$abstract" == "Y" || ( -z "$short" && -z "$long" ) ]]; then + name="$name $name_abs" +fi + +cmd="" +dir="$LOCAL" +if [[ "$global" == "Y" ]]; then + dir="$GLOBAL" + cmd="sudo" + echo "Requesting sudo privileges... " + sudo echo "Success!" +fi + +## Main ## + +for prog in $name; do + mkdir -pv $dir + $cmd cp -v -svf "$DIR"/prototype.js $dir/$prog +done + +## Finish ## + +echo "Done!" +exit 0