diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-07-09 14:49:01 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-07-09 14:49:01 +0300 |
| commit | b062211887bda338f14cb663c2b3392a52d0df88 (patch) | |
| tree | 3dd9c3ae32b312c10854c05598a17313e3d6efd6 /templates/usr_local_etc_rc.d_do_dyndns.j2 | |
| parent | 64f0adc8bb8d758c07fdd89b937466b1ab5ab43e (diff) | |
Add digitalocean dyndns rc script
Diffstat (limited to 'templates/usr_local_etc_rc.d_do_dyndns.j2')
| -rw-r--r-- | templates/usr_local_etc_rc.d_do_dyndns.j2 | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/templates/usr_local_etc_rc.d_do_dyndns.j2 b/templates/usr_local_etc_rc.d_do_dyndns.j2 new file mode 100644 index 0000000..0198f9d --- /dev/null +++ b/templates/usr_local_etc_rc.d_do_dyndns.j2 @@ -0,0 +1,53 @@ +#!/bin/sh +# +# PROVIDE: do_dyndns +# REQUIRE: NETWORKING +# KEYWORD: shutdown + +. /etc/rc.subr + +name="do_dyndns" +rcvar=do_dyndns_enable + +extra_commands="status" +rcvars="do_dyndns_enable do_dyndns_domain do_dyndns_hostname do_dyndns_if4 do_dyndns_interval do_dyndns_auth_file" +stop_cmd="do_dyndns_stop" + +load_rc_config $name + +: "${do_dyndns_enable:=NO}" +: "${do_dyndns_interval:=5m}" +: "${do_dyndns_hostname:=@}" +: "${do_dyndns_auth_file:=/usr/local/etc/do_dyndns_auth}" + +pidfile="/var/run/${name}.pid" +logfile="/var/log/${name}" + +command="/usr/sbin/daemon" +command_args="-cfr -P ${pidfile} -o ${logfile} /bin/sh -c ' + export PATH=\"/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin\" + export DO_DYNDNS_DOMAIN=\"${do_dyndns_domain}\" + export DO_DYNDNS_HOSTNAME=\"${do_dyndns_hostname}\" + export DO_DYNDNS_IF4=\"${do_dyndns_if4}\" + export DO_DYNDNS_INTERVAL=\"${do_dyndns_interval}\" + export DO_DYNDNS_AUTH_FILE=\"${do_dyndns_auth_file}\" + + exec /usr/local/bin/do_dyndns.sh +'" + +do_dyndns_stop() { + echo "Stopping ${name} with SIGINT..." + if [ -f "${pidfile}" ]; then + kill -INT "$(cat "${pidfile}")" + sleep 5 + if kill -0 "$(cat "${pidfile}")" 2>/dev/null; then + echo "Process didn't exit, sending SIGKILL..." + kill -KILL "$(cat "${pidfile}")" + fi + rm -f "${pidfile}" + else + echo "${name}: no pidfile found" + fi +} + +run_rc_command "$1" |
