2015-10-04 07:12:32 +00:00
|
|
|
#! /bin/bash
|
2016-10-25 19:09:52 +00:00
|
|
|
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
2015-10-04 07:12:32 +00:00
|
|
|
|
2016-12-07 12:16:22 +00:00
|
|
|
a2sScriptURL="https://raw.githubusercontent.com/RasppleII/a2server/master"
|
|
|
|
|
2016-10-27 20:31:00 +00:00
|
|
|
a2sDevel="$( dirname "${BASH_SOURCE[0]}" )/.."
|
|
|
|
if [[ -f "$a2sDevel/.a2server_source" ]]; then
|
|
|
|
pushd $a2sDevel >/dev/null
|
|
|
|
a2sDevel="$PWD"
|
2016-10-27 13:35:20 +00:00
|
|
|
popd >/dev/null
|
|
|
|
else
|
2016-10-27 20:31:00 +00:00
|
|
|
a2sDevel=
|
2016-10-27 13:35:20 +00:00
|
|
|
fi
|
|
|
|
|
2016-10-27 20:31:00 +00:00
|
|
|
if [[ -z "$a2sDevel" ]]; then
|
2016-12-07 12:22:45 +00:00
|
|
|
currentVersion=$(wget -qO- "${a2sScriptURL}/setup/index.txt" | grep '^a2serverVersion' | cut -d '"' -f 2)
|
2016-10-27 20:31:00 +00:00
|
|
|
else
|
|
|
|
currentVersion=$(grep '^a2serverVersion' "$a2sDevel/setup/index.txt" | cut -d '"' -f 2)
|
|
|
|
fi
|
2015-10-03 12:25:44 +00:00
|
|
|
|
|
|
|
if [[ -f /usr/local/etc/A2SERVER-version ]]; then
|
2016-10-27 09:13:58 +00:00
|
|
|
read installedVersion </usr/local/etc/A2SERVER-version
|
|
|
|
if [[ $installedVersion != *.*.* ]]; then
|
|
|
|
# Deal with old three-digit version
|
|
|
|
installedVersion="${installedVersion:0:1}.${installedVersion:1:1}.${installedVersion:2}"
|
|
|
|
fi
|
2015-10-03 12:25:44 +00:00
|
|
|
else
|
2016-10-27 09:13:58 +00:00
|
|
|
installedVersion="1.0.0"
|
2015-10-03 12:25:44 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
autoAnswerYes=
|
|
|
|
for arg in $@; do
|
2016-10-25 19:09:52 +00:00
|
|
|
if [[ $arg == "-y" ]]; then
|
|
|
|
autoAnswerYes=1
|
|
|
|
break
|
|
|
|
fi
|
2015-10-03 12:25:44 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Update history:"
|
2016-10-27 20:31:00 +00:00
|
|
|
if [[ -z "$a2sDevel" ]]; then
|
2016-12-07 12:22:45 +00:00
|
|
|
wget -qO- "${a2sScriptURL}/update/versionhistory.txt"
|
2016-10-27 20:31:00 +00:00
|
|
|
else
|
|
|
|
cat "$a2sDevel/update/versionhistory.txt"
|
|
|
|
fi
|
2015-10-03 12:25:44 +00:00
|
|
|
echo
|
2016-10-27 20:31:00 +00:00
|
|
|
echo "installed version: ${installedVersion}"
|
|
|
|
echo "current version: ${currentVersion}"
|
2015-10-03 12:25:44 +00:00
|
|
|
echo
|
|
|
|
if [[ $autoAnswerYes ]]; then
|
2016-10-25 19:09:52 +00:00
|
|
|
REPLY="y"
|
2015-10-03 12:25:44 +00:00
|
|
|
else
|
2016-10-25 19:09:52 +00:00
|
|
|
echo -n "Do you want to update (or reinstall) A2SERVER? "
|
|
|
|
read
|
2015-10-03 12:25:44 +00:00
|
|
|
fi
|
|
|
|
if [[ ${REPLY:0:1} == "y" || ${REPLY:0:1} == "Y" ]]; then
|
2016-10-27 20:31:00 +00:00
|
|
|
if [[ -z "$a2sDevel" ]]; then
|
2016-12-07 12:22:45 +00:00
|
|
|
wget -q -O /tmp/setup "${a2sScriptURL}/setup/index.txt"; source /tmp/setup -i "$@"
|
2016-10-27 20:31:00 +00:00
|
|
|
else
|
|
|
|
"$a2sDevel/setup/index.txt"
|
|
|
|
fi
|
2015-10-03 12:25:44 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
unset currentVersion 2> /dev/null
|
|
|
|
unset installedVersion 2> /dev/null
|