From 8d375cb0c6aae0965a50039fcc989fb09a072189 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 4 Jul 2016 16:56:25 +0200 Subject: Update to latest slxadmin --- satellit_upgrader/updater.template.sh | 66 ++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 13 deletions(-) (limited to 'satellit_upgrader/updater.template.sh') diff --git a/satellit_upgrader/updater.template.sh b/satellit_upgrader/updater.template.sh index 2557744..69658fd 100644 --- a/satellit_upgrader/updater.template.sh +++ b/satellit_upgrader/updater.template.sh @@ -96,7 +96,7 @@ declare -rg PATH_LDADP="/opt/ldadp" # ** Check if constants have been filled, bail out otherwise if [ -z "$TARGET_WEBIF_VERSION" ] || [[ "$TARGET_WEBIF_VERSION" == %*% ]]; then - perror "Bad upgrader: TARGET_WEBIF_VERSION not set" + [ -n "$TGZ_SLXADMIN" ] && perror "Bad upgrader: TARGET_WEBIF_VERSION not set" fi if [ -z "$PAYLOAD_OFFSET" ] || [[ "$PAYLOAD_OFFSET" == %*% ]]; then perror "Bad upgrader: PAYLOAD_OFFSET not set" @@ -105,12 +105,14 @@ fi # ********************************************************** # Get current webif version -declare -rg CURRENT_WEBIF_VERSION=$(mysql -e 'SELECT value FROM openslx.property WHERE name = "webif-version" LIMIT 1' | tail -n 1) -[ -z "$CURRENT_WEBIF_VERSION" ] && perror "Could not determine current webif version" -if [ "$TARGET_WEBIF_VERSION" = "missing" ] || [ "$CURRENT_WEBIF_VERSION" -le "$TARGET_WEBIF_VERSION" ]; then - : # Negate so NaN triggers else branch -else - perror "This update seems to be older than the server version you're currently running" +if [ -n "$TGZ_SLXADMIN" ]; then + declare -rg CURRENT_WEBIF_VERSION=$(mysql -e 'SELECT value FROM openslx.property WHERE name = "webif-version" LIMIT 1' | tail -n 1) + [ -z "$CURRENT_WEBIF_VERSION" ] && perror "Could not determine current webif version" + if [ "$TARGET_WEBIF_VERSION" = "missing" ] || [ "$CURRENT_WEBIF_VERSION" -le "$TARGET_WEBIF_VERSION" ]; then + : # Negate so NaN triggers else branch + else + perror "This update seems to be older than the server version you're currently running" + fi fi # **************** Fix tmpdelete cronjob ******************* @@ -153,17 +155,55 @@ if [ -n "$TGZ_SLXADMIN" ]; then echo "* SLX-Admin: $CURRENT_WEBIF_VERSION -> $TARGET_WEBIF_VERSION" # Cheap hack: extract, then delete, extract again to get rid of old unused files. If the extraction fails, we don't leave # the user with a broken webif, because we didn't remove the directories yet - tar -x -C "$PATH_SLXADMIN" -f "$TMPDIR/$TGZ_SLXADMIN" || perror "Could not extract $TGZ_SLXADMIN to $PATH_SLXADMIN" - rm -rf -- "$PATH_SLXADMIN/inc" "$PATH_SLXADMIN/apis" "$PATH_SLXADMIN/modules" "$PATH_SLXADMIN/templates" + tar tf "$TMPDIR/$TGZ_SLXADMIN" >/dev/null 2>&1 || perror "Could not extract $TGZ_SLXADMIN to $PATH_SLXADMIN" + rm -rf -- "$PATH_SLXADMIN/"{inc,apis,modules,templates,Mustache,script,style} tar -x -C "$PATH_SLXADMIN" -f "$TMPDIR/$TGZ_SLXADMIN" rm -- "$PATH_SLXADMIN/config.php.example" - # Remove translation feature - sed -i '/