Created
October 12, 2011 06:36
-
-
Save MatthewHallCom/1280457 to your computer and use it in GitHub Desktop.
GameCP Init.d
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/bash | |
### BEGIN INIT INFO | |
# Provides: gamecp | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 4 5 | |
# Default-Stop: 1 2 3 4 6 | |
# Short-Description: GameCP Remote Server | |
# Description: Starts and stops GameCP | |
### END INIT INFO | |
# chkconfig: - 80 45 | |
# description: Starts and stops GameCP | |
MAINDIR="/usr/local/gcp" | |
case $(uname -m) in x86_64|amd64|ia64) | |
ARCH="x64" | |
ARCH2="64" | |
;; | |
*) | |
ARCH="i386" | |
ARCH2="32" | |
;; | |
esac | |
start() { | |
PID2=`pidof gamecp_$ARCH` | |
if [ $PID2 ]; then | |
echo "GameCP is already started " | |
echo $PID2; | |
else | |
echo "Starting GameCP" | |
echo $PID2 | |
cd $MAINDIR | |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:/usr/lib:/usr/local/lib:$MAINDIR/bin$ARCH2/lib | |
$MAINDIR/bin$ARCH2/gamecp_$ARCH | |
fi | |
return 0 | |
} | |
stop() { | |
echo "Stopping GameCP" | |
killall gamecp_$ARCH | |
echo "" | |
return 0 | |
} | |
status() { | |
# Code here to check the status of the program | |
PID=`pidof gamecp_$ARCH` | |
if [ $PID ]; then | |
echo "Process id "; | |
echo $PID; | |
else | |
echo "No process id found"; | |
fi | |
return 0 | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status | |
;; | |
debug) | |
debug | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|status|restart}" | |
exit 1 | |
esac | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment