1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2014 CESNET, z.s.p.o
3 # Copyright (C) 2018 OpenWrt.org
8 COMMAND
="/usr/bin/$NAME"
14 LOGGER
="/usr/bin/logger -t $NAME"
15 LOG_ERR
="$LOGGER -p user.err -s"
19 procd_set_param
command $COMMAND
20 procd_append_param
command \
22 -p "/var/run/$NAME-$2.pid" \
24 # forward stderr to logd
25 procd_set_param stderr
1
28 $LOGGER instance
$2 has started
34 if [ "$1" = "ipaddr" ]; then
35 network_get_ipaddr tmp_addr
"$2" || tmp_addr
="$2"
37 network_get_ipaddr6 tmp_addr
"$2" || tmp_addr
="$2"
50 $LOG_ERR empty
$type entry
54 # Bail if more than 1 slash.
55 [ $
(echo "$value" |
awk -F "/" '{print NF-1}') -gt 1 ] && {
56 $LOG_ERR init
script does not understand
$type entry
\""$value"\"
60 IFS
="/" read one two
<< EOF
64 one
="$(check_ip "$type" "$one")"
65 if [ -n "$two" ]; then
66 two
="$(check_ip "$type" "$two")"
67 rtpproxy_options
=$rtpproxy_options" $param $one/$two"
69 rtpproxy_options
=$rtpproxy_options" $param $one"
76 local default_value
="$3"
78 if [ "$value" != "" ]; then
79 rtpproxy_options
=$rtpproxy_options" $param $value"
81 if [ "$default_value" != "" ]; then
82 rtpproxy_options
=$rtpproxy_options" $param $default_value"
87 check_special_param
() {
90 if [ "$param" != "" ]; then
91 rtpproxy_options
=$rtpproxy_options" $param"
97 local socket opts ipaddr ip6addr rtpproxy_options log_level
99 config_get socket
"$site" socket
100 config_get opts
"$site" opts
101 config_get ipaddr
"$site" ipaddr
102 config_get ip6addr
"$site" ip6addr
103 config_get user
"$site" user
104 config_get log_level
"$site" log_level
106 check_param
"-s" "$socket"
107 check_param
"-u" "$user" "nobody"
108 check_param
"-d" "$log_level" "DBUG"
110 check_special_param
"$opts"
112 [ -n "$ipaddr" ] && check_ipaddr
"$ipaddr" ipaddr
'-l'
113 [ -n "$ip6addr" ] && check_ipaddr
"$ip6addr" ip6addr
'-6'
115 run_instance
"$rtpproxy_options" "$site"
123 config_get_bool enabled global enabled
0
125 if [ "$enabled" -eq 1 ]; then
126 .
/lib
/functions
/network.sh
127 config_foreach handle_instance instance
129 $LOG_ERR service not enabled
130 $LOG_ERR edit
/etc
/config
/$NAME