From 5e709f0e2e430148a4d5ddc2b827a5298dd4a2a7 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Wed, 11 Apr 2018 06:34:52 -0700 Subject: [PATCH] Rewrote 2/3 of update/index.txt I really just intended to change a2sDevel to a2sSource and rewrite the lines that used it. It became a bigger rewrite with more verbose documentation text. --- update/index.txt | 102 +++++++++++++++++++++++++++++------------------ 1 file changed, 63 insertions(+), 39 deletions(-) diff --git a/update/index.txt b/update/index.txt index c4d059c..cc2a912 100755 --- a/update/index.txt +++ b/update/index.txt @@ -12,34 +12,23 @@ 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) +# Set a2sSource to the location of the source tree if we're running in one +a2sSource="$( dirname "${BASH_SOURCE[0]}" )/.." +pushd $a2sSource >/dev/null +a2sSource="$PWD" +popd >/dev/null +if [[ ! -f "$a2sSource/.a2server_source" ]]; then + a2sWebUpdate=1 + a2sSource=$(mktemp -d /tmp/a2server.XXXXXXXXXXXX) fi +installedVersion= 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= @@ -50,12 +39,43 @@ for arg in $@; do fi done +printf "\na2server web update\n\n" + +if (( $a2sWebUpdate )); then + newVersion=$(wget -qO- "${a2sScriptURL}/install.sh" | grep '^a2serverVersion' | cut -d '"' -f 2) + cat <<-EOT + You've started the single command a2server update script. This script will + download things behind the scenes, run them without much verification, and + then it will delete what it ran whether the upgrade finished successfully or + not. For this reason, we are going to be phasing this script out in the + future. + EOT +else + newVersion=$(grep '^a2serverVersion' "$a2sSource/install.sh" | cut -d '"' -f 2) + cat <<-EOT + You've started the single command a2server update script from inside the + a2server source directory for version $newVersion. This script will only + upgrade to or reinstall that version. + EOT +fi + +if [[ $installedVersion ]]; then + printf "\nRight now you have a2server %s installed\n" "$installedVersion" +else + printf "\nRight now you don't appear to have a2server installed\n" +fi + +if [[ ! $autoAnswerYes ]]; then + printf "\nPress Enter to continue " + read +fi + # If running from local source tree, that's what you'll be upgrading to printf "\nProject history:\n" -if [[ -z "$a2sDevel" ]]; then +if (( $a2sWebUpdate )); then wget -qO- "${a2sScriptURL}/update/versionhistory.txt" else - cat "$a2sDevel/update/versionhistory.txt" + cat "$a2sSource/update/versionhistory.txt" fi cat <