IPSec systemd units
authorMathieu <mbaudier@argeo.org>
Mon, 6 Mar 2023 08:29:40 +0000 (09:29 +0100)
committerMathieu <mbaudier@argeo.org>
Mon, 6 Mar 2023 08:29:40 +0000 (09:29 +0100)
usr/lib/systemd/system/freed-ipsec-roaming@.service [new file with mode: 0644]
usr/lib/systemd/system/freed-onresume.service [new file with mode: 0644]
usr/lib/systemd/system/freed-onsuspend.service [new file with mode: 0644]

diff --git a/usr/lib/systemd/system/freed-ipsec-roaming@.service b/usr/lib/systemd/system/freed-ipsec-roaming@.service
new file mode 100644 (file)
index 0000000..374004b
--- /dev/null
@@ -0,0 +1,27 @@
+[Unit]
+Description=Roaming IPSec to '%i'
+After=network-online.target
+Wants=network-online.target
+
+After=unbound.service
+Requires=unbound.service
+
+After=ipsec.service
+PartOf=ipsec.service
+Requires=ipsec.service
+
+StartLimitIntervalSec=60
+StartLimitBurst=20
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=ipsec auto --start %i
+ExecStop=ipsec auto --delete %i
+
+Restart=on-failure
+RestartSec=3
+
+[Install]
+WantedBy=multi-user.target
+RequiredBy=ipsec.service
diff --git a/usr/lib/systemd/system/freed-onresume.service b/usr/lib/systemd/system/freed-onresume.service
new file mode 100644 (file)
index 0000000..7b7dc54
--- /dev/null
@@ -0,0 +1,14 @@
+[Unit]
+Description=On resume actions
+After=sleep.target
+After=network-online.target
+Wants=network-online.target
+
+[Service]
+Type=oneshot
+ExecStartPre=sleep 3
+ExecStart=/usr/bin/systemctl restart ipsec
+
+[Install]
+WantedBy=sleep.target
+
diff --git a/usr/lib/systemd/system/freed-onsuspend.service b/usr/lib/systemd/system/freed-onsuspend.service
new file mode 100644 (file)
index 0000000..47afcc2
--- /dev/null
@@ -0,0 +1,11 @@
+[Unit]
+Description=On suspend actions
+Before=sleep.target
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/systemctl stop ipsec
+ExecStartPost=/usr/bin/sleep 5
+
+[Install]
+WantedBy=sleep.target