From 16e1306dbb9a5180bd6efc15a37becf1d0e06ea0 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Thu, 6 Sep 2018 13:35:01 -0700 Subject: [PATCH] Cleanups for consistency with a2cloud mostly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added bash check to install.sh - Switched to using top_src instead of a2sSource (not yet in ivan.sh subscripts) - Added processing of -y and -c flags to install.sh ala a2cloud - Put the intro blurb and continue question in install.sh (didn't remove the one from ivan.sh yet as it serves as a useful way to test things about to be in progress and stop after them…) - Added the fixup script, currently empty for a2server, but ohh will that be changing! - Added the show_changes script. It doesn't do a whole lot for a2server just like it doesn't for a2cloud yet. To be addressed. Higher priorities right now. - Fixed a bug where fresh installs would say that upgrading from your version of a2server wasn't supported anymore. --- install.sh | 79 ++++++++++++++++++++++++++++++++++++-------- scripts/fixup | 27 +++++++++++++++ scripts/show_changes | 33 ++++++++++++++++++ setup/index.txt | 28 ++++++++-------- setup/ivan.sh | 21 +++++------- update/index.txt | 32 +++++++++--------- 6 files changed, 165 insertions(+), 55 deletions(-) create mode 100755 scripts/fixup create mode 100755 scripts/show_changes diff --git a/install.sh b/install.sh index 35a8f2a..c19ab0d 100755 --- a/install.sh +++ b/install.sh @@ -8,21 +8,74 @@ # scripts themselves. Software used or installed by these scripts is subject # to other licenses. This work is published from the United States. -a2serverVersion="1.9.0" -a2sScriptURL="https://raw.githubusercontent.com/RasppleII/a2server/master" +a2serverVersion="1.9.0" # Leave this quoted! -# Find the path of our source directory -a2sSource="$( dirname "${BASH_SOURCE[0]}" )" -echo $a2source -pushd $a2sSource >/dev/null -a2sSource="$PWD" -popd >/dev/null -if [[ ! -f "$a2sSource/.a2server_source" ]]; then - printf "\na2server: cannot find a2server source directory in $a2sSource.\n\n" +if test "x$BASH" = "x"; then + printf "This script requires bash. Please run\nit as ./install.sh from the source\ndirectory.\n" exit 1 fi -# Run the legacy setup script for anything not yet ported -if [[ -e "${a2sSource}/setup/ivan.sh" ]]; then - "${a2sSource}/setup/ivan.sh" "$@" +# Find the path of our source directory +top_src="$( dirname "${BASH_SOURCE[0]}" )" +pushd $top_src >/dev/null +top_src="$PWD" +popd >/dev/null +if [[ ! -f "$top_src/.a2server_source" ]]; then + printf "\na2server: cannot find a2server source directory in $top_src.\n\n" + exit 1 +fi + +noPicoPkg= +autoAnswerYes= + +process_args() { + while [[ $1 ]]; do + if [[ $1 == "-c" ]]; then + shift + noPicoPkg="-c" + elif [[ $1 == "-y" ]]; then + shift + autoAnswerYes="-y" + else + shift + fi + done +} + +process_args "$@" + +# FIXME: Show version, changes, config, allow reconfig, etc… +"$top_src/scripts/show_changes" +cat </dev/null +top_src="$PWD" +popd >/dev/null +if [[ ! -f "$top_src/.a2server_source" ]]; then + printf "\na2server: cannot find a2server source directory in $top_src.\n\n" + exit 1 +fi + +newVersion=$(grep '^a2ServerVersion' "$top_src/install.sh" | cut -d '"' -f 2) + +if [[ -f /usr/local/etc/A2SERVER-version ]]; then + read installedVersion /dev/null - a2sSource="$PWD" +# Set top_src to the location of the source tree if we're running in one +top_src="$( dirname "${BASH_SOURCE[0]}" )/.." +if [[ -f "$top_src/.a2server_source" ]]; then + pushd $top_src >/dev/null + top_src="$PWD" popd >/dev/null cat <<-EOT This script exists solely for backward-compatibility with IvanX's a2server website and aliases installed by older versions. You appear to have an a2server source directory here: - $a2sSource + $top_src Please run ./install.sh in that directory. Thanks! @@ -76,18 +76,18 @@ if [[ ! $autoAnswerYes ]]; then fi fi -a2sSource=$(mktemp -d /tmp/a2server.XXXXXXXXXXXX) +top_src=$(mktemp -d /tmp/a2server.XXXXXXXXXXXX) # Normally tarballs unpack in a subdirectory, but we want it to unpack into -# $a2sSource directly (even though the directory has the tarball in it.) -printf "\na2server: Downloading installer to $a2sSource.\n" -wget -O "$a2sSource/a2server-$a2sBranch.tar.gz" "$a2sTarball" -tar -C $a2sSource --strip-components=1 -zxf "$a2sSource/a2server-${a2sBranch}.tar.gz" +# $top_src directly (even though the directory has the tarball in it.) +printf "\na2server: Downloading installer to $top_src.\n" +wget -O "$top_src/a2server-$a2sBranch.tar.gz" "$a2sTarball" +tar -C $top_src --strip-components=1 -zxf "$top_src/a2server-${a2sBranch}.tar.gz" # Now we actually run the installer as if we were installing it by hand printf "\na2server: Running the installer now.\n" -"${a2sSource}/install.sh" "$@" +"${top_src}/install.sh" "$@" # Clean up and delete the installer we downloaded -printf "\na2server: Finished with installer, now deleting ${a2sSource}.\n" -rm -rf "$a2sSource" +printf "\na2server: Finished with installer, now deleting ${top_src}.\n" +rm -rf "$top_src" diff --git a/setup/ivan.sh b/setup/ivan.sh index b8ed1dc..48fb377 100755 --- a/setup/ivan.sh +++ b/setup/ivan.sh @@ -7,19 +7,18 @@ # more info is at http://ivanx.com/a2server a2serverVersion="1.9.0" -a2sScriptURL="https://raw.githubusercontent.com/RasppleII/a2server/master" # Find the path of our source directory -a2sSource="$( dirname "${BASH_SOURCE[0]}" )/.." -pushd $a2sSource >/dev/null -a2sSource="$PWD" +top_src="$( dirname "${BASH_SOURCE[0]}" )/.." +pushd $top_src >/dev/null +top_src="$PWD" popd >/dev/null -if [[ ! -f "$a2sSource/.a2server_source" ]]; then - printf "\na2server: cannot find a2server source directory in $a2sSource.\n\n" +if [[ ! -f "$top_src/.a2server_source" ]]; then + printf "\na2server: cannot find a2server source directory in $top_src.\n\n" exit 1 fi -compare_version="$a2sSource/scripts/compare_version" +compare_version="$top_src/scripts/compare_version" isRpi= [[ -f /usr/bin/raspi-config ]] && isRpi=1 @@ -39,9 +38,7 @@ if [[ -f /usr/local/etc/A2SERVER-version ]]; then installedVersion="${installedVersion:0:1}.${installedVersion:1:1}.${installedVersion:2}" fi fi -echo "A2SERVER version available: $a2serverVersion" -echo "A2SERVER version installed: ${installedVersion:=None}" -if [[ $installedVersion == "None" ]]; then +if [[ $installedVersion != *.*.* ]]; then installedVersion=0 fi @@ -113,7 +110,7 @@ fi a2server_update=0 doSetup=1 -if "$compare_version" $installedVersion lt 1.5.2; then +if [[ "$installedVersion" != "0" ]] && "$compare_version" $installedVersion lt 1.5.2; then a2server_update=1 fi @@ -243,7 +240,7 @@ if (( $doSetup )); then fi for _script in $a2sSubScripts; do - "$a2sSource/scripts/$_script" + "$top_src/scripts/$_script" done rm -f /tmp/a2server-packageReposUpdated diff --git a/update/index.txt b/update/index.txt index cc2a912..b4ce5ab 100755 --- a/update/index.txt +++ b/update/index.txt @@ -12,14 +12,14 @@ a2sBranch="master" a2sScriptURL="https://raw.githubusercontent.com/RasppleII/a2server/${a2sBranch}" a2sTarball="https://github.com/RasppleII/a2server/archive/${a2sBranch}.tar.gz" -# 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" +# Set top_src to the location of the source tree if we're running in one +top_src="$( dirname "${BASH_SOURCE[0]}" )/.." +pushd $top_src >/dev/null +top_src="$PWD" popd >/dev/null -if [[ ! -f "$a2sSource/.a2server_source" ]]; then +if [[ ! -f "$top_src/.a2server_source" ]]; then a2sWebUpdate=1 - a2sSource=$(mktemp -d /tmp/a2server.XXXXXXXXXXXX) + top_src=$(mktemp -d /tmp/a2server.XXXXXXXXXXXX) fi installedVersion= @@ -51,7 +51,7 @@ if (( $a2sWebUpdate )); then future. EOT else - newVersion=$(grep '^a2serverVersion' "$a2sSource/install.sh" | cut -d '"' -f 2) + newVersion=$(grep '^a2serverVersion' "$top_src/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 @@ -75,7 +75,7 @@ printf "\nProject history:\n" if (( $a2sWebUpdate )); then wget -qO- "${a2sScriptURL}/update/versionhistory.txt" else - cat "$a2sSource/update/versionhistory.txt" + cat "$top_src/update/versionhistory.txt" fi cat <