#!/usr/bin/env bash # 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 name_short="nomad" name_long="nomadic-weather" name_abs="weather-list" ## Functions ## ## Parameters ## while getopts ":gslarh" arg; do case $arg in g) global="Y" ;; s) short="Y" ;; l) long="Y" ;; a) abstract="Y" ;; r) remove="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="" if [[ -z "$remove" ]]; then cmd="cp -v $DIR/prototype.js" else cmd="rm -v" fi dir="$LOCAL" if [[ "$global" == "Y" ]]; then dir="$GLOBAL" cmd="sudo $cmd" echo "Requesting sudo privileges... " sudo echo "Success!" fi ## Main ## for prog in $name; do mkdir -pv $dir $cmd $dir/$prog done ## Finish ## echo "Done!" exit 0