Created
October 25, 2011 08:08
-
-
Save rsa/1311797 to your computer and use it in GitHub Desktop.
mangos sysV startup script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/sh | |
| ### BEGIN INIT INFO | |
| # Provides: mangos | |
| # Required-Start: $remote_fs $syslog $named $network $time $mangos $mysql | |
| # Required-Stop: | |
| # Should-Start: | |
| # Should-Stop: | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: Starts MaNGOS server test realm | |
| # Description: This script runs the mangos server for local node | |
| ### END INIT INFO | |
| . /lib/lsb/init-functions | |
| hnode=mangos | |
| PID=/var/run/screen/S-$hnode | |
| lockfile=/var/lock/$hnode | |
| prog="mangos" | |
| start() { | |
| echo -n $"Starting $prog: " | |
| su $hnode --command="screen -AmdSU world /home/$hnode/bin/world.sh" | |
| RETVAL1=$? | |
| if [ $RETVAL1 -eq 0 ]; then | |
| touch $lockfile | |
| echo -n $"$prog started" | |
| log_end_msg 0 | |
| return 0 | |
| else | |
| echo -n $"$prog NOT started" | |
| log_end_msg 1 | |
| return 1 | |
| fi | |
| } | |
| stop() { | |
| if [ -f $lockfile ]; then | |
| rm -f $lockfile | |
| expect /home/$hnode/bin/mangos_cmd.exp .announce "Server shutdown after operation system request." | |
| sleep 1 | |
| expect /home/$hnode/bin/mangos_cmd.exp .server shutdown "60" | |
| for (( i=1; $i<9; i++)); do | |
| sleep 10 | |
| echo -n . | |
| ps1=`ps -U $hnode|grep worldd|sed 's/^ //'|sed 's/ .*//'` | |
| [ -z "$ps1" ] && break | |
| done | |
| echo | |
| if [ -f /home/$hnode/worldd.pid ]; then | |
| # | |
| kill -3 $(ps -U $hnode |grep worldd|sed 's/^ //'|sed 's/ .*//') | |
| sleep 3 | |
| kill -9 $(su $hnode --command="screen -list |grep world |sed 's/\.world.*//'|sed 's/ *//'") | |
| su $hnode --command="screen -wipe 1> /dev/null " | |
| echo "$prog stopped" | |
| log_end_msg 0 | |
| else | |
| echo "$prog stopped" | |
| log_end_msg 0 | |
| fi | |
| else | |
| echo "$prog NOT found!" | |
| log_end_msg 1 | |
| fi | |
| } | |
| status() { | |
| # status mangos | |
| echo -n "Status mangos" | |
| log_end_msg $? | |
| } | |
| case "$1" in | |
| start) | |
| start | |
| ;; | |
| stop) | |
| stop | |
| ;; | |
| status) | |
| status | |
| ;; | |
| restart|reload) | |
| stop | |
| start | |
| ;; | |
| *) | |
| echo "Usage: $0 {start|stop|status|restart|reload}" | |
| exit 2 | |
| esac | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment