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 '/
  • .*do=Translation.*<.li>/d' "$PATH_SLXADMIN/templates/main-menu.html" + # Enable modules + ( + mkdir -p "$PATH_SLXADMIN/modules" + cd "$PATH_SLXADMIN/modules" || perror "Cannot cd to slxadmin" + for mod in adduser backup baseconfig baseconfig_bwlp bootstrap_datepicker bootstrap_timepicker bootstrap_multiselect bootstrap_switch dozmod eventlog exams js_chart js_circles js_moment js_vis locations main minilinux news serversetup-bwlp session statistics summernote sysconfig syslog systemstatus vmstore webinterface; do + name=${mod%%-*} + rm -f -- "$name" + ln -s "../modules-available/$mod" "$name" || pwarning "Could not activate module '$mod' (alias '$name')" + done + # Update DB + if ! ./install-all > "$TMPDIR/wwwup.log"; then + cat "$TMPDIR/wwwup.log" + perror "Updating the web interface database failed" + fi + if grep -q 'Result: UPDATE_FAILED' "$TMPDIR/wwwup.log"; then + cat "$TMPDIR/wwwup.log" + perror "Updating the web interface database failed" + fi + if [ "x$(tail -n -1 "$TMPDIR/wwwup.log")" != "Done." ]; then + pwarning "slxadmin updater didn't finish with 'Done.'" + fi + ) + # Patch config with new features + # TODO: In the future it might be easier to parse the old config for the sql pass and just create a new one + if ! grep -q 'MENU_CAT_SORT_ORDER' "$PATH_SLXADMIN/config.php"; then + cat >>"$PATH_SLXADMIN/config.php" <<-"BLABLA" + // Menu sort order + $MENU_CAT_SORT_ORDER = array('main.content' => 0, 'main.settings-client' => 1, 'main.settings-server' => 2, 'main.status' => 3, 'main.users' => 4); + $MENU_SETTING_SORT_ORDER = array( + 'news' => 0, 'sysconfig' => 1, 'baseconfig' => 2, 'locations' => 3, 'exams' => 4, 'minilinux' => 5, // main.content + 'serversetup' => 0, 'internetaccess' => 1, 'vmstore' => 2, 'webinterface' => 3, 'backup' => 4, // main.settings + 'systemstatus' => 0, 'eventlog' => 1, 'syslog' => 2, 'statistics' => 3 // main.status + ); + BLABLA + fi + if ! grep -q 'CONFIG_DOZMOD_EXPIRE' "$PATH_SLXADMIN/config.php"; then + cat >>"$PATH_SLXADMIN/config.php" <<-"BLABLA" + /* for the dozmod API proxy cache */ + define('CONFIG_DOZMOD_EXPIRE', 60*60); // 1 Minute + BLABLA + fi fixperms "$PATH_SLXADMIN" root:root chmod 0640 "$PATH_SLXADMIN/config.php" chown root:www-data "$PATH_SLXADMIN/config.php" - curl -s "http://localhost/slx-admin/api.php?do=update" > /dev/null - curl -s "http://localhost/slx-admin/api.php?do=update" | grep -q 'Up to date' || perror "Updating the web interface database failed" + ln -s -f "$PATH_TFTP" "/srv/openslx/www/tftp" || perror "Could not symlink $PATH_TFTP to /srv/openslx/www/tftp" echo "Web interface upgrade complete" fi -- cgit v1.2.3-55-g7522