summaryrefslogtreecommitdiffstats
path: root/satellit_upgrader/updater.template.sh
diff options
context:
space:
mode:
authorSimon Rettberg2016-07-04 16:56:25 +0200
committerSimon Rettberg2016-07-04 16:56:25 +0200
commit8d375cb0c6aae0965a50039fcc989fb09a072189 (patch)
tree77539c5f4c57d593893e330f1c664b2645951235 /satellit_upgrader/updater.template.sh
parent[SSPS] Create tftp symlink for usb bootstick support (diff)
downloadsetup-scripts-8d375cb0c6aae0965a50039fcc989fb09a072189.tar.gz
setup-scripts-8d375cb0c6aae0965a50039fcc989fb09a072189.tar.xz
setup-scripts-8d375cb0c6aae0965a50039fcc989fb09a072189.zip
Update to latest slxadmin
Diffstat (limited to 'satellit_upgrader/updater.template.sh')
-rw-r--r--satellit_upgrader/updater.template.sh66
1 files changed, 53 insertions, 13 deletions
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 '/<li>.*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