Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- run() {
- # Runs the steam update and server
- # Loops if RESTART is set
- # Debugs if server failure is detected
- # Note: if RESTART is not set then
- # 1. DEBUG is set then the server is NOT exec'd
- # 2. DEBUG is not set the the server is exec'd
- if test -n "$RESTART" ; then
- echo "Auto-restarting the server on crash"
- #loop forever
- while true
- do
- # Update if needed
- update
- # Run the server
- $HL_CMD
- retval=$?
- if test $retval -eq 0 && test -z "$RESTART" ; then
- break; # if 0 is returned then just quit
- fi
- debugcore $retval
- echo "`date`: Server restart in $TIMEOUT seconds"
- # don't thrash the hard disk if the server dies, wait a little
- sleep $TIMEOUT
- done # while true
- else
- # Update if needed
- update
- # Run the server
- if test "$DEBUG" -eq 0; then
- # debug not requested we can exec
- exec $HL_CMD
- else
- # debug requested we can't exec
- $HL_CMD
- debugcore $?
- fi
- fi
- }
- quit() {
- # Exits with the give error code, 1
- # if none specified.
- # exit code 2 also prints syntax
- exitcode="$1"
- # default to failure
- if test -z "$exitcode"; then
- exitcode=1
- fi
- case "$exitcode" in
- 0)
- echo "`date`: Server Quit" ;;
- 2)
- syntax ;;
- *)
- echo "`date`: Server Failed" ;;
- esac
- # Remove pid file
- if test -n "$PID_FILE" && test -f "$PID_FILE" ; then
- # The specified pid file
- rm -f $PID_FILE
- fi
- # reset SIGINT and then kill ourselves properly
- trap - 2
- kill -2 $$
- }
- # Initialise
- init $*
- # Run
- run
- # Quit normally
- quit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement