wg-installer: install cronjob
authorNick Hainke <vincent@systemli.org>
Thu, 20 Jan 2022 08:06:24 +0000 (09:06 +0100)
committerNick Hainke <vincent@systemli.org>
Thu, 20 Jan 2022 08:51:05 +0000 (09:51 +0100)
Install a cronjob that removes unused wireguard interfaces every 10
minutes.

Signed-off-by: Nick Hainke <vincent@systemli.org>
net/wg-installer/Makefile
net/wg-installer/wg-server/config/wgserver.init [new file with mode: 0644]

index 55e654d651c564738cfa5a0e41c47e4d57996095..1d81271053fab43a08d63606fa78de40643ef305 100644 (file)
@@ -39,6 +39,9 @@ define Package/wg-installer-server/install
 
        $(INSTALL_DIR) $(1)/etc/config
        $(INSTALL_CONF) ./wg-server/config/wgserver.conf $(1)/etc/config/wgserver
+
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./wg-server/config/wgserver.init $(1)/etc/init.d/wgserver
 endef
 
 define Package/wg-installer-server/conffiles
diff --git a/net/wg-installer/wg-server/config/wgserver.init b/net/wg-installer/wg-server/config/wgserver.init
new file mode 100644 (file)
index 0000000..308ba4c
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh /etc/rc.common
+
+START=99
+
+# install cleanup script that executes every 10 min
+boot() {
+    test -f /etc/crontabs/root || touch /etc/crontabs/root
+    grep -q '/usr/share/wginstaller/wg.sh cleanup_wginterfaces' /etc/crontabs/root || {
+        echo "*/10 * * * *     /usr/share/wginstaller/wg.sh cleanup_wginterfaces" >> /etc/crontabs/root
+    }
+    /etc/init.d/cron restart
+}