From ef0b0c489c86461adcd3b8f25681343cbfb022bd Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Tue, 21 Sep 2021 14:03:45 +0200 Subject: [PATCH] add systemd services --- systemd/vpnclient-wg-restart.service | 12 ++++++++++++ systemd/vpnclient-wg-restart.timer | 12 ++++++++++++ systemd/vpnclient-wg.service | 17 +++++++++++++++++ .../wireguard-mount.service | 0 4 files changed, 41 insertions(+) create mode 100644 systemd/vpnclient-wg-restart.service create mode 100644 systemd/vpnclient-wg-restart.timer create mode 100644 systemd/vpnclient-wg.service rename wireguard-mount.service => systemd/wireguard-mount.service (100%) diff --git a/systemd/vpnclient-wg-restart.service b/systemd/vpnclient-wg-restart.service new file mode 100644 index 0000000..2eb1ccf --- /dev/null +++ b/systemd/vpnclient-wg-restart.service @@ -0,0 +1,12 @@ +[Unit] +Description=Wireguard Restart +After=network-online.target vpnclient-mount.service +Requires=network-online.target +Requisite=vpnclient-mount.service + +[Service] +User=root +Group=root +Type=oneshot +ExecStart=/snacks/wireguard/scripts/rotate.py +NetworkNamespacePath=/run/vpn/net diff --git a/systemd/vpnclient-wg-restart.timer b/systemd/vpnclient-wg-restart.timer new file mode 100644 index 0000000..3a8b3f1 --- /dev/null +++ b/systemd/vpnclient-wg-restart.timer @@ -0,0 +1,12 @@ +[Unit] +Description=Reconnect to WireGuard if down + +[Timer] +OnBootSec=5m +OnUnitActiveSec=1m +Persistent=False +Unit=vpnclient-wg-restart.service + +[Install] +WantedBy=timers.target + diff --git a/systemd/vpnclient-wg.service b/systemd/vpnclient-wg.service new file mode 100644 index 0000000..ec721ec --- /dev/null +++ b/systemd/vpnclient-wg.service @@ -0,0 +1,17 @@ +[Unit] +Description=Wireguard +After=network-online.target vpnclient-mount.service +Requires=network-online.target +Requisite=vpnclient-mount.service + +[Service] +User=root +Group=root +Type=oneshot +EnvironmentFile=/snacks/wireguard/env +ExecStart=/snacks/wireguard/scripts/connect.py +NetworkNamespacePath=/run/vpn/net +RemainAfterExit=true + +[Install] +WantedBy=multi-user.target diff --git a/wireguard-mount.service b/systemd/wireguard-mount.service similarity index 100% rename from wireguard-mount.service rename to systemd/wireguard-mount.service