blob: d56912a3b19ed19c53477baa202e17fb10a2095a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#!/bin/sh /etc/rc.common
START=90
NAME=rtpengine
COMMAND="/usr/bin/$NAME"
USE_PROCD=1
#PROCD_DEBUG=1
LOGGER="/usr/bin/logger -t $NAME"
LOG_ERR="$LOGGER -p user.err -s"
run_instance() {
procd_open_instance
procd_set_param command $COMMAND
procd_append_param command \
--config-file=/etc/$NAME/$NAME.conf \
--config-section="$2" \
$3 \
-f
# forward all output to logd
procd_set_param stderr 1
procd_set_param stdout 1
procd_set_param pidfile "/var/run/$NAME-$1.pid"
procd_set_param user $NAME
procd_close_instance
$LOGGER instance "$1" has started
}
handle_instance() {
config_get opts "$1" opts
config_get section "$1" section
run_instance "$1" "$section" "$opts"
}
start_service() {
config_load $NAME
config_get_bool enabled global enabled 0
rtp_spool_dir=/var/spool/rtpengine
if [ "$enabled" -eq 1 ]; then
if ! [ -e "$rtp_spool_dir" ]; then
mkdir -m 0750 -p "$rtp_spool_dir"
[ -d "$rtp_spool_dir" ] && \
chown $NAME:$NAME "$rtp_spool_dir"
fi
config_foreach handle_instance instance
else
$LOG_ERR service not enabled
$LOG_ERR edit /etc/config/$NAME
fi
}
|