summaryrefslogtreecommitdiffstats
path: root/net/ddns-scripts/files/etc/init.d/ddns
blob: f138590b69e817de69defdfe75428e35ab0c42e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh /etc/rc.common

USE_PROCD=1
START=95
STOP=10

PROG=/usr/lib/ddns/dynamic_dns_updater.sh

start_ddns() {
	local cfg="$1"

	local enabled

	config_get_bool enabled $cfg enabled '0'
	[ "$enabled" = "0" ] && return

	procd_open_instance "$cfg"
	procd_set_param command $PROG
	procd_append_param command -S "$cfg"
	procd_set_param respawn
	procd_close_instance
}

start_ddns_service() {
	local cfg="$1"
	local section="$2"

	# start section if no section name is specified
	[ -z "$section" ] && {
		start_ddns "$cfg"
		return
	}

	# start 'exactly' this section if a section name is specified
	[ "$section" = "$cfg" ] && {
		start_ddns "$cfg"
		return
	}
}

start_service() {
	local section="$1"

	config_load ddns
	config_foreach start_ddns_service "service" "$section"
}

service_triggers()
{
	procd_add_reload_trigger ddns
}