rc.slackware.asterisk 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/sh
  2. #
  3. # Start/stop/restart Asterisk PBX
  4. #
  5. # Version: 1.0 - Paul Belanger <pabelanger@gmail.com>
  6. #
  7. # 03.29.2005 - Initial Version
  8. #
  9. # $Id$
  10. ### BEGIN INIT INFO
  11. # Provides: asterisk
  12. # Required-Start: $network $syslog $named $local_fs $remote_fs
  13. # Required-Stop: $network $syslog $named $local_fs $remote_fs
  14. # Should-Start: dahdi misdn lcr wanrouter mysql postgresql
  15. # Should-Stop: dahdi misdn lcr wanrouter mysql postgresql
  16. # Default-Start: 2 3 4 5
  17. # Default-Stop: 0 1 6
  18. # Short-Description: Asterisk PBX
  19. # Description: the Asterisk Open Source PBX
  20. ### END INIT INFO
  21. asterisk_start() {
  22. if [ -x /usr/sbin/asterisk ]; then
  23. # Check if Asterisk is already running. If it is, then bug out, because
  24. # starting safe_asterisk when Asterisk is running is very bad.
  25. VERSION=`/usr/sbin/asterisk -rx 'core show version' 2>/dev/null`
  26. if [ "`echo $VERSION | cut -c 1-8`" = "Asterisk" ]; then
  27. echo "Asterisk is already running. $0 will exit now."
  28. exit 1
  29. fi
  30. echo "Starting Asterisk /usr/sbin/asterisk"
  31. /usr/sbin/asterisk
  32. fi
  33. }
  34. asterisk_stop() {
  35. # If there is no PID file, ignore this request...
  36. if [ -r /var/run/asterisk.pid ]; then
  37. killall asterisk
  38. fi
  39. }
  40. asterisk_restart() {
  41. asterisk_stop
  42. asterisk_start
  43. }
  44. case "$1" in
  45. 'start')
  46. asterisk_start
  47. ;;
  48. 'stop')
  49. asterisk_stop
  50. ;;
  51. 'restart')
  52. asterisk_restart
  53. ;;
  54. *)
  55. echo "usage $0 start|stop|restart" ;;
  56. esac