summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2020-12-21 16:20:22 +0100
committerSimon Rettberg2020-12-21 16:20:22 +0100
commit075da80fd61a68b4128ee307b78a60ea5351e79a (patch)
treed535672749bedd65a2237dae868b0f6c497e06de
parent[SSPS] Add journal config for persistent logging (diff)
downloadsetup-scripts-075da80fd61a68b4128ee307b78a60ea5351e79a.tar.gz
setup-scripts-075da80fd61a68b4128ee307b78a60ea5351e79a.tar.xz
setup-scripts-075da80fd61a68b4128ee307b78a60ea5351e79a.zip
[SSPS] Improve network wait online stuff
-rw-r--r--satellit_installer/static_files/slxadmin/etc/systemd/system/slxadmin-boot.service2
-rwxr-xr-xsatellit_installer/static_files/slxadmin/opt/openslx/slxadmin-bootscript2
-rwxr-xr-xsatellit_installer/static_files/system/usr/local/sbin/slx-wait-online15
-rw-r--r--satellit_installer/static_files/timesync/etc/systemd/system/redneck-timesync.service2
-rwxr-xr-xsatellit_installer/static_files/timesync/usr/local/sbin/redneck-timesync.sh4
5 files changed, 21 insertions, 4 deletions
diff --git a/satellit_installer/static_files/slxadmin/etc/systemd/system/slxadmin-boot.service b/satellit_installer/static_files/slxadmin/etc/systemd/system/slxadmin-boot.service
index 21bdf51..3322028 100644
--- a/satellit_installer/static_files/slxadmin/etc/systemd/system/slxadmin-boot.service
+++ b/satellit_installer/static_files/slxadmin/etc/systemd/system/slxadmin-boot.service
@@ -2,7 +2,7 @@
Description=Trigger init hooks of slx-admin
RefuseManualStart=yes
Before=lighttpd.service
-After=mariadb.service mysql.service network.target taskmanager.service
+After=mariadb.service network-online.target taskmanager.service
Wants=network-online.target
[Service]
diff --git a/satellit_installer/static_files/slxadmin/opt/openslx/slxadmin-bootscript b/satellit_installer/static_files/slxadmin/opt/openslx/slxadmin-bootscript
index a959dfd..55afbe8 100755
--- a/satellit_installer/static_files/slxadmin/opt/openslx/slxadmin-bootscript
+++ b/satellit_installer/static_files/slxadmin/opt/openslx/slxadmin-bootscript
@@ -1,5 +1,7 @@
#!/bin/sh
+/usr/local/sbin/slx-wait-online
+
FILE=$(mktemp)
if ! php /srv/openslx/www/slx-admin/api.php init > "$FILE" 2>&1; then
diff --git a/satellit_installer/static_files/system/usr/local/sbin/slx-wait-online b/satellit_installer/static_files/system/usr/local/sbin/slx-wait-online
new file mode 100755
index 0000000..f4b41dc
--- /dev/null
+++ b/satellit_installer/static_files/system/usr/local/sbin/slx-wait-online
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+for i in 1 1 2 2 3 1; do
+ < <(ip route show default) read -r _ _ ip _
+ if [ -n "$ip" ]; then
+ echo "Trying to ping $ip"
+ ping -W 2 -c 1 "$ip" &> /dev/null && exit 0
+ else
+ echo "No default gateway yet..."
+ fi
+ sleep "$i"
+done
+
+exit 1
+
diff --git a/satellit_installer/static_files/timesync/etc/systemd/system/redneck-timesync.service b/satellit_installer/static_files/timesync/etc/systemd/system/redneck-timesync.service
index a555704..e019a92 100644
--- a/satellit_installer/static_files/timesync/etc/systemd/system/redneck-timesync.service
+++ b/satellit_installer/static_files/timesync/etc/systemd/system/redneck-timesync.service
@@ -6,8 +6,6 @@ After=network.target network-online.target
[Service]
Type=oneshot
RemainAfterExit=no
-# For awesome reasons, depending on network-online.target doesn't seem enough
-ExecStartPre=-/bin/sleep 10
ExecStart=/usr/local/sbin/redneck-timesync.sh -s
[Install]
diff --git a/satellit_installer/static_files/timesync/usr/local/sbin/redneck-timesync.sh b/satellit_installer/static_files/timesync/usr/local/sbin/redneck-timesync.sh
index 5fc8794..30ebaad 100755
--- a/satellit_installer/static_files/timesync/usr/local/sbin/redneck-timesync.sh
+++ b/satellit_installer/static_files/timesync/usr/local/sbin/redneck-timesync.sh
@@ -31,10 +31,12 @@ URLS="
"
F=$(mktemp)
-[ -z "$F" ] && F=/tmp/timesync-boot
+[ -z "$F" ] && F="/tmp/timesync-boot.$$"
NOW=$(date +%s)
ECODE=0
+/usr/local/sbin/slx-wait-online
+
# Request all at once, HEAD only, 2 sec timeout
for url in $URLS; do
curl -s -m 2 -I "$url" &