/[svn]/linux scripts/hlds
ViewVC logotype

Contents of /linux scripts/hlds

Parent Directory Parent Directory | Revision Log Revision Log


Revision 22 - (show annotations) (download)
Tue Sep 23 19:54:08 2008 UTC (15 years, 6 months ago) by cstrike
File size: 3068 byte(s)
hlds now kills steam during stop|restart
1 #!/bin/bash
2 ################################################################################
3
4 # This program is free software; you can redistribute it and/or modify it
5 # under the terms of the GNU General Public License as published by the
6 # Free Software Foundation; either version 2 of the License, or (at
7 # your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software Foundation,
16 # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18 # Unless you change the below variables, this script assumes:
19 # * Only one instance of hlds is being run
20 # * hlds is installed in /usr/local/hlds/
21 # * The Linux user "cs" exists
22 # * The Linux user "cs" owns /usr/local/hlds/
23 # * hlds_startup.sh exists in /home/cs/
24 # This script won't kill steam (run automatically when -autoupdate is specified)
25
26 ################################################################################
27 . /lib/lsb/init-functions
28
29 ##### You can change these variables #####
30 # If you're not running Debian/Ubuntu, the next line may need to be changed
31 ID=/usr/bin/id;
32 HLDS_PATH=/usr/local/hlds;
33 HLDS_PID=hlds.pid;
34 HLDS_USER=cs;
35 ##### Don't change anything below here #####
36
37 start_hlds() {
38 log_action_begin_msg "Starting hlds"
39
40 #Make sure old hlds isn't running because they fight for same ip:port
41 killall -q hlds_run
42 if [ -f $HLDS_PATH/$HLDS_PID ] && [ -r $HLDS_PATH/$HLDS_PID ]; then
43 read hpid < $HLDS_PATH/$HLDS_PID
44 kill -TERM $hpid >/dev/null 2>&1
45 fi
46
47 #Allow full core dumps for debugging purposes
48 ulimit -c unlimited
49
50 #Run as correct user
51 if [ "`$ID -u`" == "0" ]; then
52 # stdout and stderr to /dev/null
53 su - $HLDS_USER -c /home/$HLDS_USER/hlds_startup.sh >/dev/null 2>&1
54 else
55 /home/$HLDS_USER/hlds_startup.sh >/dev/null 2>&1
56 fi
57 log_action_end_msg $?
58 }
59
60 stop_hlds() {
61 log_action_begin_msg "Stopping hlds_run"
62 killall -q hlds_run
63 log_action_end_msg $?
64
65 log_action_begin_msg "Stopping steam"
66 killall -q steam
67 log_action_end_msg $?
68
69 log_action_begin_msg "Stopping hlds"
70 if [ ! -f $HLDS_PATH/$HLDS_PID ]; then
71 log_action_end_msg 1 # Fail
72 log_failure_msg "$HLDS_PID not found. (Are you sure hlds is running?)"
73 return
74 elif [ ! -r $HLDS_PATH/$HLDS_PID ]; then
75 log_action_end_msg 1 # Fail
76 log_failure_msg "Unable to read $HLDS_PID. (Are you the correct user?)"
77 return
78 fi
79 read hpid < $HLDS_PATH/$HLDS_PID
80 kill -TERM $hpid >/dev/null 2>&1
81 log_action_end_msg $?
82
83 if [ ! -f /proc/$hpid/exe ]; then # If not running,
84 rm -f $HLDS_PATH/$HLDS_PID # Delete the pid file
85 fi
86 }
87
88
89 case "$1" in
90 start)
91 start_hlds
92 ;;
93 stop)
94 stop_hlds
95 ;;
96 restart)
97 stop_hlds
98 log_action_begin_msg "Sleeping"
99 sleep 2
100 log_action_end_msg $?
101 start_hlds
102 ;;
103 *)
104 echo "usage: $0 {start|stop|restart}"
105 esac

Contact webmaster
ViewVC Help
Powered by ViewVC RSS 2.0 feed