From 075da80fd61a68b4128ee307b78a60ea5351e79a Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 21 Dec 2020 16:20:22 +0100 Subject: [SSPS] Improve network wait online stuff --- .../slxadmin/etc/systemd/system/slxadmin-boot.service | 2 +- .../static_files/slxadmin/opt/openslx/slxadmin-bootscript | 2 ++ .../static_files/system/usr/local/sbin/slx-wait-online | 15 +++++++++++++++ .../timesync/etc/systemd/system/redneck-timesync.service | 2 -- .../timesync/usr/local/sbin/redneck-timesync.sh | 4 +++- 5 files changed, 21 insertions(+), 4 deletions(-) create mode 100755 satellit_installer/static_files/system/usr/local/sbin/slx-wait-online 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" & -- cgit v1.2.3-55-g7522