From bd02d4611a0b230daaec7e9774c9d5ae977647f5 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Sat, 12 Sep 2026 12:48:22 -0700 Subject: [PATCH] Add usage as well as fix the global install to work properly with node_modules. --- install.sh | 59 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index f9961ed..b38f190 100755 --- a/install.sh +++ b/install.sh @@ -5,15 +5,47 @@ ## Variables ## DIR="$(cd "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" +PROG="$(basename -- "${BASH_SOURCE[0]}")" LOCAL=~/bin GLOBAL=/usr/local/bin +GLOBAL_SRC=/usr/local/src +name_local="prototype.js" name_short="nomad" name_long="nomadic-weather" name_abs="weather-list" ## Functions ## +function usage { + cat <<- EOF + $PROG [-h] [-g] [a|l|s] [-r] + + Install $name_local to the system. Can be local, global, or removed. + + Parameters) + h) Display this message. + g) Install globally ($GLOBAL), otherwise local ($LOCAL). + a) Abstract name, unrelated to being nomadic. ($name_abs) + l) Long name, the full name of the project. ($name_long) + s) Short name, the full name of the project. ($name_short) + r) Remove / uninstall the project according to the above flags. + + Examples) + - Install to the local user with the abstract name. + $PROG + - Install to all users with all names. + $PROG -alsg + - Remove all instances. + $PROG -alsr && $PROG -alsrg + + Happy weather watching! :) + + ~ Hyperling + EOF + exit $1 +} + ## Parameters ## while getopts ":gslarh" arg; do @@ -42,25 +74,34 @@ if [[ "$abstract" == "Y" || ( -z "$short" && -z "$long" ) ]]; then fi cmd="" -if [[ -z "$remove" ]]; then - cmd="cp -v $DIR/prototype.js" -else - cmd="rm -v" -fi - dir="$LOCAL" +src="$DIR" if [[ "$global" == "Y" ]]; then dir="$GLOBAL" - cmd="sudo $cmd" + cmd="sudo" echo "Requesting sudo privileges... " sudo echo "Success!" + mkdir -pv /usr/local/src + sudo cp -Rv "$DIR" $GLOBAL_SRC/ + src="$GLOBAL_SRC/`basename "$DIR"`" +fi + +if [[ -z "$remove" ]]; then + cmd="$cmd ln -svf $src/$name_local" +else + cmd="$cmd rm -v" fi ## Main ## +# Untested +#if [[ "$global" == "Y" && "$remove" == "Y" ]]; then +# sudo rm -rfv "$src" +#fi + for prog in $name; do - mkdir -pv $dir - $cmd $dir/$prog + mkdir -pv "$dir" + $cmd "$dir/$prog" done ## Finish ##