/
opensips.init
93 lines (83 loc) · 1.82 KB
/
opensips.init
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
#
# Startup script for OpenSIPS
#
# chkconfig: - 85 15
# description: OpenSIPS is a fast SIP Server.
#
# processname: opensips
# pidfile: /var/run/opensips.pid
# config: /etc/opensips/opensips.cfg
#
### BEGIN INIT INFO
# Provides: opensips
# Required-Start: $local_fs $network $named
# Should-Start: mysqld postgresql
# Short-Description: start, stop OpenSIPS
# Description: OpenSIPS is a very fast and flexible SIP (RFC3261) server.
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
prog=opensips
oser=/usr/sbin/$prog
pidfile="/var/run/$prog.pid"
lockfile="/var/lock/subsys/$prog"
configfile="/etc/$prog/$prog.cfg"
OPTIONS=""
RETVAL=0
[ -f /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
start() {
echo -n $"Starting $prog: "
# check whether OpenSIPs was already started
if status -p $pidfile $prog > /dev/null 2>&1 ; then
echo -n "already running" && warning && echo
return 0
fi
# there is something at end of this output which is needed to
# report proper [ OK ] status in Fedora scripts
daemon $oser -u $prog -g $prog -P $pidfile -f $configfile $OPTIONS 2>/dev/null | tail -1
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch $lockfile
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
# check whether OpenSIPs is running
if ! status -p $pidfile $prog > /dev/null 2>&1 ; then
echo -n "not running" && warning && echo
return 0
fi
killproc $prog 2> /dev/null
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f $lockfile $pidfile
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p $pidfile $prog
RETVAL=$?
;;
restart|reload)
stop
start
;;
condrestart|try-restart)
if [ -f $pidfile ] ; then
stop
start
fi
;;
*)
echo $"Usage: $prog {start|stop|reload|restart|condrestart|status|help}"
RETVAL=2
esac
exit $RETVAL