blob: 18ed3a47fea4d6cc10e2cbb9f5d879a411a1a5b0 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001#!/bin/sh /etc/rc.common
2
3USE_PROCD=1
4
5START=95
6STOP=01
7
8CONFIGURATION=netstinky
9
10validate_ids_section()
11{
12 uci_load_validate netstinky netstinky "$1" "$2" \
13 'interface:string:lan' \
14 'port:uinteger:8089' \
15 'updatehost:string' \
16 'updateport:uinteger' \
17 'sslnoverify:bool:false'
18}
19
20netstinky_instance()
21{
22 [ "$2" = 0 ] || {
23 echo "validation failed"
24 return 1
25 }
26
27 procd_open_instance
28 procd_set_param command /usr/bin/nsids
29
30 if [ -n "${interface}" ]; then
31 local iface
32 network_get_device iface "${interface}"
33 procd_append_param command -i "${iface}"
34 fi
35 procd_append_param command -p "${port}"
36 [ -n "${updatehost}" ] && procd_append_param command --update-host "${updatehost}"
37 [ -n "${updateport}" ] && procd_append_param command --update-port "${updateport}"
38 [ "${sslnoverify}" -eq 1 ] && procd_append_param command --ssl-no-verify
39
40 procd_set_param stderr 1
41 procd_set_param stdout 1
42
43 procd_add_mdns "netstinky" "tcp" "$port"
44
45 procd_close_instance
46}
47
48start_service()
49{
50 . /lib/functions/network.sh
51
52 config_load "${CONFIGURATION}"
53 config_foreach validate_ids_section netstinky netstinky_instance
54}
55
56service_triggers()
57{
58 procd_add_config_trigger "config.change" "netstinky" /etc/init.d/nsids reload
59
60 config_load "${CONFIGURATION}"
61
62 procd_add_validation validate_ids_section
63}
64