From daf7f8a8e031d23230b6dbee4f785cd39a27cfd2 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 30 Jun 2023 07:59:07 +0200 Subject: [PATCH] Add wait-network-online.service Add a service which waits (max 15 seconds) for the network to be available. We define 'available' as the ability to ping our default router by its name, which implies dns is working. Service units, which really need network to start, should add After=network-online.target Wants=network-online.target --- install.sh | 2 ++ misc_systemd_units/wait-network-online.service | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 misc_systemd_units/wait-network-online.service diff --git a/install.sh b/install.sh index 7e68250..e529f2a 100755 --- a/install.sh +++ b/install.sh @@ -264,6 +264,8 @@ install_symlink /etc/local/access.conf "$DESTDIR$sysconfdir/s install_data misc_etc_files/cups/client.conf "$DESTDIR$sysconfdir/cups/client.conf" install_data misc_systemd_units/ip6.service "$DESTDIR$systemdunitdir/ip6.service" install_data mxrouter/mxrouter.service "$DESTDIR$systemdunitdir/mxrouter.service" +install_data misc_systemd_units/wait-network-online.service \ + "$DESTDIR$systemdunitdir/wait-network-online.service" postinstall exit diff --git a/misc_systemd_units/wait-network-online.service b/misc_systemd_units/wait-network-online.service new file mode 100644 index 0000000..425e7a2 --- /dev/null +++ b/misc_systemd_units/wait-network-online.service @@ -0,0 +1,14 @@ +[Unit] +DefaultDependencies=no +After=sysinit.target network.target +Before=network-online.target + +[Service] +Type=oneshot +RemainAfterExit=true +TimeoutStartSec=15 +StandardOutput=null +ExecStart=bash -c 'while ! ping -c 1 -w 1 rick.molgen.mpg.de; do sleep 1 ; done' + +[Install] +WantedBy=network-online.target