summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsatellit_upgrader/pack-update.sh21
-rw-r--r--satellit_upgrader/updater.template.sh83
2 files changed, 96 insertions, 8 deletions
diff --git a/satellit_upgrader/pack-update.sh b/satellit_upgrader/pack-update.sh
index 33bbfc5..15d64ca 100755
--- a/satellit_upgrader/pack-update.sh
+++ b/satellit_upgrader/pack-update.sh
@@ -22,10 +22,26 @@ patchtgz () {
#[ -d "$TMPDIR" ] || perror "TMPDIR fail."
declare -rg UPDATER="updater.sh"
declare -rg TGZ_SLXADMIN="files/slx-admin.tar.gz"
+declare -rg TGZ_DOZMOD="files/dozmod.tar.gz"
+declare -rg TGZ_TASKMANAGER="files/taskmanager.tar.gz"
+declare -rg TGZ_TFTP="files/syslinux.tar.gz"
cp "updater.template.sh" "$UPDATER" || perror "could not copy template"
chmod +x "$UPDATER"
+addpayload () {
+ echo -n "Includes $2: "
+ local FILEVAR=$1
+ local FILENAME=${!FILEVAR}
+ if [ -e "${FILENAME}" ]; then
+ echo "yes"
+ patchtgz "$FILEVAR" "$FILENAME"
+ else
+ echo "no"
+ patchtgz "$FILEVAR"
+ fi
+}
+
# Replace variables
# slxadmin version
echo -n "Includes SLX-Admin: "
@@ -40,6 +56,11 @@ else
echo "no"
patchtgz "TGZ_SLXADMIN"
fi
+
+addpayload "TGZ_DOZMOD" "Dozmod server"
+addpayload "TGZ_TASKMANAGER" "Taskmanager"
+addpayload "TGZ_TFTP" "TFTP/PxeLinux data"
+
# Last patch: Payload offset
# Calc payload offset, which is tricky as the size changes as we patch
SIZE=$(stat -c %s "$UPDATER")
diff --git a/satellit_upgrader/updater.template.sh b/satellit_upgrader/updater.template.sh
index 427d288..f02e57f 100644
--- a/satellit_upgrader/updater.template.sh
+++ b/satellit_upgrader/updater.template.sh
@@ -12,14 +12,21 @@ done
declare -rg SELFPID=$$
perror () {
if [ -n "$IGNORE_ERRORS" ]; then
- echo "[ERROR] $@"
+ echo -n -e '\033[01;31m[ERROR]\033[00m '
+ echo "$@"
return 0
fi
- echo "[FATAL] $@"
+ echo -n -e '\033[01;31m[FATAL]\033[00m '
+ echo "$@"
[ "$$" != "$SELFPID" ] && kill "$SELFPID"
exit 1
}
+pwarning () {
+ echo -n -e '\033[01;33m[WARNING]\033[00m '
+ echo "$@"
+}
+
if [ "$UID" != "0" ]; then
perror "Must be running as root"
fi
@@ -34,13 +41,24 @@ mysql () {
"$(which mysql)" --defaults-extra-file=/etc/mysql/debian.cnf --default-character-set=utf8 "$@"
}
+# ** Restart given systemd service, warn if it fails but do not bail out
+restart_service () {
+ systemctl restart "$1" || pwarning "Could not restart service $1 - !! YOU SHOULD REBOOT THE SERVER !!"
+}
+
# ** Constants - to be patched by the packaging script
declare -rg TARGET_WEBIF_VERSION="%TARGET_WEBIF_VERSION%"
declare -rg TGZ_SLXADMIN="%TGZ_SLXADMIN%"
+declare -rg TGZ_DOZMOD="%TGZ_DOZMOD%"
+declare -rg TGZ_TASKMANAGER="%TGZ_TASKMANAGER%"
+declare -rg TGZ_TFTP="%TGZ_TFTP%"
declare -rg PAYLOAD_OFFSET="%PAYLOAD_OFFSET%"
# ** Constants - hardcoded or determined at runtime
declare -rg PATH_SLXADMIN="/srv/openslx/www/slx-admin"
+declare -rg PATH_DOZMOD="/opt/dmsd"
+declare -rg PATH_TASKMANAGER="/opt/taskmanager"
+declare -rg PATH_TFTP="/srv/openslx/tftp"
# ** Check if constants have been filled, bail out otherwise
if [ -z "$TARGET_WEBIF_VERSION" ] || [[ "$TARGET_WEBIF_VERSION" == %*% ]]; then
@@ -90,13 +108,62 @@ if [ -n "$TGZ_SLXADMIN" ]; then
fi
# ************************* Dozmod *************************
-echo "* Dozentenmodul"
-echo "Adjusting mysql permissions of user sat"
-mysql -e 'GRANT CREATE, ALTER ON sat.* TO sat@localhost' || perror "Could not GRANT permissions ON sat.* to sat@localhost"
-mysql -e 'GRANT SELECT ON openslx.location TO sat@localhost' || perror "Could not GRANT permissions ON openslx.location to sat@localhost"
+if [ -n "$TGZ_DOZMOD" ]; then
+ [ -e "$TMPDIR/$TGZ_DOZMOD" ] || perror "$TGZ_DOZMOD missing from payload."
+ echo "* Dozentenmodul"
+ echo "Adjusting mysql permissions of user sat"
+ mysql -e 'GRANT CREATE, ALTER ON sat.* TO sat@localhost' || perror "Could not GRANT permissions ON sat.* to sat@localhost"
+ mysql -e 'GRANT SELECT ON openslx.location TO sat@localhost' || perror "Could not GRANT permissions ON openslx.location to sat@localhost"
+ echo "Extracting new jar"
+ tar -x -C "$PATH_DOZMOD" -f "$TMPDIR/$TGZ_DOZMOD" || perror "Could not extract $TGZ_DOZMOD to $PATH_DOZMOD"
+ if mysql -e 'SHOW TABLES' openslx | grep -q '^location$'; then
+ echo "Enabling location feature"
+ sed -i '/^db.location-table\b/d' "$PATH_DOZMOD/config.properties"
+ echo 'db.location-table = openslx.location' >> "$PATH_DOZMOD/config.properties"
+ fi
+ chmod 0640 "$PATH_DOZMOD/config.properties"
+ chown root:images "$PATH_DOZMOD/config.properties"
+ echo "Restarting service"
+ restart_service dmsd
+ echo "Dozentenmodul Server Daemon upgrade complete"
+fi
+# ********************** Taskmanager ***********************
+if [ -n "$TGZ_TASKMANAGER" ]; then
+ [ -e "$TMPDIR/$TGZ_TASKMANAGER" ] || perror "$TGZ_TASKMANAGER missing from payload"
+ echo "* Task manager"
+ echo "Extracting new jar and data"
+ # Replacement trick (see slxadmin)
+ tar -x -C "$PATH_TASKMANAGER" -f "$TMPDIR/$TGZ_TASKMANAGER" || perror "Could not extract $TGZ_TASKMANAGER to $PATH_TASKMANAGER"
+ rm -rf -- "$PATH_TASKMANAGER/data" "$PATH_TASKMANAGER/scripts" "$PATH_TASKMANAGER/plugins"
+ tar -x -C "$PATH_TASKMANAGER" -f "$TMPDIR/$TGZ_TASKMANAGER"
+ echo "Restarting service"
+ restart_service taskmanager
+ echo "Taskmanager upgrade complete"
+fi
+
+# ************************** TFTP **************************
+if [ -n "$TGZ_TFTP" ]; then
+ [ -e "$TMPDIR/$TGZ_TFTP" ] || perror "$TGZ_TFTP missing from payload"
+ echo "* TFTP"
+ echo "Extracting new jar and data"
+ rm -rf -- "$PATH_TFTP"
+ mkdir -p "$PATH_TFTP"
+ tar -x -C "$PATH_TFTP" -f "$TMPDIR/$TGZ_TFTP" || perror "Could not extract $TGZ_TFTP to $PATH_TFTP"
+ chown -R taskmanager:taskmanager "$PATH_TFTP"
+ echo "Resetting pxe menu"
+ mysql -e 'UPDATE openslx.property SET value = "invalid" WHERE name = "server-ip"' || pwarning "Could not reset pxe menu status; manual regeneration of menu required"
+ echo "TFTP upgrade complete"
+fi
+
+# ********************** lighttpd config *******************
+if [ -e "$TMPDIR/lighttpd.conf" ] && [ -e "/etc/lighttpd/lighttpd.conf" ]; then
+ echo "* Replacing lighttpd.conf"
+ cp "$TMPDIR/lighttpd.conf" "/etc/lighttpd/lighttpd.conf" || perror "Could not replace /etc/lighttpd/lighttpd.conf"
+ restart_service lighttpd
+ echo "lighttpd config upgrade complete"
+fi
-# File end
exit 0
-# Payload to follow
+# File end