Make version semantic (Closes #49)

What's still missing from this is a version comparison mechanism.  The
reason why it is missing is that we only use this in one place at the
moment, and if you have a version string that is not three digits, your
version is recent enough.  This means we can save this for when there
are a common functions script to import and make the comparisons for us
without code duplication.
This commit is contained in:
T. Joseph Carter 2016-10-27 02:13:58 -07:00
parent 530b8d57f5
commit ee4078ab23
3 changed files with 20 additions and 8 deletions

View File

@ -56,9 +56,10 @@ if [[ $debianVersion ]]; then
fi
# skip this if already done
if [[ -f /usr/local/etc/A2SERVER-version && $(head -c 3 /usr/local/etc/A2SERVER-version) -ge 101 ]]; then
echo "A2SERVER: Netatalk is already installed."
else
if [[ -f /usr/local/etc/A2SERVER-version ]]; then
read a2sVersion </usr/local/etc/A2SERVER-version
fi
if [[ $a2sVersion = *.*.* || $a2sVersion -ge 101]]; then
echo "A2SERVER: Installing Netatalk (this will take a while)..."
# stop Netatalk and samba if running (during upgrade)
if [[ $(ps --no-headers -C afpd) ]]; then
@ -176,7 +177,10 @@ else
cd
rm -rf /tmp/netatalk
fi
else
echo "A2SERVER: Netatalk is already installed."
fi
unset a2sVersion
# --- Install MacIPgw
if ! hash macipgw &>/dev/null; then

View File

@ -9,7 +9,7 @@
# to download and execute, type:
# wget ivanx.com/a2server/setup; source setup
a2serverVersion="151"
a2serverVersion="1.5.1"
# Ensure URL we'll use ends in a /
case "$A2SERVER_SCRIPT_URL" in
@ -35,8 +35,12 @@ if lsb_release -a 2> /dev/null | grep -q 'Distributor ID:.Debian'; then
fi
fi
if [ -f /usr/local/etc/A2SERVER-version ]; then
installedVersion="$(cat /usr/local/etc/A2SERVER-version)"
if [[ -f /usr/local/etc/A2SERVER-version ]]; then
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
fi
echo "A2SERVER version available: $a2serverVersion"
echo "A2SERVER version installed: ${installedVersion:=None}"

View File

@ -10,9 +10,13 @@ esac
currentVersion=$(wget -qO- "${scriptURL}setup/index.txt" | grep '^a2serverVersion' | cut -d '"' -f 2)
if [[ -f /usr/local/etc/A2SERVER-version ]]; then
installedVersion=$(cat /usr/local/etc/A2SERVER-version)
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
else
installedVersion=100
installedVersion="1.0.0"
fi
autoAnswerYes=