summaryrefslogtreecommitdiffstats
path: root/net/ddns-scripts/files/etc/hotplug.d/iface/ddns
blob: dd58f9180cf01fe2bb0874137193c72e22aa962b (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
#!/bin/sh

. /lib/functions.sh

start_ddns_service() {
	local cfg="$1"
	local interface_event="$2"
	local action="$3"

	local interface

	config_get interface $cfg interface
	[ -z "$interface" ] && return

	[ "$interface" != "$interface_event" ] && return

	case "$action" in
	ifup)
		/etc/init.d/ddns start "$cfg"
		;;
	ifdown)
		/etc/init.d/ddns stop "$cfg"
		;;
	esac
}

ddns_service() {
	local action="$1"
	local interface="$2"

	config_load ddns
	config_foreach start_ddns_service "service" "$interface" "$action"
}

case "$ACTION" in
	ifup)
		/etc/init.d/ddns enabled && ddns_service "ifup" "$INTERFACE"
		;;
	ifdown)
		ddns_service "ifdown" "$INTERFACE"
		;;
esac