generated from me/template-mit
Compare commits
3
Commits
cde66dcd67
..
prod
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3d3573fae | ||
|
|
bd02d4611a | ||
|
|
d70c5d3069 |
No files matched your search
File renamed without changes.
Executable
+110
@@ -0,0 +1,110 @@
|
|||||||
|
#!/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)"
|
||||||
|
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
|
||||||
|
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=""
|
||||||
|
dir="$LOCAL"
|
||||||
|
src="$DIR"
|
||||||
|
if [[ "$global" == "Y" ]]; then
|
||||||
|
dir="$GLOBAL"
|
||||||
|
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"
|
||||||
|
done
|
||||||
|
|
||||||
|
## Finish ##
|
||||||
|
|
||||||
|
echo "Done!"
|
||||||
|
exit 0
|
||||||
File renamed without changes.
File renamed without changes.
Vendored
File renamed without changes.
-62
@@ -1,62 +0,0 @@
|
|||||||
#!/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 ":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
|
|
||||||
Reference in new issue
Block a user