AqualinkD/extras/aqua.sh

96 lines
1.6 KiB
Bash
Raw Normal View History

2018-09-21 15:19:26 +00:00
#!/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 ""
}
2018-09-21 16:00:54 +00:00
function upgrade_self {
if [ -f "$AQUA/extras/aqua.sh" ]; then
cp "$AQUA/extras/aqua.sh" $0
fi
}
2018-09-21 15:19:26 +00:00
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 ~
2018-09-21 16:00:54 +00:00
sudo "$AQUA/release/install.sh" "clean"
2018-09-21 15:19:26 +00:00
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
2018-09-21 15:28:47 +00:00
exit
2018-09-21 15:19:26 +00:00
else
print_usage
exit;
fi
install
2018-09-21 16:00:54 +00:00
upgrade_self
echo "Installed "`cat $AQUA/version.h | cut -d '"' -f 2 | tr '\n' ' '`
2018-09-21 15:19:26 +00:00
cd $CWD