Advertisement
roadapathy

wowlogon

Jul 30th, 2011
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.21 KB | None | 0 0
  1. root@netbook:/etc/init.d# cat wowlogon
  2. #! /bin/sh
  3. #
  4. ### BEGIN INIT INFO
  5. # Provides:          logon
  6. # Required-Start:    $syslog $local_fs $remote_fs
  7. # Required-Stop:     $syslog $local_fs $remote_fs
  8. # Should-Start:      dbus avahi
  9. # Should-Stop:       dbus avahi
  10. # Default-Start:     2 3 4 5
  11. # Default-Stop:      1
  12. # Short-Description: WoW logon server
  13. # Description:       Logon server run before world
  14. #                    
  15. ### END INIT INFO
  16.  
  17. PATH=/home/arcemu/server
  18. DAEMON=/home/arcemu/server/logon
  19. NAME=logon
  20. DESC="WoW logon"
  21.  
  22. test -x /home/arcemu/server/logon -a -r || exit 0
  23.  
  24. RUN=yes
  25. RUN_AS_USER=arcemu
  26.  
  27. DAEMON_OPTS="-a $RUN_AS_USER"
  28.  
  29. set -e
  30.  
  31. case "$1" in
  32.   start)
  33.     echo -n "Starting $DESC: "
  34.     start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
  35.         --exec /home/arcemu/server/logon
  36.     echo "$NAME."
  37.     ;;
  38.   stop)
  39.     echo -n "Stopping $DESC: "
  40.     start-stop-daemon --stop --oknodo --quiet --pidfile /var/run/$NAME.pid \
  41.         --exec /home/arcemu/server/logon
  42.     echo "$NAME."
  43.     ;;
  44.   force-reload)
  45.     # check whether $DAEMON is running. If so, restart
  46.     start-stop-daemon --stop --test --quiet --pidfile \
  47.         /var/run/$NAME.pid --exec /home/arcemu/server/logon && $0 restart || exit 0
  48.     ;;
  49.   restart)
  50.     echo -n "Restarting $DESC: "
  51.     start-stop-daemon --stop --oknodo --quiet --pidfile \
  52.         /var/run/$NAME.pid --exec /home/arcemu/server/logon
  53.     sleep 1
  54.     start-stop-daemon --start --quiet --pidfile \
  55.         /var/run/$NAME.pid --exec /home/arcemu/server/logon
  56.     echo "$NAME."
  57.     ;;
  58.   status)
  59.     if [ -s /var/run/$NAME.pid ]; then
  60.             RUNNING=$(cat /var/run/$NAME.pid)
  61.             if [ -d /proc/$RUNNING ]; then
  62.                 if [ $(readlink /proc/$RUNNING/exe) = $DAEMON ]; then
  63.                     echo "$NAME is running."
  64.                     exit 0
  65.                 fi
  66.             fi
  67.  
  68.             # No such PID, or executables don't match
  69.             echo "$NAME is not running, but pidfile existed."
  70.             rm /var/run/$NAME.pid
  71.             exit 1
  72.         else
  73.             rm -f /var/run/$NAME.pid
  74.             echo "$NAME not running."
  75.             exit 1
  76.         fi
  77.     ;;
  78.   *)
  79.     N=/etc/init.d/$NAME
  80.     echo "Usage: $N {start|stop|restart|force-reload}" >&2
  81.     exit 1
  82.     ;;
  83. esac
  84.  
  85. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement