mirror of
https://github.com/RasppleII/a2server.git
synced 2025-08-08 02:25:19 +00:00
Rewrote this script—when run, upgrades will always happen from a local tree, even if the script has to download a tree to /tmp to do it! This maintains an upgrade path from the a2server-update in Ivan's tree, but allow us to phase out that kind of thing because it's insecure. This is still effectively chipping away at the old structure, but it's a pretty sizable chip for one new script. Granted, that's because the old update script didn't really do a whole lot. *shrug* The next chip should do similar to the one-line installation from Ivan's website. Once we have that, we can remove the need for scripts to download files one at a time. That won't remove much complexity admittedly, but it'll remove some of it and every bit helps at this point.
91 lines
2.5 KiB
Bash
Executable File
91 lines
2.5 KiB
Bash
Executable File
#! /bin/bash
|
|
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
|
|
|
# update/index.txt - upgrade path from Ivan's a2server tree
|
|
#
|
|
# Ivan's a2server installed with a single copy-paste of a command line that
|
|
# downloaded a script and ran it sight-unseen. It also installed an alias
|
|
# command that would perform a similar one-liner to upgrade a2server to the
|
|
# latest version. This script provides that interface for upgrades.
|
|
|
|
a2sBranch="master"
|
|
a2sScriptURL="https://raw.githubusercontent.com/RasppleII/a2server/${a2sBranch}"
|
|
a2sTarball="https://github.com/RasppleII/a2server/archive/${a2sBranch}.tar.gz"
|
|
|
|
origDir="$PWD"
|
|
|
|
# Set a2sDevel to the location of the source tree if we're running in one
|
|
a2sDevel="$( dirname "${BASH_SOURCE[0]}" )/.."
|
|
if [[ -f "$a2sDevel/.a2server_source" ]]; then
|
|
pushd $a2sDevel >/dev/null
|
|
a2sDevel="$PWD"
|
|
popd >/dev/null
|
|
else
|
|
# We aren't in a source tree, empty the variable
|
|
a2sDevel=
|
|
fi
|
|
|
|
# Find the version in the install script
|
|
if [[ ! $a2sDevel ]]; then
|
|
newVersion=$(wget -qO- "${a2sScriptURL}/install.sh" | grep '^a2serverVersion' | cut -d '"' -f 2)
|
|
else
|
|
newVersion=$(grep '^a2serverVersion' "$a2sDevel/install.sh" | cut -d '"' -f 2)
|
|
fi
|
|
|
|
if [[ -f /usr/local/etc/A2SERVER-version ]]; then
|
|
read installedVersion < /usr/local/etc/A2SERVER-version
|
|
# Convert old three-digit version if needed
|
|
if [[ $installedVersion != *.*.* ]]; then
|
|
installedVersion="${installedVersion:0:1}.${installedVersion:1:1}.${installedVersion:2}"
|
|
fi
|
|
else
|
|
installedVersion="1.0.0"
|
|
fi
|
|
|
|
autoAnswerYes=
|
|
for arg in $@; do
|
|
if [[ $arg == "-y" ]]; then
|
|
autoAnswerYes=1
|
|
break
|
|
fi
|
|
done
|
|
|
|
# If running from local source tree, that's what you'll be upgrading to
|
|
printf "\nProject history:\n"
|
|
if [[ -z "$a2sDevel" ]]; then
|
|
wget -qO- "${a2sScriptURL}/update/versionhistory.txt"
|
|
else
|
|
cat "$a2sDevel/update/versionhistory.txt"
|
|
fi
|
|
|
|
cat <<EOT
|
|
|
|
installed version: ${installedVersion}
|
|
available version: ${newVersion}
|
|
|
|
EOT
|
|
|
|
if [[ $autoAnswerYes ]]; then
|
|
REPLY="y"
|
|
else
|
|
printf "Do you want to update (or reinstall) a2server? "
|
|
read
|
|
fi
|
|
if [[ ${REPLY:0:1} == "y" || ${REPLY:0:1} == "Y" ]]; then
|
|
if [[ -z "$a2sDevel" ]]; then
|
|
a2sInstall=$(mktemp -d /tmp/a2server.XXXXXXXXXXXX)
|
|
cd "$a2sInstall"
|
|
wget -O "a2server-${a2sBranch}.tar.gz" "$a2sTarball"
|
|
tar zxf "a2server-${a2sBranch}.tar.gz"
|
|
installScript="a2server-${a2sBranch}/install.sh"
|
|
else
|
|
installScript="${a2sDevel}/install.sh"
|
|
fi
|
|
source "$installScript" -i "$@"
|
|
fi
|
|
|
|
cd "$origDir"
|
|
if [[ $a2sInstall ]]; then
|
|
rm -rf "$a2sInstall"
|
|
fi
|