Loading

/etc/init.d/inspircd

  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          inspircd
  4. # Required-Start:    $remote_fs $network $syslog $time
  5. # Required-Stop:     $remote_fs $syslog
  6. # Should-Start:      $local_fs
  7. # Should-Stop:       $local_fs
  8. # Default-Start:     2 3 4 5
  9. # Default-Stop:      0 1 6
  10. # Short-Description: Start inspircd
  11. # Description:       Starts the inspircd irc server
  12. ### END INIT INFO
  13. # GPL Licensed
  14.  
  15. #su ircd -c "/home/ircd/inspircd/run/inspircd start"
  16. #su ircd -c "/home/ircd/Anope/bin/anoperc start"
  17. #su ircd -c "/usr/local/bin/znc"
  18.  
  19.  
  20. NAME="inspircd"
  21. IRCD="/home/ircd/inspircd/run/inspircd"
  22. IRCDPID="/home/ircd/inspircd/run/inspircd.pid"
  23. IRCDLOG="/var/log/inspircd.log"
  24. IRCDCONF="/home/ircd/inspircd/run/conf/inspircd.conf"
  25. #IRCDARGS="--logfile $IRCDLOG --config $IRCDCONF"
  26. IRCDARGS="--logfile $IRCDLOG"
  27.  
  28. USER="ircd"
  29. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  30.  
  31. if [ -f "/etc/default/inspircd" ]; then
  32.         . /etc/default/inspircd
  33. fi
  34.  
  35. # Define LSB log_* functions (status_of_proc)
  36. . /lib/lsb/init-functions
  37.  
  38. if [ ! -x "$IRCD" ]; then exit 0; fi
  39.  
  40. if [ -f "$IRCDPID" ]; then
  41.         IRCDPIDN=`cat "$IRCDPID" 2> /dev/null`
  42. fi
  43.  
  44. start_ircd()
  45. {
  46.         [ -f "$IRCDPID" ] || ( touch "$IRCDPID" ; chown "$USER" "$IRCDPID" )
  47.         [ -f "$IRCDLOG" ] || ( touch "$IRCDLOG" ; chown "$USER:adm" "$IRCDLOG" ; chmod 0640 "$IRCDLOG" )
  48.         export LD_LIBRARY_PATH=/usr/lib/inspircd
  49.         start-stop-daemon --start --quiet --oknodo --chuid "$USER" --pidfile "$IRCDPID" --exec "$IRCD" start > /dev/null
  50. }
  51.  
  52. stop_ircd()
  53. {
  54.         start-stop-daemon --stop --quiet --pidfile "$IRCDPID" > /dev/null 2> /dev/null
  55.         rm -f "$IRCDPID"
  56. #       su ircd -c "/home/ircd/Anope/bin/anoperc stop"
  57.         return 0
  58. }
  59.  
  60. reload_ircd()
  61. {
  62.         if [ ! -z "$IRCDPIDN" ] && kill -0 $IRCDPIDN 2> /dev/null; then
  63.                 kill -HUP $IRCDPIDN >/dev/null 2>&1 || return 1
  64.                 return 0
  65.         else
  66.                 echo "Error: IRCD is not running."
  67.                 return 1
  68.         fi
  69. }
  70.  
  71. case "$1" in
  72.   start)
  73.         if [ "$INSPIRCD_ENABLED" != "1" ]; then
  74.                 echo -n "Please configure inspircd first and edit /etc/default/inspircd, otherwise inspircd won't start"
  75.                 exit 0
  76.         fi
  77.         echo -n "Starting Inspircd... "
  78.         start_ircd && echo "done."
  79.         su ircd -c "/home/ircd/Anope/bin/anoperc start"
  80.         echo "Starting Anope..."
  81.         ;;
  82.   stop)
  83.         echo -n "Stopping Inspircd... "
  84.         stop_ircd && echo "done."
  85.         su ircd -c "/home/ircd/Anope/bin/anoperc stop"
  86.         echo -n "Stopping Anope... "
  87.         ;;
  88.   status)
  89.         status_of_proc "$IRCD" "$NAME" && exit 0 || exit $?
  90.         echo -n "/home/ircd/Anope/bin/anoperc status"
  91.         ;;
  92.   force-reload|reload)
  93.         echo -n "Reloading Inspircd... "
  94.         reload_ircd && echo "done."
  95.         ;;
  96.   restart)
  97.         $0 stop
  98.         sleep 2s
  99.         $0 start
  100. #        su ircd -c "/home/ircd/Anope/bin/anoperc start"
  101. #        echo "Starting Anope..."
  102.         ;;
  103.   cron)
  104.         start_ircd || echo "Inspircd not running, starting it"
  105.         ;;
  106.  
  107.   *)
  108.         echo "Usage: $0 {start|stop|status|restart|reload|force-reload|cron}"
  109.         exit 1
  110. esac

Comments