14 |
# Initialises the various variables |
# Initialises the various variables |
15 |
# Set up the defaults |
# Set up the defaults |
16 |
GAME="valve" |
GAME="valve" |
17 |
DEBUG="" |
DEBUG=0 |
18 |
RESTART="yes" |
RESTART="yes" |
19 |
HL=./hlds_i486 |
HL=./hlds_i486 |
20 |
HL_DETECT=1 |
HL_DETECT=1 |
22 |
CRASH_DEBUG_MSG="email debug.log to linux@valvesoftware.com" |
CRASH_DEBUG_MSG="email debug.log to linux@valvesoftware.com" |
23 |
GDB="gdb" # the gdb binary to run |
GDB="gdb" # the gdb binary to run |
24 |
DEBUG_LOG="debug.log" |
DEBUG_LOG="debug.log" |
25 |
PID_FILE="" # Used for debug and with -pidfile argument |
PID_FILE="" |
26 |
STEAM="" |
STEAM="" |
|
#PID_FILE_SET=0 |
|
27 |
STEAMERR="" |
STEAMERR="" |
28 |
SIGINT_ACTION="quit 0" # exit normally on sig int |
SIGINT_ACTION="quit 0" # exit normally on sig int |
29 |
NO_TRAP=0 |
NO_TRAP=0 |
30 |
AUTO_UPDATE="" |
AUTO_UPDATE="" |
|
#STEAM_USER="" |
|
|
#STEAM_PASSWORD="" |
|
31 |
BETA_VERSION="" |
BETA_VERSION="" |
32 |
PARAMS=$* |
PARAMS=$* |
33 |
|
|
48 |
GAME="$2" |
GAME="$2" |
49 |
shift ;; |
shift ;; |
50 |
"-debug") |
"-debug") |
51 |
DEBUG=1 ;; |
DEBUG=1 |
52 |
# Ensure that PID_FILE is set |
# Ensure that PID_FILE is set |
53 |
#PID_FILE_SET=1 |
if test -z "$PID_FILE"; then |
54 |
#if test -z "$PID_FILE"; then |
PID_FILE="hlds.$$.pid" |
55 |
# PID_FILE="hlds.$$.pid" |
fi ;; |
|
#fi ;; |
|
56 |
"-norestart") |
"-norestart") |
57 |
RESTART="" ;; |
RESTART="" ;; |
58 |
"-pidfile") |
"-pidfile") |
59 |
PID_FILE="$2" |
PID_FILE="$2" |
|
#PID_FILE_SET=1 |
|
60 |
shift ;; |
shift ;; |
61 |
"-binary") |
"-binary") |
62 |
HL="$2" |
HL="$2" |
81 |
SIGINT_ACTION="" ;; |
SIGINT_ACTION="" ;; |
82 |
"-notrap") |
"-notrap") |
83 |
NO_TRAP=1 ;; |
NO_TRAP=1 ;; |
|
#"-steamuser") |
|
|
# STEAM_USER="$2"; |
|
|
# shift ;; |
|
|
#"-steampass") |
|
|
# STEAM_PASSWORD="$2"; |
|
|
# shift ;; |
|
84 |
"-beta") |
"-beta") |
85 |
BETA_VERSION="$2"; |
BETA_VERSION="$2"; |
86 |
shift ;; |
shift ;; |
125 |
fi |
fi |
126 |
|
|
127 |
# Setup debugging |
# Setup debugging |
128 |
if test -n "$DEBUG" ; then |
if test "$DEBUG" -eq 1; then |
129 |
#turn on core dumps :) (if possible) |
#turn on core dumps :) (if possible) |
130 |
echo "Enabling debug mode" |
echo "Enabling debug mode" |
131 |
if test "`ulimit -c`" -eq 0 ; then |
if test "`ulimit -c`" -eq 0 ; then |
135 |
if test -z "$GDB_TEST"; then |
if test -z "$GDB_TEST"; then |
136 |
echo "Please install gdb first." |
echo "Please install gdb first." |
137 |
echo "goto http://www.gnu.org/software/gdb/ " |
echo "goto http://www.gnu.org/software/gdb/ " |
138 |
DEBUG="" # turn off debugging cause gdb isn't installed |
DEBUG=0 # turn off debugging cause gdb isn't installed |
139 |
fi |
fi |
140 |
fi |
fi |
141 |
|
|
142 |
#if test -n "$STEAM_PASSWORD" && test -z "$STEAM_USER"; then |
PID_IN_PARAMS="`echo $PARAMS | grep -e -pidfile`" |
|
# echo "You must set both the steam username and password." |
|
|
# quit 1 |
|
|
#fi |
|
|
|
|
|
PID_PASSED="`echo \047$PARAMS\047 | grep -e -pidfile`"; |
|
|
if test -n "$PID_PASSED" || test -n "$DEBUG"; then |
|
|
if test -z "$PID_FILE"; then |
|
|
PID_FILE="hlds.$$.pid" |
|
|
fi |
|
|
fi |
|
143 |
|
|
144 |
if test -n "$DEBUG" && test -z "$PID_PASSED"; then |
if test -z "$PID_IN_PARAMS" && test -n "$PID_FILE"; then |
145 |
HL_CMD="$HL $PARAMS -pidfile $PID_FILE" |
HL_CMD="$HL $PARAMS -pidfile $PID_FILE" |
146 |
else |
else |
147 |
HL_CMD="$HL $PARAMS" |
HL_CMD="$HL $PARAMS" |
155 |
echo "$0 [-game <game>] [-debug] [-norestart] [-pidfile]" |
echo "$0 [-game <game>] [-debug] [-norestart] [-pidfile]" |
156 |
echo " [-binary [hlds_i486|hlds_i686|hlds_amd]" |
echo " [-binary [hlds_i486|hlds_i686|hlds_amd]" |
157 |
echo " [-timeout <number>] [-gdb <gdb>] [-autoupdate]" |
echo " [-timeout <number>] [-gdb <gdb>] [-autoupdate]" |
158 |
#echo " [-steamerr] [-ignoresigint] [-steamuser <username>]" |
echo " [-steamerr] [-ignoresigint] [-beta <version>]" |
159 |
echo " [-steamerr] [-ignoresigint] [-debuglog <logname>]" |
echo " [-debuglog <logname>]" |
|
#echo " [-steampass <password>] [-debuglog <logname>]" |
|
|
echo " [-beta <version>]" |
|
160 |
echo "Params:" |
echo "Params:" |
161 |
echo "-game <game> Specifies the <game> to run." |
echo "-game <game> Specifies the <game> to run." |
162 |
echo "-debug Run debugging on failed servers if possible." |
echo "-debug Run debugging on failed servers if possible." |
168 |
echo " a failed server." |
echo " a failed server." |
169 |
echo "-gdb <gdb> Use <dbg> as the debugger of failed servers." |
echo "-gdb <gdb> Use <dbg> as the debugger of failed servers." |
170 |
echo "-steamerr Quit on steam update failure." |
echo "-steamerr Quit on steam update failure." |
|
#echo "-steamuser <username> Use this username for steam updates." |
|
|
#echo "-steampass <password> Use this password for steam updates" |
|
|
#echo " (-steamuser must be specified as well)." |
|
171 |
echo "-ignoresigint Ignore signal INT ( prevents CTRL+C quitting" |
echo "-ignoresigint Ignore signal INT ( prevents CTRL+C quitting" |
172 |
echo " the script )." |
echo " the script )." |
173 |
echo "-notrap Don't use trap. This prevents automatic" |
echo "-notrap Don't use trap. This prevents automatic" |
185 |
exitcode=$1 |
exitcode=$1 |
186 |
|
|
187 |
if test $exitcode -ne 0; then |
if test $exitcode -ne 0; then |
188 |
if test -n "$DEBUG" ; then |
if test "$DEBUG" -eq 1; then |
189 |
echo "bt" > debug.cmds; |
echo "bt" > debug.cmds; |
190 |
echo "info locals" >> debug.cmds; |
echo "info locals" >> debug.cmds; |
191 |
echo "info sharedlibrary" >> debug.cmds |
echo "info sharedlibrary" >> debug.cmds |
293 |
if test -n "$BETA_VERSION"; then |
if test -n "$BETA_VERSION"; then |
294 |
CMD="$CMD -beta $BETA_VERSION"; |
CMD="$CMD -beta $BETA_VERSION"; |
295 |
fi |
fi |
|
#if test -n "$STEAM_USER"; then |
|
|
# CMD="$CMD -username $STEAM_USER"; |
|
|
#fi |
|
|
#if test -n "$STEAM_PASSWORD"; then |
|
|
# CMD="$CMD -password $STEAM_PASSWORD"; |
|
|
#fi |
|
296 |
|
|
297 |
$CMD |
$CMD |
298 |
if test $? -ne 0; then |
if test $? -ne 0; then |
354 |
update |
update |
355 |
|
|
356 |
# Run the server |
# Run the server |
357 |
if test -z "$DEBUG"; then |
if test "$DEBUG" -eq 0; then |
358 |
# debug not requested we can exec |
# debug not requested we can exec |
359 |
exec $HL_CMD |
exec $HL_CMD |
360 |
else |
else |