aboutsummaryrefslogtreecommitdiffstats
path: root/templates/usr_local_etc_rc.d_hetzner_ddns.j2
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2025-10-06 00:06:54 +0300
committerJan Tuomi <jan@jantuomi.fi>2025-10-06 00:06:54 +0300
commitae9be6373428471dd4c95f64741b990638c272c0 (patch)
tree66211764ac0d8c5484e119b7b3f23ad56ebc5ea4 /templates/usr_local_etc_rc.d_hetzner_ddns.j2
parentffe2c8d0accb5c33c98408dfb1039d7387ddffd1 (diff)
Work on networking
Diffstat (limited to 'templates/usr_local_etc_rc.d_hetzner_ddns.j2')
-rw-r--r--templates/usr_local_etc_rc.d_hetzner_ddns.j248
1 files changed, 48 insertions, 0 deletions
diff --git a/templates/usr_local_etc_rc.d_hetzner_ddns.j2 b/templates/usr_local_etc_rc.d_hetzner_ddns.j2
new file mode 100644
index 0000000..ccbbb8c
--- /dev/null
+++ b/templates/usr_local_etc_rc.d_hetzner_ddns.j2
@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+# PROVIDE: hetzner_ddns
+# REQUIRE: NETWORKING
+# KEYWORD: shutdown
+
+# Enable via:
+# hetzner_ddns_enable="YES"
+#
+# (pfSense: System -> Advanced -> System Tunables or /etc/rc.conf)
+
+. /etc/rc.subr
+
+name="hetzner_ddns"
+rcvar=hetzner_ddns_enable
+
+load_rc_config $name
+
+: ${hetzner_ddns_enable:="NO"}
+: ${hetzner_ddns_user:="root"}
+: ${hetzner_ddns_command:="/usr/local/bin/hetzner-ddns.sh"}
+
+start_cmd="${name}_start"
+stop_cmd="${name}_stop"
+status_cmd="${name}_status"
+
+hetzner_ddns_start() {
+ echo "Starting ${name}..."
+ /usr/sbin/daemon -t "${name}" -u "${hetzner_ddns_user}" ${hetzner_ddns_command}
+}
+
+hetzner_ddns_stop() {
+ echo "Stopping ${name}..."
+ # First try by daemon title, then by command as fallback
+ pkill -f "^daemon: ${name}$" || pkill -f "${hetzner_ddns_command}"
+}
+
+hetzner_ddns_status() {
+ if pgrep -f "^daemon: ${name}$" >/dev/null 2>&1 || pgrep -f "${hetzner_ddns_command}" >/dev/null 2>&1; then
+ echo "${name} is running"
+ return 0
+ else
+ echo "${name} is not running"
+ return 1
+ fi
+}
+
+run_rc_command "$1"