/[svn]/linux scripts/hlds
ViewVC logotype

Contents of /linux scripts/hlds

Parent Directory Parent Directory | Revision Log Revision Log


Revision 54 - (show annotations) (download)
Thu Aug 18 21:31:14 2011 UTC (7 years, 3 months ago) by cstrike
File size: 2987 byte(s)
Removed outdated comment
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
25 ################################################################################
26 . /lib/lsb/init-functions
27
28 ##### You can change these variables #####
29 # If you're not running Debian/Ubuntu, the next line may need to be changed
30 ID=/usr/bin/id;
31 HLDS_PATH=/usr/local/hlds;
32 HLDS_PID=hlds.pid;
33 HLDS_USER=cs;
34 ##### Don't change anything below here #####
35
36 start_hlds() {
37 log_action_begin_msg "Starting hlds"
38
39 #Make sure old hlds isn't running because they fight for same ip:port
40 killall -q hlds_run
41 if [ -f $HLDS_PATH/$HLDS_PID ] && [ -r $HLDS_PATH/$HLDS_PID ]; then
42 read hpid < $HLDS_PATH/$HLDS_PID
43 kill -TERM $hpid >/dev/null 2>&1
44 fi
45
46 #Allow full core dumps for debugging purposes
47 ulimit -c unlimited
48
49 #Run as correct user
50 if [ "`$ID -u`" == "0" ]; then
51 # stdout and stderr to /dev/null
52 su - $HLDS_USER -c /home/$HLDS_USER/hlds_startup.sh >/dev/null 2>&1
53 else
54 /home/$HLDS_USER/hlds_startup.sh >/dev/null 2>&1
55 fi
56 log_action_end_msg $?
57 }
58
59 stop_hlds() {
60 log_action_begin_msg "Stopping hlds_run"
61 killall -q hlds_run
62 log_action_end_msg $?
63
64 log_action_begin_msg "Stopping steam"
65 killall -q steam
66 log_action_end_msg $?
67
68 log_action_begin_msg "Stopping hlds"
69 if [ ! -f $HLDS_PATH/$HLDS_PID ]; then
70 log_action_end_msg 1 # Fail
71 log_failure_msg "$HLDS_PID not found. (Are you sure hlds is running?)"
72 return
73 elif [ ! -r $HLDS_PATH/$HLDS_PID ]; then
74 log_action_end_msg 1 # Fail
75 log_failure_msg "Unable to read $HLDS_PID. (Are you the correct user?)"
76 return
77 fi
78 read hpid < $HLDS_PATH/$HLDS_PID
79 kill -TERM $hpid >/dev/null 2>&1
80 log_action_end_msg $?
81
82 if [ ! -f /proc/$hpid/exe ]; then # If not running,
83 rm -f $HLDS_PATH/$HLDS_PID # Delete the pid file
84 fi
85 }
86
87
88 case "$1" in
89 start)
90 start_hlds
91 ;;
92 stop)
93 stop_hlds
94 ;;
95 restart)
96 stop_hlds
97 log_action_begin_msg "Sleeping"
98 sleep 2
99 log_action_end_msg $?
100 start_hlds
101 ;;
102 *)
103 echo "usage: $0 {start|stop|restart}"
104 esac

Contact webmaster
ViewVC Help
Powered by ViewVC RSS 2.0 feed