summaryrefslogtreecommitdiffstats
path: root/satellit_upgrader
diff options
context:
space:
mode:
authorSimon Rettberg2016-07-05 17:44:39 +0200
committerSimon Rettberg2016-07-05 17:44:39 +0200
commitc98979078ae1c872664e35d8b3c8de0fb959537e (patch)
treeb086961eda7cd71524599d2e7325fcc0fa279501 /satellit_upgrader
parent[SSUS] Include lighttpd.conf from installer (diff)
downloadsetup-scripts-c98979078ae1c872664e35d8b3c8de0fb959537e.tar.gz
setup-scripts-c98979078ae1c872664e35d8b3c8de0fb959537e.tar.xz
setup-scripts-c98979078ae1c872664e35d8b3c8de0fb959537e.zip
[SSUS] Various minor fixes/improvements
Diffstat (limited to 'satellit_upgrader')
-rwxr-xr-xsatellit_upgrader/pack-update.sh30
-rw-r--r--satellit_upgrader/updater.template.sh65
2 files changed, 73 insertions, 22 deletions
diff --git a/satellit_upgrader/pack-update.sh b/satellit_upgrader/pack-update.sh
index 5f7e559..15768c1 100755
--- a/satellit_upgrader/pack-update.sh
+++ b/satellit_upgrader/pack-update.sh
@@ -18,8 +18,6 @@ patchtgz () {
sed -i "s,%${VARNAME}%,${VALUE},g" "$UPDATER" || perror "could not patchtgz $VARNAME in updater"
}
-#declare -rg TMPDIR=$(mktemp -d)
-#[ -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"
@@ -28,9 +26,31 @@ declare -rg TGZ_TFTP="files/tftpdir.tar.gz"
declare -rg TGZ_IPXE="files/ipxe.tar.gz"
declare -rg TGZ_LDADP="files/ldadp.tar.gz"
+# Prepare installer
cp "updater.template.sh" "$UPDATER" || perror "could not copy template"
chmod +x "$UPDATER"
+# Prepare source directory
+declare -rg SRCDIR=$1
+if [ -z "$SRCDIR" ]; then
+ echo "Usage: $0 <srcdir>"
+ echo "Where <srcdir> is the directory you put all the file to pack as payload"
+ exit 1
+fi
+
+if [ "x$(stat -c "%d:%i" "$SRCDIR")" != "x$(stat -c "%d:%i" files)" ]; then
+ rm -rf "files"
+ [ -d "files" ] && perror "files still exists..."
+ cp -r "$SRCDIR" "files"
+fi
+
+if [ ! -d "$SRCDIR" ]; then
+ echo "Source dir '$SRCDIR' not found!"
+fi
+
+#declare -rg TMPDIR=$(mktemp -d)
+#[ -d "$TMPDIR" ] || perror "TMPDIR fail."
+
addpayload () {
echo -n "Includes $2: "
local FILEVAR=$1
@@ -63,7 +83,7 @@ addinstallfile () {
echo -n "Includes SLX-Admin: "
if [ -e "$TGZ_SLXADMIN" ]; then
echo "yes"
- VERS=$(tar -xOf "$TGZ_SLXADMIN" "inc/database.inc.php" | grep -A3 'function getExpectedSchemaVersion' | grep -o -E 'return [0-9]+' | grep -o -E '[0-9]+')
+ VERS=$(date +%Y%j%H)
[ -n "$VERS" ] || perror "Could not extract slx-admin version!"
echo "Version: $VERS"
sed -i "s/%TARGET_WEBIF_VERSION%/${VERS}/" "$UPDATER" || perror "could not patch slxadmin version in updater"
@@ -82,6 +102,10 @@ addpayload "TGZ_LDADP" "ldap/ad proxy"
addinstallfile "atftpd.service"
addinstallfile "lighttpd.conf"
+# TODO: Unify more
+source ../satellit_installer/includes/10-sudo_config.inc
+sudo_config files/tm-sudo-config
+
# 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 69658fd..d4c7e5f 100644
--- a/satellit_upgrader/updater.template.sh
+++ b/satellit_upgrader/updater.template.sh
@@ -131,6 +131,23 @@ declare -rg FILEDIR="$TMPDIR/files"
# **********************************************************
+# ********************** Taskmanager ***********************
+# Do this first in case one of the later updates depends on the 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" "$PATH_TASKMANAGER/taskmanager.sh"
+ tar -x -C "$PATH_TASKMANAGER" -f "$TMPDIR/$TGZ_TASKMANAGER"
+ fixperms "$PATH_TASKMANAGER" root:root
+ chmod -R a+x "$PATH_TASKMANAGER/scripts"
+ echo "Restarting service"
+ restart_service taskmanager
+ echo "Taskmanager upgrade complete"
+fi
+
# ************************** IPXE **************************
if [ -n "$TGZ_IPXE" ]; then
[ -e "$TMPDIR/$TGZ_IPXE" ] || perror "$TGZ_IPXE missing from payload"
@@ -145,7 +162,7 @@ if [ -n "$TGZ_IPXE" ]; then
echo "iPXE upgrade complete"
# Trigger default compile in the background so the next regen doesn't take too long
{
- cd "$PATH_IPXE/src" && sudo -u taskmanager nice -n 10 make bin/undionly.kkkpxe > /dev/null 2>&1
+ cd "$PATH_IPXE/src" && sudo -n -u taskmanager nice -n 10 make -j2 bin/undionly.kkkpxe > /dev/null 2>&1
} &
fi
@@ -158,7 +175,7 @@ if [ -n "$TGZ_SLXADMIN" ]; then
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"
+ rm -f -- "$PATH_SLXADMIN/config.php.example"
# Enable modules
(
mkdir -p "$PATH_SLXADMIN/modules"
@@ -169,6 +186,7 @@ if [ -n "$TGZ_SLXADMIN" ]; then
ln -s "../modules-available/$mod" "$name" || pwarning "Could not activate module '$mod' (alias '$name')"
done
# Update DB
+ cd "$PATH_SLXADMIN"
if ! ./install-all > "$TMPDIR/wwwup.log"; then
cat "$TMPDIR/wwwup.log"
perror "Updating the web interface database failed"
@@ -177,7 +195,8 @@ if [ -n "$TGZ_SLXADMIN" ]; then
cat "$TMPDIR/wwwup.log"
perror "Updating the web interface database failed"
fi
- if [ "x$(tail -n -1 "$TMPDIR/wwwup.log")" != "Done." ]; then
+ if [ "x$(tail -n -1 "$TMPDIR/wwwup.log")" != "xDone." ]; then
+ cat "$TMPDIR/wwwup.log"
pwarning "slxadmin updater didn't finish with 'Done.'"
fi
)
@@ -203,6 +222,17 @@ if [ -n "$TGZ_SLXADMIN" ]; then
fixperms "$PATH_SLXADMIN" root:root
chmod 0640 "$PATH_SLXADMIN/config.php"
chown root:www-data "$PATH_SLXADMIN/config.php"
+ # Update version number in DB - doesn't make too much sense like this, restore would overwrite
+ mysql -e "INSERT INTO openslx.property (name, value) VALUES ('webif-version', '${TARGET_WEBIF_VERSION}')
+ ON DUPLICATE KEY UPDATE value = VALUES(value)" || pwarning "Could not update version number in DB"
+ # config.tgz symlink -> db entry
+ if [ -L /srv/openslx/www/boot/default/config.tgz ]; then
+ CONFTGZ=$(readlink /srv/openslx/www/boot/default/config.tgz | sed "s/'/\\\'/g")
+ echo "config.tgz links to '$CONFTGZ'"
+ mysql -e "INSERT IGNORE INTO openslx.configtgz_location (locationid, configid) SELECT 0, configid FROM openslx.configtgz WHERE filepath = '$CONFTGZ' LIMIT 1" \
+ || pwarning "Could not convert default config.tgz setting - do so manually"
+ rm -f -- /srv/openslx/www/boot/default/config.tgz
+ fi
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
@@ -229,22 +259,6 @@ if [ -n "$TGZ_DOZMOD" ]; then
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" "$PATH_TASKMANAGER/taskmanager.sh"
- tar -x -C "$PATH_TASKMANAGER" -f "$TMPDIR/$TGZ_TASKMANAGER"
- fixperms "$PATH_TASKMANAGER" root:root
- chmod -R a+x "$PATH_TASKMANAGER/scripts"
- 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"
@@ -308,6 +322,19 @@ if [ -n "$TGZ_LDADP" ]; then
echo "LDADP upgrade complete"
fi
+# ************************ sudo config *********************
+if [ -n "$FILEDIR/tm-sudo-config" ]; then
+ cp -f "$FILEDIR/tm-sudo-config" "/etc/sudoers.d/taskmanager" || pwarning "Could not update sudo conf for taskmanager"
+ chmod 0440 "/etc/sudoers.d/taskmanager"
+fi
+
+for i in 1 1 1 1 2 2 3 4 END; do
+ CB=$(sudo -u www-data -n php /srv/openslx/www/slx-admin/api.php cb)
+ [ "x$CB" != "xTrue" ] && break
+ [ "$i" = "END" ] && break
+ sleep $i
+done
+
echo ""
echo "Update complete. It is recommended to reboot the server."
echo ""