Browse Source

rtl-ais: add procd validation

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
lilik-openwrt-22.03
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 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=rtl-ais
PKG_VERSION:=20150722
PKG_VERSION:=20151213
PKG_RELEASE=$(PKG_SOURCE_VERSION)


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

@ -1,19 +1,38 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2015 OpenWrt.org
START=99
USE_PROCD=1
PROG=/usr/bin/rtl_ais
start_service() {
enabled="$(uci_get rtl_ais @rtl_ais[0] enabled 0)"
ppm="$(uci_get rtl_ais @rtl_ais[0] ppm 0)"
validate_rtl_ais_section() {
uci_validate_section "rtl_ais" "rtl_ais" "$1" \
'enabled:bool' \
'ppm:range(-100,100):0'
}
load_rtl_ais() {
local cfg="$1"
local enabled ppm
validate_rtl_ais_section "$cfg" || { echo "validation failed"; return 1; }
[ "$enabled" != "1" ] && return
[ "$enabled" = "1" ] || return 1
procd_open_instance
procd_set_param command "$PROG" -p "$ppm"
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param respawn
procd_close_instance
}
start_service() {
config_load "rtl_ais"
config_foreach load_rtl_ais "rtl_ais"
}
service_triggers() {
procd_add_reload_trigger "rtl_ais"
procd_add_validation validate_rtl_ais_section
}

Loading…
Cancel
Save