mirror of https://github.com/sfeakes/AqualinkD.git
pull/42/head
parent
cb2375b103
commit
8962fca13b
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue