p910nd.init (953B)
1 #!/bin/sh /etc/rc.common 2 # Copyright (C) 2007 OpenWrt.org 3 START=50 4 USE_PROCD=1 5 6 append_bool() { 7 local section="$1" 8 local option="$2" 9 local value="$3" 10 local _val 11 config_get_bool _val "$section" "$option" '0' 12 [ "$_val" -gt 0 ] && append args "$3" 13 } 14 15 append_string() { 16 local section="$1" 17 local option="$2" 18 local value="$3" 19 local _val 20 config_get _val "$section" "$option" 21 [ -n "$_val" ] && append args "$3$_val" 22 } 23 24 start_service() { 25 config_load "p910nd" 26 config_foreach start_p910nd p910nd 27 } 28 29 30 start_p910nd() { 31 local section="$1" 32 config_get_bool "enabled" "$section" "enabled" '1' 33 if [ "$enabled" -gt 0 ]; then 34 args="-d " 35 config_get port "$section" port 36 name=p910${port}d 37 append_bool "$section" bidirectional "-b" 38 append_string "$section" device "-f " 39 append_string "$section" bind "-i " 40 append_string "$section" port "" 41 procd_open_instance $name 42 procd_set_param command /usr/sbin/p910nd $args 43 procd_close_instance 44 fi 45 }