This repository has been archived by the owner on Dec 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
srcds-daemon
66 lines (56 loc) · 2.26 KB
/
srcds-daemon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
# replace <newuser> with the user you created above
SRCDS_USER="srcds"
# Do not change this path
PATH=/bin:/usr/bin:/sbin:/usr/sbin
# The path to the game you want to host. example = /home/newuser/dod
DIR=/mnt/tf2-mge
DAEMON=$DIR/srcds_run
# Change all PARAMS to your needs.
PARAMS="-game tf -port 20715 +map mge_training_v8_beta4b +sv_pure 2 +tv_enable 0 +tv_port 20730 -maxplayers 26 -autoupdate -steam_dir /mnt/steamcmd -steamcmd_script /mnt/steamcmd/tf2-mge.cfg +sv_shutdown_timeout_minutes 5"
NAME=SRCDS
DESC="source dedicated server"
case "$1" in
start)
echo "Starting $DESC: $NAME"
if [ -e $DIR ]; then
cd $DIR
su $SRCDS_USER -l -c "screen -d -m -S $NAME $DAEMON $PARAMS"
else
echo "No such directory: $DIR!"
fi
;;
stop)
if su $SRCDS_USER -l -c "screen -ls" |grep $NAME; then
echo -n "Stopping $DESC: $NAME"
kill `su $SRCDS_USER -l -c "screen -ls" |grep $NAME |awk -F . '{print $1}'|awk '{print $1}'`
echo " ... done."
else
echo "Couldn't find a running $DESC"
fi
;;
restart)
if su $SRCDS_USER -l -c "screen -ls" |grep $NAME; then
echo -n "Stopping $DESC: $NAME"
kill `su $SRCDS_USER -l -c "screen -ls" |grep $NAME |awk -F . '{print $1}'|awk '{print $1}'`
echo " ... done."
else
echo "Couldn't find a running $DESC"
fi
echo -n "Starting $DESC: $NAME"
cd $DIR
su $SRCDS_USER -l -c "screen -d -m -S $NAME $DAEMON $PARAMS"
echo " ... done."
;;
status)
# Check whether there's a "srcds" process
ps aux | grep -v grep | grep srcds_r > /dev/null
CHECK=$?
[ $CHECK -eq 0 ] && echo "SRCDS is UP" || echo "SRCDS is DOWN"
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
exit 0