Created
September 22, 2012 00:24
-
-
Save jnsdbr/3764652 to your computer and use it in GitHub Desktop.
GameServer Startup Script
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/sh | |
# | |
# This is a very old startup script for gameservers which can be easily modified | |
# | |
# What u need: | |
# screen | |
# awk | |
# Quake3 Files | |
# | |
# VARS: | |
# G_USER Username | |
# NAME The Screen Name | |
# DESC Server Desciption | |
# PARAMS Start Parameter | |
# DIR Directory | |
# SCRIPT Serverstart Script | |
# DAEMON Daemon | |
# | |
# OPTIONS: (start|stop|restart|status) | |
# USER | |
# The user which is running the server. | |
G_USER=gamesrv | |
# VARS | |
# Screen NAME | |
# Attach Screen : # screen -r NAME | |
# Detach Screen : # [CTRL]+[A]; [D] | |
# Don't press [CTRL]+[C] it will terminate screen | |
NAME=quake3 | |
# SERVER DESCRIPTION | |
# Single Word DESC=myserver | |
# Multiple Words DESC="This is my Server" | |
DESC="Quake3 Dedicated Server" | |
# PARAMETER | |
PARAMS="+set sv_pure 1 +set dedicated 2 +set fs_game osp +exec 1v1.cfg +set com_hunkmegs 128" | |
# DIRECTORY | |
# Your Path to your Source Dedicated Server Directory (absolute) | |
DIR=/home/gamesrv/quake3 | |
# DAEMON | |
# You place your startscript here, normally q3ded | |
SCRIPT=q3ded | |
# MAIN SCRIPT | |
DAEMON=$DIR/$SCRIPT | |
case "$1" in | |
start) | |
if [[ `su $G_USER -c "screen -ls | grep $NAME"` ]] | |
then | |
echo "$DESC is already running!" | |
else | |
echo "Starting $DESC: $NAME" | |
su $G_USER -c "cd $DIR; screen -d -m -S $NAME $DAEMON $PARAMS" | |
fi | |
;; | |
stop) | |
if [[ `su $G_USER -c "screen -ls | grep $NAME"` ]] | |
then | |
echo -n "Stopping $DESC: $NAME " | |
kill `ps aux | grep -i screen | grep -i $NAME | awk '{print $2}'` | |
echo " ... done." | |
else | |
echo "Coulnd't find a running $DESC" | |
fi | |
;; | |
restart) | |
if [[ `su $G_USER -c "screen -ls | grep $NAME"` ]] | |
then | |
echo -n "Stopping $DESC: $NAME " | |
kill `ps aux | grep -i screen | grep -i $NAME | awk '{print $2}'` | |
echo " ... done." | |
else | |
echo "Coulnd't find a running $DESC" | |
fi | |
echo -n "Starting $DESC: $NAME" | |
su $G_USER -c "cd $DIR; screen -d -m -S $NAME $DAEMON $PARAMS" | |
echo " ... done." | |
;; | |
status) | |
ps aux | grep -v grep | grep $SCRIPT > /dev/null | |
CHECK=$? | |
[ $CHECK -eq 0 ] && echo "$DESC is UP" || echo "$DESC is DOWN" | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart|status}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment