|
@@ -1,19 +1,38 @@
|
1
|
1
|
#!/bin/sh /etc/rc.common
|
2
|
|
-# Copyright (C) 2015 OpenWrt.org
|
3
|
2
|
|
4
|
3
|
START=99
|
5
|
|
-
|
6
|
4
|
USE_PROCD=1
|
|
5
|
+
|
7
|
6
|
PROG=/usr/bin/rtl_ais
|
8
|
7
|
|
9
|
|
-start_service() {
|
10
|
|
- enabled="$(uci_get rtl_ais @rtl_ais[0] enabled 0)"
|
11
|
|
- ppm="$(uci_get rtl_ais @rtl_ais[0] ppm 0)"
|
|
8
|
+validate_rtl_ais_section() {
|
|
9
|
+ uci_validate_section "rtl_ais" "rtl_ais" "$1" \
|
|
10
|
+ 'enabled:bool' \
|
|
11
|
+ 'ppm:range(-100,100):0'
|
|
12
|
+}
|
|
13
|
+
|
|
14
|
+load_rtl_ais() {
|
|
15
|
+ local cfg="$1"
|
|
16
|
+
|
|
17
|
+ local enabled ppm
|
|
18
|
+ validate_rtl_ais_section "$cfg" || { echo "validation failed"; return 1; }
|
12
|
19
|
|
13
|
|
- [ "$enabled" != "1" ] && return
|
|
20
|
+ [ "$enabled" = "1" ] || return 1
|
14
|
21
|
|
15
|
22
|
procd_open_instance
|
16
|
23
|
procd_set_param command "$PROG" -p "$ppm"
|
|
24
|
+ procd_set_param stdout 1
|
|
25
|
+ procd_set_param stderr 1
|
17
|
26
|
procd_set_param respawn
|
18
|
27
|
procd_close_instance
|
19
|
28
|
}
|
|
29
|
+
|
|
30
|
+start_service() {
|
|
31
|
+ config_load "rtl_ais"
|
|
32
|
+ config_foreach load_rtl_ais "rtl_ais"
|
|
33
|
+}
|
|
34
|
+
|
|
35
|
+service_triggers() {
|
|
36
|
+ procd_add_reload_trigger "rtl_ais"
|
|
37
|
+ procd_add_validation validate_rtl_ais_section
|
|
38
|
+}
|