Created
April 18, 2013 18:50
-
-
Save Qalthos/5415249 to your computer and use it in GitHub Desktop.
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 | |
# The user that will run the server | |
CS_USER=hlds | |
# Leave this alone. | |
NAME=srcds | |
PATH=/bin:/usr/bin:/sbin:/usr/sbin | |
# DON'T FORGET TO CHANGE THE PATH TO YOUR NEEDS! | |
HOMEDIR=~$CS_USER | |
DIR=$HOMEDIR/orangebox/ | |
# Leave this alone. | |
DAEMON=srcds_run | |
# Game Parameters | |
PARAMS="-console -game tf +ip 0.0.0.0 +map koth_nucleus -autoupdate +maxplayers 32" | |
# Unused params: -port 27015 -replay | |
# Leave this alone. | |
DESC="Team Fortress Dedicated Server" | |
do_start() { | |
if [[ `su $CS_USER -c "tmux ls | grep $NAME"` ]] | |
then | |
echo "$DESC is already running" | |
else | |
echo "Starting $DESC: $NAME" | |
su $CS_USER -c "cd $DIR; tmux new-session -s $NAME \"./$DAEMON $PARAMS\"" | |
fi | |
} | |
do_stop() { | |
if [[ `su $CS_USER -c "tmux ls | grep $NAME"` ]] | |
then | |
echo -n "Stopping $DESC: $NAME" | |
kill `ps aux | grep -v grep | grep -i $CS_USER | grep -i tmux | grep -i $NAME | awk '{print $2}'` | |
echo " ... done." | |
else | |
echo "Coulnd't find a running $DESC" | |
fi | |
} | |
case "$1" in | |
start) | |
do_start | |
;; | |
start_debug) | |
PARAMS="$PARAMS -debug" | |
do_start | |
;; | |
stop) | |
do_stop | |
;; | |
restart) | |
do_stop | |
do_start | |
;; | |
status) | |
ps aux | grep -v grep | grep srcds_r > /dev/null | |
CHECK=$? | |
[ $CHECK -eq 0 ] && echo "$DESC is UP" || echo "$DESC is DOWN" | |
;; | |
apache) | |
su $CS_USER -c "cd $HOMEDIR/SourceRSC; mono SourceRSC.exe" | |
;; | |
update) | |
do_stop | |
echo "Updating TF2" | |
su $CS_USER -c "cd $HOMEDIR; ./steam -command update -game "tf" -dir ." | |
do_start | |
;; | |
console) | |
su $CS_USER -c "tmux attach -t $NAME" | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart|status|apache|update|console}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment