summaryrefslogtreecommitdiffstats
path: root/satellit_upgrader/updater.template.sh
diff options
context:
space:
mode:
authorSimon Rettberg2018-01-12 22:52:50 +0100
committerSimon Rettberg2018-01-12 22:52:50 +0100
commit6dd0417ab13ac65808f7a4645ece4e20bc716670 (patch)
tree590a65e1c6d6749070ec92774b75b9242d04d0de /satellit_upgrader/updater.template.sh
parent[SSUS] Patch post_max_size independenly of upload_max_filesize (diff)
downloadsetup-scripts-6dd0417ab13ac65808f7a4645ece4e20bc716670.tar.gz
setup-scripts-6dd0417ab13ac65808f7a4645ece4e20bc716670.tar.xz
setup-scripts-6dd0417ab13ac65808f7a4645ece4e20bc716670.zip
[SSUS] Remove old files when updating slx-admin; check OS version more thoroughly
Diffstat (limited to 'satellit_upgrader/updater.template.sh')
-rw-r--r--satellit_upgrader/updater.template.sh25
1 files changed, 20 insertions, 5 deletions
diff --git a/satellit_upgrader/updater.template.sh b/satellit_upgrader/updater.template.sh
index 196ccf1..e50b020 100644
--- a/satellit_upgrader/updater.template.sh
+++ b/satellit_upgrader/updater.template.sh
@@ -5,16 +5,25 @@
if [ ! -d "/opt/dmsd" ] && [ ! -d "/srv/openslx/www/slx-admin" ]; then
echo "This system doesn't look like a bwLehrpool Satellite Server"
+ echo "(Or this updater is really old)"
exit 1
fi
-TEST1=$(which systemctl)
-TEST2=$(lsb_release -sc)
-if [ -z "$TEST1" ] || [ "x$TEST2" != "xjessie" ]; then
+if [ "$(lsb_release -si)" != "Debian" ]; then
+ echo "This updater only supports Debian-based satellite servers"
+ exit 1
+fi
+
+TEST2=$(lsb_release -sr)
+if [ "${TEST2%%.*}" -lt 8 ]; then
echo "This Version of the bwLehrpool Satellite Server is too old!"
exit 1
fi
-unset TEST1 TEST2
+if [ "${TEST2%%.*}" -gt 8 ]; then
+ echo "This Version of the bwLehrpool Satellite Server is too new!"
+ exit 1
+fi
+unset TEST2
unset TMPDIR
[ -n "$TMPDIR" ] && exit 1
@@ -148,6 +157,7 @@ fi
# ************** Extract payload ***************************
declare -rg TMPDIR=$(mktemp -d)
+export TMPDIR
[ -z "$TMPDIR" ] && perror "Could not create temporary directory for installer"
dd "bs=$PAYLOAD_OFFSET" "if=$0" skip=1 | tar -z -x -C "$TMPDIR"
RET=$?
@@ -205,8 +215,13 @@ if [ -n "$TGZ_SLXADMIN" ]; then
[ -e "$TMPDIR/$TGZ_SLXADMIN" ] || perror "$TGZ_SLXADMIN missing from payload."
echo "* SLX-Admin: $CURRENT_WEBIF_VERSION -> $TARGET_WEBIF_VERSION"
# Test archive
- tar tf "$TMPDIR/$TGZ_SLXADMIN" >/dev/null 2>&1 || perror "Could not read $TGZ_SLXADMIN"
+ INCMODS=$(mktemp)
+ tar tf "$TMPDIR/$TGZ_SLXADMIN" | grep -oP '^modules-available/[^/]+/$' > "$INCMODS" || perror "Could not read $TGZ_SLXADMIN"
+ # Remove old files - wipe selectively, just in case someone added a new module by hand
rm -rf -- "$PATH_SLXADMIN/"{inc,apis,modules,templates,Mustache,script,style}
+ while read -r line || [[ -n "$line" ]]; do
+ rm -rf -- "$PATH_SLXADMIN/$line"
+ done < "$INCMODS"
tar -x -C "$PATH_SLXADMIN" -f "$TMPDIR/$TGZ_SLXADMIN" || perror "Could not extract $TGZ_SLXADMIN to $PATH_SLXADMIN"
rm -f -- "$PATH_SLXADMIN/config.php.example"
# New config.php supplied