2015-10-04 00:12:32 -07:00
|
|
|
#! /bin/bash
|
2016-10-25 12:09:52 -07:00
|
|
|
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
2015-10-04 00:12:32 -07:00
|
|
|
|
2015-12-09 20:39:09 -05:00
|
|
|
# Ensure URL we'll use ends in a /
|
|
|
|
case "$A2SERVER_SCRIPT_URL" in
|
|
|
|
*/) scriptURL="$A2SERVER_SCRIPT_URL" ;;
|
2016-05-28 10:11:26 -04:00
|
|
|
*) scriptURL="${A2SERVER_SCRIPT_URL:-https://raw.githubusercontent.com/RasppleII/a2server/current}/" ;;
|
2015-12-09 20:39:09 -05:00
|
|
|
esac
|
|
|
|
|
|
|
|
currentVersion=$(wget -qO- "${scriptURL}setup/index.txt" | grep '^a2serverVersion' | cut -d '"' -f 2)
|
2015-10-03 05:25:44 -07:00
|
|
|
|
|
|
|
if [[ -f /usr/local/etc/A2SERVER-version ]]; then
|
2016-10-25 12:09:52 -07:00
|
|
|
installedVersion=$(cat /usr/local/etc/A2SERVER-version)
|
2015-10-03 05:25:44 -07:00
|
|
|
else
|
2016-10-25 12:09:52 -07:00
|
|
|
installedVersion=100
|
2015-10-03 05:25:44 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
autoAnswerYes=
|
|
|
|
for arg in $@; do
|
2016-10-25 12:09:52 -07:00
|
|
|
if [[ $arg == "-y" ]]; then
|
|
|
|
autoAnswerYes=1
|
|
|
|
break
|
|
|
|
fi
|
2015-10-03 05:25:44 -07:00
|
|
|
done
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Update history:"
|
2015-10-04 01:23:53 -07:00
|
|
|
wget -qO- "${scriptURL}update/versionhistory.txt"
|
2015-10-03 05:25:44 -07:00
|
|
|
echo
|
|
|
|
echo "installed version: ${installedVersion:0:1}.${installedVersion:1:1}.${installedVersion:2:1}"
|
|
|
|
echo "current version: ${currentVersion:0:1}.${currentVersion:1:1}.${currentVersion:2:1}"
|
|
|
|
echo
|
|
|
|
if [[ $autoAnswerYes ]]; then
|
2016-10-25 12:09:52 -07:00
|
|
|
REPLY="y"
|
2015-10-03 05:25:44 -07:00
|
|
|
else
|
2016-10-25 12:09:52 -07:00
|
|
|
echo -n "Do you want to update (or reinstall) A2SERVER? "
|
|
|
|
read
|
2015-10-03 05:25:44 -07:00
|
|
|
fi
|
|
|
|
if [[ ${REPLY:0:1} == "y" || ${REPLY:0:1} == "Y" ]]; then
|
2016-10-25 12:09:52 -07:00
|
|
|
# sudo rm /usr/local/etc/netatalk/a2boot/* &> /dev/null
|
|
|
|
wget -q -O /tmp/setup "${scriptURL}setup/index.txt"; source /tmp/setup -i "$@"
|
2015-10-03 05:25:44 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
unset currentVersion 2> /dev/null
|
|
|
|
unset installedVersion 2> /dev/null
|