Comment out LD_ASSUME_KERNEL by default.
[asterisk/asterisk.git] / contrib / init.d / rc.debian.asterisk
1 #! /bin/sh
2 # $Id: asterisk,v 1.3 2005/11/17 22:30:01 Gregory Boehnlein <damin@nacs.net>
3 #
4 # asterisk      start the asterisk PBX
5 #
6 # Thu Nov 17 2005 Gregory Boehnlein <damin@nacs.net>
7 # - Updated Version to 1.3
8 # - Reversed behavior of LD_ASSUME_KERNEL=2.4.1
9 # - Added detailed failure messages
10 #
11 # Sun Jul 18 2004 Gregory Boehnlein <damin@nacs.net>
12 # - Updated Version to 1.2
13 # - Added test for safe_asterisk
14 # - Changed "stop gracefully" to "stop now"
15 # - Added support for -U and -G command line options
16 # - Modified "reload" to call asterisk -rx 'reload' 
17
18 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
19 NAME=asterisk
20 DESC="Asterisk PBX"
21 # Full path to asterisk binary
22 DAEMON=/usr/sbin/asterisk
23
24 # Full path to safe_asterisk script
25 SAFE_ASTERISK=/usr/sbin/safe_asterisk
26
27 # Uncomment this ONLY if you know what you are doing.
28 # export LD_ASSUME_KERNEL=2.4.1
29
30 # Uncomment the following and set them to the user/groups that you
31 # want to run Asterisk as. NOTE: this requires substantial work to
32 # be sure that Asterisk's environment has permission to write the
33 # files required  for  its  operation, including logs, its comm
34 # socket, the asterisk database, etc.
35 #AST_USER="asterisk"
36 #AST_GROUP="asterisk"
37
38 if ! [ -x $DAEMON ] ; then
39         echo "ERROR: /usr/sbin/asterisk not found"
40         exit 0
41 fi
42
43 if ! [ -d /etc/asterisk ] ; then
44         echo "ERROR: /etc/asterisk directory not found"
45         exit 0
46 fi
47
48 set -e
49
50 case "$1" in
51   start)
52         echo -n "Starting $DESC: "
53         if [ -f $SAFE_ASTERISK ] ; then
54                 DAEMON=$SAFE_ASTERISK
55         fi
56         if [ $AST_USER ] ; then
57                 ASTARGS="-U $AST_USER"
58         fi
59         if [ $AST_GROUP ] ; then
60                 ASTARGS="`echo $ASTARGS` -G $AST_GROUP"
61         fi
62         start-stop-daemon --start --exec $DAEMON -- $ASTARGS
63         echo "$NAME."
64         ;;
65   stop)
66         echo -n "Stopping $DESC: "
67         $DAEMON -rx 'stop now' > /dev/null 2> /dev/null && echo -n "$NAME"
68         echo "."
69         exit 0
70         ;;
71   reload)
72         echo "Reloading $DESC configuration files."
73         $DAEMON -rx 'reload' > /dev/null 2> /dev/null
74         ;;
75   restart|force-reload)
76         $DAEMON -rx 'restart gracefully' > /dev/null 2> /dev/null && echo -n "$NAME"
77         ;;
78   *)
79         N=/etc/init.d/$NAME
80         echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
81         exit 1
82         ;;
83 esac
84
85 exit 0