pull/42/head
shaun feakes 2018-09-21 10:19:26 -05:00
parent cb2375b103
commit 8962fca13b
2 changed files with 108 additions and 0 deletions

86
extras/aqua.sh Executable file
View File

@ -0,0 +1,86 @@
#!/bin/bash
CWD=$(cd)
cd ~
BASE="./software/"
AQUA="$BASE/AqualinkD"
echoerr() { printf "%s\n" "$*" >&2; }
function print_usage {
echoerr "No arguments supplied, please use use:-"
echoerr "$0 install <- Install from scratch, delete any existing install (except configuration files)"
echoerr "$0 upgrade <- Upgrade existing install"
echoerr "$0 clean <- Remove everything, including configuration files"
echoerr ""
}
function git_install {
sudo apt-get install git
}
function remove {
cd ~
if [ -d "$AQUA" ]; then
rm -rf "$AQUA"
fi
}
function new_install {
remove
cd ~
if [ ! -d "$BASE" ]; then
mkdir -p $BASE
fi
cd $BASE
git clone https://github.com/sfeakes/AqualinkD.git
}
function upgrade {
cd ~
cd $AQUA
git pull
}
function clean {
cd ~
sudo "$AQUA/release/install.sh clean"
remove
}
function install {
cd ~
sudo "$AQUA/release/install.sh"
}
# Check something was passed
if [[ $# -eq 0 ]]; then
print_usage
exit
fi
# Check git is installed
command -v git >/dev/null 2>&1 || { echoerr "git is not installed. Installing"; git_install; }
command -v git >/dev/null 2>&1 || { echoerr "git is not installed. Aborting"; exit 1; }
# Pass command line
if [ "$1" == "install" ]; then
new_install
elif [ "$1" == "upgrade" ]; then
upgrade
elif [ "$1" == "clean" ]; then
clean
else
print_usage
exit;
fi
install
cd $CWD

View File

@ -38,6 +38,28 @@ command -v systemctl >/dev/null 2>&1 || { echo "This script needs systemd's syst
systemctl stop $SERVICE > /dev/null 2>&1
SERVICE_EXISTS=$(echo $?)
# Clean everything if requested.
if [ "$1" == "clean" ]; then
echo "Deleting install"
if [ -f $BINLocation/$BIN ]; then
rm -f $BINLocation/$BIN
fi
if [ -f $SRVLocation/$SRV ]; then
rm -f $SRVLocation/$SRV
fi
if [ -f $CFGLocation/$CFG ]; then
rm -f $CFGLocation/$CFG
fi
if [ -f $DEFLocation/$DEF ]; then
rm -f $DEFLocation/$DEF
fi
if [ -d $WEBLocation ]; then
rm -rf $WEBLocation
fi
systemctl daemon-reload
exit
fi
# copy files to locations, but only copy cfg if it doesn;t already exist
cp $BUILD/$BIN $BINLocation/$BIN