Browse Source

rtl-ais: add procd validation

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
Nuno Goncalves 9 years ago
parent
commit
0b06f1f51c
2 changed files with 26 additions and 7 deletions
  1. 1
    1
      utils/rtl-ais/Makefile
  2. 25
    6
      utils/rtl-ais/files/rtl_ais.init

+ 1
- 1
utils/rtl-ais/Makefile View File

@@ -7,7 +7,7 @@
7 7
 include $(TOPDIR)/rules.mk
8 8
 
9 9
 PKG_NAME:=rtl-ais
10
-PKG_VERSION:=20150722
10
+PKG_VERSION:=20151213
11 11
 
12 12
 PKG_RELEASE=$(PKG_SOURCE_VERSION)
13 13
 

+ 25
- 6
utils/rtl-ais/files/rtl_ais.init View File

@@ -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
+}