Compare commits

...
2 Commits
2 changed files with 46 additions and 32 deletions

No files matched your search

+42 -29
View File
@@ -8,7 +8,7 @@ DIR="$(cd "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
PROJ="$(cd "$DIR"/.. &>/dev/null && pwd)" PROJ="$(cd "$DIR"/.. &>/dev/null && pwd)"
PROG="$(basename -- "${BASH_SOURCE[0]}")" PROG="$(basename -- "${BASH_SOURCE[0]}")"
LOCAL=~/bin LOCAL=~/bin
GLOBAL="$(npm prefix -g)" GLOBAL="/usr/local"
GLOBAL_BIN="$GLOBAL/bin" GLOBAL_BIN="$GLOBAL/bin"
GLOBAL_SRC="$GLOBAL/src" GLOBAL_SRC="$GLOBAL/src"
@@ -21,29 +21,32 @@ name_abs="weather-list"
function usage { function usage {
cat <<- EOF cat <<- EOF
$PROG [-h] [-g] [a|l|s] [-r] $PROG [-h] [-g] [a: b|l|s] [-r]
Install $name_local to the system. Can be local, global, or removed. Install $name_local to the system. Can be local, global, or removed.
Parameters) Parameters)
h) Display this message. h) Display this message.
g) Install globally ($GLOBAL), otherwise local ($LOCAL). g) Install globally ($GLOBAL), otherwise local ($LOCAL).
a) Abstract name, unrelated to being nomadic. ($name_abs) a) All names / pseudonyms, rather than choosing from below.
l) Long name, the full name of the project. ($name_long) b) Basic name, unrelated to being nomadic. ($name_abs)
l) Long name, the full name of the project. ($name_long) [Default]
s) Short name, the full name of the project. ($name_short) s) Short name, the full name of the project. ($name_short)
r) Remove / uninstall the project according to the above flags. r) Remove / uninstall the project according to the above flags.
Examples) Examples)
- Install to the local user with the abstract name. - Install to the local user with the default name.
$PROG $PROG
- Install to all users with all names. - Install to all users with all names.
$PROG -alsg $PROG -ga
- Remove all instances. - Remove all instances.
$PROG -alsr && $PROG -alsrg $PROG -ra && $PROG -gra
Happy weather watching! :) Happy weather watching! :)
~ Hyperling ~ Hyperling
https://git.hyperling.com/me/nomadic-weather
EOF EOF
exit $1 exit $1
} }
@@ -68,42 +71,47 @@ done
## Parameters ## ## Parameters ##
while getopts ":gslarh" arg; do while getopts ":gslabrh" arg; do
case $arg in case $arg in
g) global="Y" ;; g) global="Y" ;;
s) short="Y" ;; s) short="Y" ;;
l) long="Y" ;; l) long="Y" ;;
a) abstract="Y" ;; b) abstract="Y" ;;
a) all="Y" ;;
r) remove="Y" ;; r) remove="Y" ;;
h) usage ;; h) usage ;;
*) echo "ERROR: Parameter $OPTARG was not recognized." && usage 1 ;; *) echo "ERROR: Parameter $OPTARG was not recognized." && usage 1 ;;
esac esac
done done
## Processing ##
name="" name=""
if [[ "$short" == "Y" ]]; then if [[ "$all" == "Y" || "$abstract" == "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" name="$name $name_abs"
fi fi
if [[ "$all" == "Y" || "$short" == "Y" ]]; then
name="$name $name_short"
fi
if [[ "$all" == "Y" || "$long" == "Y" || -z "$name" ]]; then
name="$name $name_long"
fi
termux_check="/sdcard"
if [[ "$global" == "Y" && -e "$termux_check" ]]; then
echo "Detected $termux_check, assuming we are on Termux, global flag disabled."
global="N"
fi
## Processing ##
cmd="" cmd=""
dir="$LOCAL" dir="$LOCAL"
src="$PROJ" src="$PROJ"
if [[ "$global" == "Y" ]]; then if [[ "$global" == "Y" ]]; then
dir="$GLOBAL_BIN"
cmd="sudo" cmd="sudo"
dir="$GLOBAL_BIN"
src="$GLOBAL_SRC/`basename "$PROJ"`"
echo "Requesting sudo privileges... " echo "Requesting sudo privileges... "
sudo echo "Success!" sudo echo "Success!"
mkdir -pv /usr/local/src
sudo cp -Rv "$PROJ" "$GLOBAL_SRC"/
src="$GLOBAL_SRC/`basename "$PROJ"`"
fi fi
if [[ -z "$remove" ]]; then if [[ -z "$remove" ]]; then
@@ -114,15 +122,20 @@ fi
## Main ## ## Main ##
# Untested # Global Source Code: Install / Removal
#if [[ "$global" == "Y" && "$remove" == "Y" ]]; then if [[ "$global" == "Y" ]]; then
# sudo rm -rfv "$src" if [[ "$remove" == "Y" ]]; then
#fi sudo rm -rfv "$src"
else
mkdir -pv "$GLOBAL_SRC"
sudo cp -Rv "$PROJ" "$GLOBAL_SRC"/
fi
fi
# Program: Install / Removal
for prog in $name; do for prog in $name; do
# fix spaces to tabs if [[ ! -d "$dir" ]]; then
if [[ ! -d "$dir" ]]; then mkdir -pv "$dir"
mkdir -pv "$dir"
fi fi
$cmd "$dir/$prog" $cmd "$dir/$prog"
done done
+4 -3
View File
@@ -41,11 +41,11 @@ const { hideBin } = require('yargs/helpers');
/* * * Variables * * */ /* * * Variables * * */
const version = '0.1.1'; const version = '0.1.2';
const days_fore_max = 16; const days_fore_max = 16;
const days_fore_default = 12; const days_fore_default = 7;
const days_past_default = 2; const days_past_default = 7;
const ft_to_m = 0.3048; const ft_to_m = 0.3048;
@@ -92,6 +92,7 @@ const locations = [
{ name: "Quartzsite: ++", lat: 33.6763, lon: -114.2104, elevation: 900 }, { name: "Quartzsite: ++", lat: 33.6763, lon: -114.2104, elevation: 900 },
{ name: "Kanab: BF", lat: 37.1412, lon: -112.5439, elevation: 5500 }, { name: "Kanab: BF", lat: 37.1412, lon: -112.5439, elevation: 5500 },
//{ name: "Kanab: ++", lat: 37.1399, lon: -112.5926, elevation: 5700 }, //{ name: "Kanab: ++", lat: 37.1399, lon: -112.5926, elevation: 5700 },
{ name: "Pahrump, NV", lat: 36.1925, lon: -115.9758, elevation: 2700 },
]; ];
locations.sort((a, b) => a.elevation - b.elevation); locations.sort((a, b) => a.elevation - b.elevation);