Advertisement
Guest User

srcds_runscript.sh

a guest
Mar 16th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.52 KB | None | 0 0
  1. #/bin/dash
  2.  
  3. # replace  with the user you created above
  4. SRCDS_USER="sebastian"
  5.  
  6. # Do not change this path
  7. PATH=/bin:/usr/bin:/sbin:/usr/sbin
  8.  
  9. # The path to the game you want to host. example = /home/newuser/dod
  10. DIR=/home/sebastian/tf/orangebox
  11. DAEMON=$DIR/srcds_run
  12.  
  13. # Change all PARAMS to your needs.
  14. PARAMS="-game tf +map cp_badlands"
  15. NAME=SRCDS
  16. DESC="source dedicated server"
  17.  
  18. case "$1" in
  19.   start)
  20.     echo "Starting $DESC: $NAME"
  21.     if [ -e $DIR ]; then
  22.       cd $DIR
  23.       su $SRCDS_USER -l -c "screen -d -m -S $NAME $DAEMON $PARAMS"
  24.     else
  25.       echo "No such directory: $DIR!"
  26.     fi
  27.   ;;
  28.  
  29.   stop)
  30.     if screen -ls |grep $NAME; then
  31.       echo -n "Stopping $DESC: $NAME"
  32.       kill `screen -ls |grep $NAME |awk -F . '{print $1}'|awk '{print $1}'`
  33.       echo " ... done."
  34.     else
  35.       echo "Couldn't find a running $DESC"
  36.     fi
  37.   ;;
  38.  
  39.   restart)
  40.     if screen -ls |grep $NAME; then
  41.       echo -n "Stopping $DESC: $NAME"
  42.       kill `screen -ls |grep $NAME |awk -F . '{print $1}'|awk '{print $1}'`
  43.       echo " ... done."
  44.     else
  45.       echo "Couldn't find a running $DESC"
  46.     fi
  47.     echo -n "Starting $DESC: $NAME"
  48.     cd $DIR
  49.     screen -d -m -S $NAME $DAEMON $PARAMS
  50.     echo " ... done."
  51.   ;;
  52.  
  53.   status)
  54.     # Check whether there's a "srcds" process
  55.     ps aux | grep -v grep | grep srcds_r > /dev/null
  56.     CHECK=$?
  57.     [ $CHECK -eq 0 ] && echo "SRCDS is UP" || echo "SRCDS is DOWN"
  58.   ;;
  59.  
  60.   *)
  61.     echo "Usage: $0 {start|stop|status|restart}"
  62.     exit 1
  63.   ;;
  64.  
  65. esac
  66. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement