Loading

/etc/init.d/eggdrop

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          eggdrop
  4. # Required-Start:    $syslog $network
  5. # Required-Stop:     $syslog
  6. # Should-Start:      mysql postgresql
  7. # Should-Stop:       mysql postgresql
  8. # Default-Start:     2 3 4 5
  9. # Default-Stop:      0 1 6
  10. # Short-Description: Eggdrop.
  11. # Description:       Eggdrop.
  12. ### END INIT INFO
  13. # Do NOT "set -e"
  14.  
  15. # PATH should only include /usr/* if it runs after the mountnfs.sh script
  16. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  17. DESC="Eggdrop"
  18. NAME=eggdrop
  19. SERVICEVERBOSE=yes
  20. PIDFILE=/var/run/$NAME.pid
  21. SCRIPTNAME=/etc/init.d/$NAME
  22. WORKINGDIR=/home/ircd/EchoEGG
  23. DAEMON=$WORKINGDIR/$NAME
  24. DAEMON_ARGS="eggdrop eggdrop.conf"
  25. USER=ircd
  26.  
  27. #su ircd -c "cd  /home/ircd/EchoEGG/ && /home/ircd/EchoEGG/eggdrop eggdrop.conf"
  28.  
  29. # Read configuration variable file if it is present
  30. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  31.  
  32. # Exit if the package is not installed
  33. [ -x "$DAEMON" ] || exit 0
  34.  
  35. # Load the VERBOSE setting and other rcS variables
  36. . /lib/init/vars.sh
  37.  
  38. # Define LSB log_* functions.
  39. # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
  40. # and status_of_proc is working.
  41. . /lib/lsb/init-functions
  42.  
  43. #
  44. # Function that starts the daemon/service
  45. #
  46. do_start()
  47. {
  48.         # Return
  49.         #   0 if daemon has been started
  50.         #   1 if daemon was already running
  51.         #   2 if daemon could not be started
  52.  /bin/sh  -c "USER=$USER start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --exec $DAEMON -- $DAEMON_ARGS > /dev/null \\
  53.                        --test --chdir $WORKINGDIR --chuid $USER \\
  54.                        || return 1"
  55.  /bin/sh  -c "USER=$USER start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \\
  56.                        --background --chdir $WORKINGDIR --chuid $USER \\
  57.                        --exec $DAEMON -- $DAEMON_ARGS \\
  58.                        || return 2"
  59. }
  60.  
  61. #
  62. # Function that stops the daemon/service
  63. #
  64. do_stop()
  65. {
  66.         # Return
  67.         #   0 if daemon has been stopped
  68.         #   1 if daemon was already stopped
  69.         #   2 if daemon could not be stopped
  70.         #   other if a failure occurred
  71.         start-stop-daemon --stop --quiet --retry=TERM/1/KILL/5 --pidfile $PIDFILE --name $NAME
  72.         RETVAL="$?"
  73.         [ "$RETVAL" = 2 ] && return 2
  74.         start-stop-daemon --stop --quiet --oknodo --retry=0/1/KILL/5 --exec $DAEMON
  75.         [ "$?" = 2 ] && return 2
  76.         # Many daemons don't delete their pidfiles when they exit.
  77.         rm -f $PIDFILE
  78.         return "$RETVAL"
  79. }
  80.  
  81.  
  82. case "$1" in
  83.   start)
  84.         [ "$SERVICEVERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
  85.         do_start
  86.         case "$?" in
  87.                 0|1) [ "$SERVICEVERBOSE" != no ] && log_end_msg 0 ;;
  88.                 2) [ "$SERVICEVERBOSE" != no ] && log_end_msg 1 ;;
  89.         esac
  90.         ;;
  91.   stop)
  92.         [ "$SERVICEVERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  93.         do_stop
  94.         case "$?" in
  95.                 0|1) [ "$SERVICEVERBOSE" != no ] && log_end_msg 0 ;;
  96.                 2) [ "$SERVICEVERBOSE" != no ] && log_end_msg 1 ;;
  97.         esac
  98.         ;;
  99.   status)
  100.         status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
  101.         ;;
  102.   restart|force-reload)
  103.         log_daemon_msg "Restarting $DESC" "$NAME"
  104.         do_stop
  105.         case "$?" in
  106.           0|1)
  107.                 do_start
  108.                 case "$?" in
  109.                         0) log_end_msg 0 ;;
  110.                         1) log_end_msg 1 ;; # Old process is still running
  111.                         *) log_end_msg 1 ;; # Failed to start
  112.                 esac
  113.                 ;;
  114.           *)
  115.                 # Failed to stop
  116.                 log_end_msg 1
  117.                 ;;
  118.                 esac
  119.         ;;
  120.   *)
  121.                 echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
  122.                 exit 3
  123.                 ;;
  124. esac

Comments