~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to vivid/etc/init.d/sipwitch

  • Committer: Dimitri John Ledkov
  • Date: 2014-11-19 12:58:41 UTC
  • Revision ID: dimitri.j.ledkov@intel.com-20141119125841-98dr37roy8dvcv3b
auto update

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
### BEGIN INIT INFO
 
3
# Provides:             sipwitch
 
4
# Required-Start:       $named $network $syslog $remote_fs
 
5
# Required-Stop:        $named $network $syslog $remote_fs
 
6
# Default-Start:        2 3 4 5
 
7
# Default-Stop:         0 1 6
 
8
# Short-Description:    Start and stop sipwitch service daemon.
 
9
# Description:          This script manages startup and shutdown for
 
10
#                       GNU SIP Witch, a SIP telephony service daemon.
 
11
### END INIT INFO
 
12
#
 
13
# Copyright (C) 2008 David Sugar, Tycho Softworks.
 
14
#
 
15
# This file is free software; as a special exception the author gives
 
16
# unlimited permission to copy and/or distribute it, with or without
 
17
# modifications, as long as this notice is preserved.
 
18
#
 
19
# This program is distributed in the hope that it will be useful, but
 
20
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
 
21
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
22
#
 
23
# sipwitch        This shell script takes care of starting and stopping
 
24
#                 a sipwitch server running as a system service.
 
25
#
 
26
# chkconfig: - 95 15
 
27
# description: GNU SIP Witch telephony service.
 
28
 
 
29
DAEMON="/usr/sbin/sipw"
 
30
NAME="sipwitch"
 
31
DESC="sipwitch"
 
32
FIFO="/var/run/sipwitch/control"
 
33
OPTIONS="-b"
 
34
PRELOAD=""
 
35
PLUGINS=""
 
36
GROUP=""
 
37
CONCURRENCY=""
 
38
PRIORITY=""
 
39
DEFAULT="/etc/default/sipwitch"
 
40
START="1"
 
41
 
 
42
test -x "$DAEMON" || exit 0
 
43
 
 
44
set -e
 
45
 
 
46
if [ -f /etc/sysconfig/sipwitch ] ; then
 
47
    DEFAULT="/etc/sysconfig/sipwitch"
 
48
    . /etc/sysconfig/sipwitch
 
49
elif [ -f /etc/default/sipwitch ] ; then
 
50
    . /etc/default/sipwitch
 
51
elif [ -f /etc/conf.d/sipwitch ] ; then
 
52
    . /etc/conf.d/sipwitch
 
53
elif [ -f /etc/site-start.d/sipwitch ] ; then
 
54
    . /etc/site-start.d/sipwitch
 
55
fi
 
56
 
 
57
if [ ! -z "$PLUGINS" ] ; then
 
58
    export PLUGINS
 
59
else
 
60
    START="0"
 
61
fi
 
62
 
 
63
if [ ! -z "$GROUP" ] ; then
 
64
    export GROUP ; fi
 
65
 
 
66
if [ ! -z "$CONCURRENCY" ] ; then
 
67
    export CONCURRENCY ; fi
 
68
 
 
69
if [ ! -z "$PRIORITY" ] ; then
 
70
    export PRIORITY ; fi
 
71
 
 
72
if [ ! -z "$PRELOAD" ] ; then
 
73
    if [ -z "$LD_PRELOAD" ] ; then
 
74
        LD_PRELOAD="$PRELOAD"
 
75
    else
 
76
        LD_PRELOAD="$LD_PRELOAD:$PRELOAD"
 
77
    fi
 
78
    export LD_PRELOAD
 
79
fi
 
80
 
 
81
case "$SECURITY" in
 
82
desktop|Desktop|DESKTOP)
 
83
    OPTIONS="$OPTIONS --desktop"
 
84
    ;;
 
85
public|Public|PUBLIC)
 
86
    OPTIONS="$OPTIONS --desktop"
 
87
    ;;
 
88
esac
 
89
 
 
90
case "$1" in
 
91
start)
 
92
    if [ "$START" = "0" ] ; then
 
93
        if test -z "$PLUGINS" ; then
 
94
            echo "You have to define PLUGINS in $DEFAULT before running sipwitch"
 
95
        else
 
96
            echo "You have to modify config and START in $DEFAULT before running"
 
97
        fi
 
98
        exit 0
 
99
    fi
 
100
 
 
101
    if [ -p $FIFO ] ; then
 
102
        echo "already started"
 
103
        exit 1
 
104
    fi
 
105
 
 
106
    echo -n "Starting $DESC: "
 
107
    $DAEMON $OPTIONS
 
108
    echo "$NAME."
 
109
    if test -d /var/lock/subsys ; then
 
110
        touch /var/lock/subsys/sipwitch ; fi
 
111
    ;;
 
112
stop)
 
113
    if [ ! -p $FIFO ] ; then
 
114
        exit 0 ; fi
 
115
 
 
116
    echo -n "Stopping $DESC: "
 
117
    echo "down" >$FIFO
 
118
    echo "$NAME."
 
119
    if test -d /var/lock/subsys ; then
 
120
        rm -f /var/lock/subsys/sipwitch ; fi
 
121
    ;;
 
122
status)
 
123
    sipwitch status
 
124
    ;;
 
125
condrestart|try-restart)
 
126
    if [ -p $FIFO ] ; then
 
127
        echo "down" >$FIFO
 
128
        sleep 3
 
129
        $DAEMON $OPTIONS
 
130
    fi
 
131
    ;;
 
132
reload)
 
133
    if [ ! -p $FIFO ] ; then
 
134
        exit 0 ; fi
 
135
    echo -n "Reloading $DESC: "
 
136
    echo "reload" >$FIFO
 
137
    echo "$NAME."
 
138
    ;;
 
139
restart|force-reload)
 
140
    echo -n "Restarting $DESC: "
 
141
    if [ -p $FIFO ] ; then
 
142
        echo "down" >$FIFO
 
143
        sleep 3
 
144
    fi
 
145
    $DAEMON $OPTIONS
 
146
    echo "$NAME."
 
147
    ;;
 
148
*)
 
149
    N=/etc/init.d/$NAME
 
150
    echo "Usage: $N {start|stop|restart|force-reload}" >&2
 
151
    exit 1
 
152
    ;;
 
153
esac
 
154
 
 
155
exit 0
 
156
 
 
157
 
 
158
 
 
159