0
0
mirror of https://github.com/openwrt/packages.git synced 2025-02-07 09:19:51 +00:00
packages/utils/rtl-ais/files/rtl_ais.init
Jeffery To da2974620e rtl-ais: Update init script
This replaces the use of uci_validate_section() with
uci_load_validate(), which removes the need to declare local variables
for every config option.

This also fixes some space-indented lines to use tabs.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2019-02-12 18:03:20 +00:00

38 lines
706 B
Bash

#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
PROG=/usr/bin/rtl_ais
validate_rtl_ais_section() {
uci_load_validate "rtl_ais" "rtl_ais" "$1" "$2" \
'enabled:bool' \
'ppm:range(-100,100):0'
}
load_rtl_ais() {
local cfg="$1"
[ "$2" = 0 ] || { echo "validation failed"; return 1; }
[ "$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 validate_rtl_ais_section "rtl_ais" load_rtl_ais
}
service_triggers() {
procd_add_reload_trigger "rtl_ais"
procd_add_validation validate_rtl_ais_section
}