Advertisement
Guest User

Untitled

a guest
Oct 14th, 2012
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.75 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # general config
  4. . /etc/rc.conf
  5. . /etc/rc.d/functions
  6.  
  7. PID=`pidof -o %PPID /usr/sbin/asterisk`
  8. case "$1" in
  9.   start)
  10.     stat_busy "Starting Asterisk"
  11.     [ -z "$PID" ] && cd /var/lib/asterisk && /usr/sbin/asterisk -G asterisk -U asterisk
  12.     if [ $? -gt 0 ]; then
  13.       stat_fail
  14.     else
  15.       add_daemon asterisk
  16.       stat_done
  17.     fi
  18.     ;;
  19.   stop)
  20.     stat_busy "Stopping Asterisk"
  21.     [ ! -z "$PID" ]  && kill $PID &> /dev/null
  22.     if [ $? -gt 0 ]; then
  23.       stat_fail
  24.     else
  25.       rm -f /var/run/asterisk/asterisk.pid &>/dev/null
  26.       rm_daemon asterisk
  27.       stat_done
  28.     fi
  29.     ;;
  30.   restart)
  31.     $0 stop
  32.     sleep 2
  33.     $0 start
  34.     ;;
  35.   *)
  36.     echo "usage: $0 {start|stop|restart}"  
  37. esac
  38. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement