rc.gentoo.asterisk 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/sbin/runscript
  2. # $Id$
  3. ### BEGIN INIT INFO
  4. # Provides: asterisk
  5. # Required-Start: $network $syslog $named $local_fs $remote_fs
  6. # Required-Stop: $network $syslog $named $local_fs $remote_fs
  7. # Should-Start: dahdi misdn lcr wanrouter mysql postgresql
  8. # Should-Stop: dahdi misdn lcr wanrouter mysql postgresql
  9. # Default-Start: 2 3 4 5
  10. # Default-Stop: 0 1 6
  11. # Short-Description: Asterisk PBX
  12. # Description: the Asterisk Open Source PBX
  13. ### END INIT INFO
  14. depend() {
  15. need net logger
  16. }
  17. start() {
  18. # Check if Asterisk is already running. If it is, then bug out, because
  19. # starting safe_asterisk when Asterisk is running is very bad.
  20. VERSION=`${ASTSBINDIR}/asterisk -rx 'core show version' 2>/dev/null`
  21. if [ "`echo $VERSION | cut -c 1-8`" = "Asterisk" ]; then
  22. echo "Asterisk is already running. $0 will exit now."
  23. exit 1
  24. fi
  25. ebegin "Starting Asterisk"
  26. /usr/sbin/asterisk
  27. eend $? "Failed to start Asterisk"
  28. }
  29. stop() {
  30. ebegin "Stopping Asterisk"
  31. kill $(cat /var/run/asterisk.pid)
  32. eend $? "Failed to stop Asterisk"
  33. }