Last active
December 31, 2015 13:39
-
-
Save mackal/7994207 to your computer and use it in GitHub Desktop.
This file contains 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/bash | |
#bashisms woo | |
ulimit -c unlimited | |
case "$1" in | |
start) | |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. | |
rm -rf logs/*.log | |
chmod --recursive ugo+rwx quests | |
#sleep 5 | |
echo Loading Shared Mem... | |
./shared_memory > /dev/null 2>&1 & | |
sleep 2 | |
echo Starting World Server... | |
./world > /dev/null 2>&1 & | |
echo $! > world.pid | |
sleep 3 | |
echo Starting Query Server... | |
./queryserv > /dev/null 2>&1 & | |
echo $! > queryserv.pid | |
sleep 5 | |
echo Starting the Zone Launcher... | |
./eqlaunch zone > /dev/null 2>&1 & | |
echo $! > eqlaunch.pid | |
sleep 5 | |
echo The server is mostly ready... Give it a couple of minutes | |
echo to load stuff from the database before the users start logging in. | |
;; | |
stop) | |
kill $(cat world.pid) | |
kill $(cat queryserv.pid) | |
kill $(cat eqlaunch.pid) | |
rm -f *.pid | |
echo All server components have been exited. | |
;; | |
restart|reload) | |
$0 stop | |
$0 start | |
;; | |
status) | |
if [ -f world.pid ] && ps -p $(cat world.pid) > /dev/null; then | |
echo -e World Server '\t\t' [$(tput bold)$(tput setaf 2)UP$(tput sgr0)] | |
else | |
echo -e World Server '\t\t' [$(tput bold)$(tput setaf 1)DOWN$(tput sgr0)] | |
fi | |
if [ -f queryserv.pid ] && ps -p $(cat queryserv.pid) > /dev/null; then | |
echo -e Query Server '\t\t' [$(tput bold)$(tput setaf 2)UP$(tput sgr0)] | |
else | |
echo -e Query Server '\t\t' [$(tput bold)$(tput setaf 1)DOWN$(tput sgr0)] | |
fi | |
if [ -f eqlaunch.pid ] && ps -p $(cat eqlaunch.pid) > /dev/null; then | |
# Switch around the comment on these lines depending on your pgrep version ... | |
# echo -e Zone Launcher '\t\t' [$(tput bold)$(tput setaf 2)UP$(tput sgr0)] \($(pgrep zone | wc -l)\) | |
echo -e Zone Launcher '\t\t' [$(tput bold)$(tput setaf 2)UP$(tput sgr0)] \($(pgrep -c zone)\) | |
else | |
echo -e Zone Launcher '\t\t' [$(tput bold)$(tput setaf 1)DOWN$(tput sgr0)] | |
fi | |
;; | |
help|*) | |
printf "Usage: \n $0 [start|stop|reload|restart|status|help]" | |
printf "\n\n" | |
printf " start\t\tStarts the server components\n" | |
printf " stop\t\tStops all the server components started by this script\n" | |
printf " restart/reload\tRestarts the server\n" | |
printf " status\t\tLists the status of the server components\n" | |
printf " help\t\tDisplays this message\n" | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment