Advertisement
deseven

/etc/init.d/l2l

Dec 18th, 2011
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.56 KB | None | 0 0
  1. #! /bin/sh
  2. # Author:   deseven,   <de7@deseven.info>
  3. #
  4. # chkconfig:    2345 98 02
  5. # description:  l2j login server
  6. # processname:  java
  7.  
  8. # Source function library.
  9. . /etc/rc.d/init.d/functions
  10.  
  11. # Source networking configuration.
  12. . /etc/sysconfig/network
  13.  
  14. # Name of service
  15. SERVICE="l2l"
  16.  
  17. # Main ls invocation
  18. INVOC="java -Xbootclasspath/p:./lib/jsr167.jar -Dfile.encoding=UTF-8 -Xmx256m -server -XX:SurvivorRatio=8 -Xnoclassgc -XX:+AggressiveOpts  -cp lib/*: com.emurt.loginserver.LoginServer"
  19.  
  20. # Name of ls session
  21. SESS="login"
  22.  
  23. # User that should run the server
  24. USERNAME="srv"
  25.  
  26. # Path to ls directory
  27. LSPATH="/home/srv/l2/emurt-login"
  28.  
  29. # Path to PID-file
  30. PIDPATH="/home/srv/l2/emurt-login/config/server.pid"
  31.  
  32. RETVAL=0
  33.  
  34. srv_start() {
  35.     echo -n "Starting $SERVICE:"
  36.     daemon screen -dmS $SESS "su $USERNAME -c 'cd $LSPATH && $INVOC'"
  37.     RETVAL=$?
  38.     echo
  39.     [ $RETVAL = 0 ] && touch /var/lock/subsys/$SERVICE
  40. }
  41.  
  42. srv_stop() {
  43.     echo -n "Stopping $SERVICE:"
  44.     killproc -p $PIDPATH
  45.     RETVAL=$?
  46.     echo
  47.     [ $RETVAL = 0 ] && rm -f /var/lock/subsys/$SERVICE
  48. }
  49.  
  50. case "$1" in
  51.     start)
  52.         # Starts the server if there is active interface
  53.         [ "$NETWORKING" = "yes" ] || exit 6
  54.         srv_start
  55.         ;;
  56.     stop)
  57.         # Stops the server
  58.         srv_stop
  59.         ;;
  60.     restart)
  61.         # Restarts the server
  62.         srv_stop
  63.         srv_start
  64.         ;;
  65.     status)
  66.         # Shows server status
  67.         status -p $PIDPATH $SERVICE
  68.         RETVAL=$?
  69.         ;;
  70.     sess)
  71.         # Shows current screen session
  72.         screen -x $SESS
  73.         RETVAL=$?
  74.         ;;
  75.     *)
  76.         echo "Usage: $0 {start|stop|status|restart|sess}"
  77.         exit 1
  78.         ;;
  79. esac
  80.  
  81. exit $RETVAL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement