summaryrefslogtreecommitdiffstats
path: root/satellit_upgrader/updater.template.sh
diff options
context:
space:
mode:
authorSimon Rettberg2017-05-12 22:57:12 +0200
committerSimon Rettberg2017-05-12 22:57:12 +0200
commit248192b6dabc9a0f6208a08e92f4b14a9115a5b3 (patch)
tree973920a1189daf7dc97eb7c059a97a687a1fbaa0 /satellit_upgrader/updater.template.sh
parent[SSPS] lighttpd-ssl: Only generate dhparam if not already running (diff)
downloadsetup-scripts-248192b6dabc9a0f6208a08e92f4b14a9115a5b3.tar.gz
setup-scripts-248192b6dabc9a0f6208a08e92f4b14a9115a5b3.tar.xz
setup-scripts-248192b6dabc9a0f6208a08e92f4b14a9115a5b3.zip
[SSUS] Tweak execution order; install updated slxadmin cron files
Diffstat (limited to 'satellit_upgrader/updater.template.sh')
-rw-r--r--satellit_upgrader/updater.template.sh53
1 files changed, 45 insertions, 8 deletions
diff --git a/satellit_upgrader/updater.template.sh b/satellit_upgrader/updater.template.sh
index d52637c..e70a5fc 100644
--- a/satellit_upgrader/updater.template.sh
+++ b/satellit_upgrader/updater.template.sh
@@ -116,6 +116,15 @@ if [ -n "$TGZ_SLXADMIN" ]; then
fi
fi
+# **** Start generating dhparam early as it takes a long time **********************
+declare -rg DHPARAM="/etc/lighttpd/dhparam.pem"
+DH_PID=
+if ! [ -s "$DHPARAM" ]; then
+ openssl dhparam -out "$DHPARAM" 2048 >/dev/null 2>&1 &
+ DH_PID=$!
+fi
+
+
# **************** Fix tmpdelete cronjob *******************
if [ -f "/etc/cron.daily/tmpdelete.sh" ]; then
[ -f "/etc/cron.daily/tmpdelete" ] || mv "/etc/cron.daily/tmpdelete.sh" "/etc/cron.daily/tmpdelete"
@@ -204,6 +213,14 @@ if [ -n "$TGZ_SLXADMIN" ]; then
grep -q 'CONFIG_FOOTER' "${PATH_SLXADMIN}/config.php" || echo "define('CONFIG_FOOTER', '${FOOTER}');" >> "${PATH_SLXADMIN}/config.php"
echo "$TARGET_WEBIF_VERSION" > "${PATH_SLXADMIN}/version"
fi
+ # New cronscript supplied
+ if [ -s "$FILEDIR/slxadmin-cronscript" ]; then
+ cp "$FILEDIR/slxadmin-cronscript" "/opt/openslx/slxadmin-cronscript"
+ fi
+ # New crontab supplied
+ if [ -s "$FILEDIR/slxadmin-crontab" ]; then
+ cp "$FILEDIR/slxadmin-crontab" "/etc/cron.d/slx-admin"
+ fi
# Enable modules
(
mkdir -p "$PATH_SLXADMIN/modules"
@@ -243,13 +260,13 @@ if [ -n "$TGZ_SLXADMIN" ]; then
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"
mkdir -p "${PATH_SLXADMINCACHE}"
fixperms "${PATH_SLXADMINCACHE}" www-data:www-data
rm -f -- "/srv/openslx/www/slx-admin/modules-available/baseconfig_bwidm/baseconfig/settings.json"
ln -s "${PATH_SLXADMINCACHE}/baseconfig-bwidm_settings.json" /srv/openslx/www/slx-admin/modules-available/baseconfig_bwidm/baseconfig/settings.json || \
pwarning "Could not set link ${PATH_SLXADMINCACHE}/baseconfig-bwidm_settings.json to /srv/openslx/www/slx-admin/modules-available/baseconfig_bwidm/baseconfig/settings.json - do so manually if you need bwIDM login on client computers"
+ echo "Web interface upgrade complete"
fi
# ************************* Dozmod *************************
@@ -346,13 +363,6 @@ if ! grep -q 'upload_max_filesize = 100M' "$PHPINIFILE"; then
RESTART_LIGHTY=ja
fi
-# ************************** LIGHTY ************************
-
-if [ -n "$RESTART_LIGHTY" ]; then
- echo "* Restarting lighttpd"
- restart_service lighttpd
-fi
-
# ********************** atftpd.service ********************
if [ -e "$FILEDIR/atftpd.service" ]; then
echo "* Replacing atftpd.service"
@@ -423,13 +433,23 @@ if ! which tmate > /dev/null 2>&1; then
fi
fi
+# ******************* make sure ssh keypair exists *********
+if ! [ -s /root/.ssh/id_rsa ]; then
+ echo "* Generating ssh keypair"
+ mkdir -p /root/.ssh
+ ssh-keygen -f /root/.ssh/id_rsa -N '' -C autogenerated &>/dev/null || pwarning "Could not create new ssh keypair in /root/.ssh/id_rsa"
+ echo "done"
+fi
+
# ************************ sudo config *********************
if [ -s "$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
+# Wait for webif callbacks and IPXE compile
echo -n "Finishing."
+sudo -u www-data -n php /srv/openslx/www/slx-admin/api.php rebootcontrol --action rebuild >/dev/null 2>&1
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
@@ -444,6 +464,23 @@ count=0
count=$(( count + 1 ))
[ "$count" -gt 5 ] && break
done
+
+# ************************** LIGHTY ************************
+if [ -n "$RESTART_LIGHTY" ]; then
+ count=0
+ if [ -n "$DH_PID" ] && kill -0 "$DH_PID" 2>/dev/null; then
+ echo -n ".waiting up to 5 minutes for dh param generation."
+ while kill -0 "$DH_PID" 2>/dev/null; do
+ echo -n "."
+ sleep 2
+ count=$(( count + 1 ))
+ [ "$count" -gt 150 ] && break
+ done
+ fi
+
+ echo -n ".restarting lighttpd."
+ restart_service lighttpd
+fi
echo ". done!"
echo ""