summaryrefslogtreecommitdiff
path: root/community/opensips/opensips.init
blob: 1c883c4c2f4bd1806e5a13986b37fb00275141af (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
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

BINNAME=opensips
OSRDIR=/usr/sbin
OPENSIPS=$OSRDIR/$BINNAME

TMPDIR=/var/tmp
CORE=$TMPDIR/core

ETC=/etc/opensips/opensips.cfg
PIDFILE=/var/run/opensips.pid

case "$1" in
  start)
    stat_busy "Starting OpenSIPS server"
    cd $TMPDIR
    $OPENSIPS -f $ETC -w $TMPDIR -P $PIDFILE 2>&1 > /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      add_daemon opensips
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping OpenSIPS server"
    if [ -r $PIDFILE ]
    then
	cat $PIDFILE | xargs kill
	if [ $? -gt 0 ]; then
	  stat_fail
	else
	  rm_daemon opensips
	  stat_done
	fi
    else
	stat_fail
    fi
    ;;
  restart)
    $0 stop
    sleep 3
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"  
esac