1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2008 Alina Friedrichsen
3 # Copyright (C) 2011 OpenWrt.org
9 siproxd_bin
="/usr/sbin/siproxd"
10 siproxd_conf_dir
="/var/etc/siproxd"
11 siproxd_conf_prefix
="$siproxd_conf_dir/siproxd-"
12 siproxd_registration_dir
="/var/lib/siproxd"
13 siproxd_registration_prefix
="$siproxd_registration_dir/siproxd-"
14 siproxd_pid_dir
="/var/run/siproxd"
17 # Check if a UCI option is set, or else apply a provided default.
24 config_get
"$opt" "$sec" "$opt"
25 eval "val=\"\${$opt}\""
27 [ -z "$val" ] ||
return 0
28 [ -n "$default" ] ||
return 0
29 echo "$opt" = "$default" >> "$siproxd_conf_prefix$sec.conf"
32 # Use user-friendly network names (e.g. "wan", "lan") from options
33 # 'interface_inbound' and 'interface_outbound', but use standard siproxd
34 # parameters 'if_inbound' and 'if_outbound' if explicitly set.
43 config_get _int_inbound
"$sec" interface_inbound
44 config_get _int_outbound
"$sec" interface_outbound
46 network_get_physdev _dev_inbound
$_int_inbound
47 network_get_physdev _dev_outbound
$_int_outbound
49 default_conf if_inbound
$_dev_inbound
50 default_conf if_outbound
$_dev_outbound
53 # Apply default values to key options if unset in user's UCI config.
58 default_conf sip_listen_port
5060
59 default_conf daemonize
1
60 default_conf silence_log
1
61 default_conf user nobody
62 default_conf registration_file
"$siproxd_registration_prefix$sec.reg"
63 default_conf autosave_registrations
300
64 default_conf pid_file
"$siproxd_pid_dir/siproxd-$sec.pid"
65 default_conf rtp_proxy_enable
1
66 default_conf rtp_port_low
7070
67 default_conf rtp_port_high
7089
68 default_conf rtp_timeout
300
69 default_conf rtp_dscp
46
70 default_conf sip_dscp
0
71 default_conf rtp_input_dejitter
0
72 default_conf rtp_output_dejitter
0
73 default_conf tcp_timeout
600
74 default_conf tcp_connect_timeout
500
75 default_conf tcp_keepalive
20
76 default_conf default_expires
600
77 default_conf debug_level
0x00000000
78 default_conf debug_port
0
79 default_conf ua_string Siproxd-UA
80 default_conf use_rport
0
81 default_conf plugindir
"/usr/lib/siproxd/"
84 # Setup callbacks for parsing siproxd sections, options, and lists.
85 # This avoids hardcoding all supported siproxd configuration parameters.
95 # Initialize section processing and save section name.
98 if [ -f "$siproxd_conf_prefix$sec.conf" ]; then
99 rm "$siproxd_conf_prefix$sec.conf"
101 echo "# auto-generated config file from /etc/config/siproxd" > \
102 "$siproxd_conf_prefix$sec.conf"
104 # Parse OpenWRT interface names (e.g. "wan") and apply defaults,
105 # using saved section name.
110 setup_networks
"$sec"
111 apply_defaults
"$sec"
113 config_get chrootjail
"$sec" chrootjail
114 if [ -n "$chrootjail" ]; then
115 if [ ! -d "$chrootjail" ]; then
116 mkdir
-p "$chrootjail"
117 chmod 0755 "$chrootjail"
121 config_get pid_file
"$sec" pid_file
122 SERVICE_PID_FILE
="$pid_file" service_start \
123 $siproxd_bin --config "$siproxd_conf_prefix$sec.conf"
130 # These 2 OpenWRT-specific options are handled in post-processing.
132 "interface_inbound"|
"interface_outbound") return 0 ;;
134 # Other options match siproxd docs, so write directly to config.
135 [ -n "$2" ] && echo "$1" = "$2" >> "$siproxd_conf_prefix$sec.conf"
140 # All list items match siproxd docs, so write directly to config.
141 [ -n "$2" ] && echo "$1" = "$2" >> "$siproxd_conf_prefix$sec.conf"
149 config_get pid_file
"$sec" pid_file
"$siproxd_pid_dir/siproxd-$sec.pid"
151 SERVICE_PID_FILE
="$pid_file" \
152 service_stop
$siproxd_bin
156 mkdir
-p "$siproxd_conf_dir"
157 chmod 755 "$siproxd_conf_dir"
159 mkdir
-p "$siproxd_registration_dir"
160 chmod 700 "$siproxd_registration_dir"
161 chown nobody
:nogroup
"$siproxd_registration_dir"
163 mkdir
-p "$siproxd_pid_dir"
164 chmod 700 "$siproxd_pid_dir"
165 chown nobody
:nogroup
"$siproxd_pid_dir"
167 .
/lib
/functions
/network.sh
169 config_load
'siproxd'
173 config_load
'siproxd'
174 config_foreach stop_instance
'siproxd'