summaryrefslogtreecommitdiffhomepage
path: root/libs/uci/root/sbin/luci-reload
blob: 24cf76064bd568d63526dc8a5bbdbe30d2a19e6f (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
#!/bin/sh
. /etc/functions.sh

apply_config() {
	config_get init "$1" init
	config_get exec "$1" exec
	config_get test "$1" test

	echo "$2" > "/var/run/luci-reload-status"

	[ -n "$init" ] && reload_init "$2" "$init" "$test"
	[ -n "$exec" ] && reload_exec "$2" "$exec" "$test"
}

reload_exec() {
	[ -x $2 ] && {
		echo "Reloading $1... "
		$2 >/dev/null 2>&1
		[ -n "$3" -a "$?" != "$3" ] && echo '!!! Failed to reload' $1 '!!!'
	}
}

reload_init() {
	[ -x /etc/init.d/$2 ] && /etc/init.d/$2 enabled && {
		echo "Reloading $1... "
		/etc/init.d/$2 reload >/dev/null 2>&1
		[ -n "$3" -a "$?" != "$3" ] && echo '!!! Failed to reload' $1 '!!!'
	}
}

lock "/var/run/luci-reload"

config_load ucitrack

for i in $*; do
	config_foreach apply_config $i $i
done

rm -f "/var/run/luci-reload-status"
lock -u "/var/run/luci-reload"