From 203ab6573b054cf81318d724fe12182d14c66313 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Thu, 17 Oct 2024 14:27:10 +0200 Subject: [PATCH] add new podman-user-wait-network-online.service This service is meant to be used by quadlet as replacement for network-online.target as this does not work for rootless users. see #22197 Signed-off-by: Paul Holzinger --- .gitignore | 2 +- Makefile | 3 +++ .../user/podman-user-wait-network-online.service | 12 ++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 contrib/systemd/user/podman-user-wait-network-online.service diff --git a/.gitignore b/.gitignore index 1b596b2b44..9ad295735e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ /build/ /conmon/ contrib/spec/podman.spec -contrib/systemd/*/*.service +contrib/systemd/system/*.service *.coverprofile coverprofile /.coverage diff --git a/Makefile b/Makefile index d8b416291a..41582736ce 100644 --- a/Makefile +++ b/Makefile @@ -1000,6 +1000,9 @@ install.systemd: $(PODMAN_GENERATED_UNIT_FILES) install ${SELINUXOPT} -m 644 $$unit $(DESTDIR)${USERSYSTEMDDIR}/$$(basename $$unit); \ install ${SELINUXOPT} -m 644 $$unit $(DESTDIR)${SYSTEMDDIR}/$$(basename $$unit); \ done + # Important this unit should only be installed for the user session and is thus not added to the loop above. + install ${SELINUXOPT} -m 644 contrib/systemd/user/podman-user-wait-network-online.service \ + $(DESTDIR)${USERSYSTEMDDIR}/podman-user-wait-network-online.service rm -f $^ else install.systemd: diff --git a/contrib/systemd/user/podman-user-wait-network-online.service b/contrib/systemd/user/podman-user-wait-network-online.service new file mode 100644 index 0000000000..757948ac0d --- /dev/null +++ b/contrib/systemd/user/podman-user-wait-network-online.service @@ -0,0 +1,12 @@ +[Unit] +Description=Wait for system level network-online.target as user. +Documentation=https://github.com/containers/podman/issues/22197 +Documentation=man:podman-systemd.unit(5) + +[Service] +Type=oneshot +# Set a timeout as by default oneshot does not have one and in case network-online.target +# never comes online we do not want to block forever, 90s is the default systemd unit timeout. +TimeoutStartSec=90s +ExecStart=sh -c 'until systemctl is-active network-online.target; do sleep 0.5; done' +RemainAfterExit=yes