<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://hlds.pl/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl">
		<id>http://hlds.pl/index.php?action=history&amp;feed=atom&amp;title=SRCDS-Start_Stop_Restart</id>
		<title>SRCDS-Start Stop Restart - Historia wersji</title>
		<link rel="self" type="application/atom+xml" href="http://hlds.pl/index.php?action=history&amp;feed=atom&amp;title=SRCDS-Start_Stop_Restart"/>
		<link rel="alternate" type="text/html" href="http://hlds.pl/index.php?title=SRCDS-Start_Stop_Restart&amp;action=history"/>
		<updated>2026-04-18T06:26:54Z</updated>
		<subtitle>Historia wersji tej strony wiki</subtitle>
		<generator>MediaWiki 1.18.1</generator>

	<entry>
		<id>http://hlds.pl/index.php?title=SRCDS-Start_Stop_Restart&amp;diff=8197&amp;oldid=prev</id>
		<title>Trawiator o 21:39, 17 maj 2008</title>
		<link rel="alternate" type="text/html" href="http://hlds.pl/index.php?title=SRCDS-Start_Stop_Restart&amp;diff=8197&amp;oldid=prev"/>
				<updated>2008-05-17T21:39:31Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← poprzednia wersja&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Wersja z 21:39, 17 maj 2008&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Linia 172:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Linia 172:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;DSPORT='27015';&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;  # Game server listens on this UDP port&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;DSPORT='27015';&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;  # Game server listens on this UDP port&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;DSSIZE='21';&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; # Maximum number of players to allow&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;DSSIZE='21';&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; # Maximum number of players to allow&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;DSUSER=&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;`&lt;/del&gt;whoami&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;`&lt;/del&gt;;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;  # Which user is running the process&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;DSUSER=&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'&lt;/ins&gt;whoami&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'&lt;/ins&gt;;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;  # Which user is running the process&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wiki-wiki:diff:version:1.11a:oldid:7552:newid:8197 --&gt;
&lt;/table&gt;</summary>
		<author><name>Trawiator</name></author>	</entry>

	<entry>
		<id>http://hlds.pl/index.php?title=SRCDS-Start_Stop_Restart&amp;diff=7552&amp;oldid=prev</id>
		<title>Trawiator o 21:01, 17 gru 2007</title>
		<link rel="alternate" type="text/html" href="http://hlds.pl/index.php?title=SRCDS-Start_Stop_Restart&amp;diff=7552&amp;oldid=prev"/>
				<updated>2007-12-17T21:01:02Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Nowa strona&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{linuxonly}}&lt;br /&gt;
* startscript&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
# Start/stop/restart a Valve dedicated server&lt;br /&gt;
# All configuration changes should occur in &amp;lt;scriptname&amp;gt;.conf. Only change the name of the call below if you are using a different name for the script&lt;br /&gt;
. ./startscript.conf&lt;br /&gt;
&lt;br /&gt;
service_start() {&lt;br /&gt;
&lt;br /&gt;
# Checking to see if root is the current user you are using to start the script&lt;br /&gt;
if [ $DSUSER == 'root' ]; then&lt;br /&gt;
# Oops is caught you running as root shame on you &amp;gt;:). Well you gotta tell it yes or no.	&lt;br /&gt;
	echo -e &amp;quot;You are currently running as $DSUSER, This is dangerous and should be avoided\nAre you sure you want to do this? (yes or no please):&amp;quot;&lt;br /&gt;
	read&lt;br /&gt;
	case &amp;quot;$REPLY&amp;quot; in&lt;br /&gt;
	yes)&lt;br /&gt;
# Looks like you chose to run it as root... The script hates you for it but hey do whatever you feel hehe&lt;br /&gt;
		echo -e &amp;quot;Alright proceeding running program as $DSUSER&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Currently checking to see if the pid files that is creates during the startup process exsist. If neither exsists it will go ahead.&lt;br /&gt;
		if [ ! -f $DSPATH/$DSNAME.pid ] &amp;amp;&amp;amp; [ ! -f $DSPATH/dod/$DSNAMESHORT.pid ]; then&lt;br /&gt;
			if [ -x $DSPATH/$DSNAME ]; then&lt;br /&gt;
				echo &amp;quot;Starting $TITLE: Services&amp;quot;&lt;br /&gt;
				cd $DSPATH; $DSINTERFACE $DSPATH/$DSNAME $DSOPTS&lt;br /&gt;
				sleep 1 # prevent race condition on SMP kernels&lt;br /&gt;
				ps -ef | grep SCREEN | grep &amp;quot;$CLIENT&amp;quot; | grep -v grep | awk '{ print $2 }' &amp;gt; $DSNAME.pid # Finding and writing current process id of the screen process&lt;br /&gt;
				echo -e &amp;quot;$DSNAMESHORT Process ID Written to $DSNAME.pid\n$DSGAME Server Process ID Written to $DSNAMESHORT.pid&amp;quot;&lt;br /&gt;
			fi&lt;br /&gt;
		else&lt;br /&gt;
			echo -e &amp;quot;Server is Already running you sure you want to start this up?&amp;quot; # It found that one of the pid files exsists perhaps the server did not shut down with the script being used... if this is the case use &amp;lt;scriptname&amp;gt; clean to fix it&lt;br /&gt;
		fi&lt;br /&gt;
	;;&lt;br /&gt;
	no)&lt;br /&gt;
# Good choice you did not choose to run as root&lt;br /&gt;
		echo -e &amp;quot;Wise choice please login as a different user or run this with su - &amp;lt;username&amp;gt; -c 'command'. &amp;quot;&lt;br /&gt;
	;;&lt;br /&gt;
	*)&lt;br /&gt;
# What in the heck is wrong with you didn't I say YES or NO&lt;br /&gt;
		echo -e &amp;quot;I don't recognize $REPLY as a valid yes or no answer. Please user only yes or no only&amp;quot;&lt;br /&gt;
	;;&lt;br /&gt;
	esac&lt;br /&gt;
# The script found you were not running as root so it is running like normal. Uses same calls to activate script like above just no input is require to start it this time. You should not be prompted for yes or no if yo uare not root running it this time&lt;br /&gt;
else&lt;br /&gt;
		if [ ! -f $DSPATH/$DSNAME.pid ] &amp;amp;&amp;amp; [ ! -f $DSPATH/$DSNAMESHORT.pid ]; then&lt;br /&gt;
			if [ -x $DSPATH/$DSNAME ]; then&lt;br /&gt;
				echo &amp;quot;Starting $TITLE: Services&amp;quot;&lt;br /&gt;
				echo &amp;quot;$DSPATH/$DSNAME $DSOPTS&amp;quot;&lt;br /&gt;
				cd $DSPATH; $DSINTERFACE $DSPATH/$DSNAME $DSOPTS&lt;br /&gt;
				sleep 1 # prevent race condition on SMP kernels&lt;br /&gt;
				ps -ef | grep SCREEN | grep &amp;quot;$CLIENT&amp;quot; | grep -v grep | awk '{ print $2 }' &amp;gt; $DSNAME.pid&lt;br /&gt;
				echo -e &amp;quot;$DSNAME Process ID Written to $DSNAME.pid\n$DSNAMESHORT Server Process ID Written to $DSNAMESHORT.pid&amp;quot;&lt;br /&gt;
			fi&lt;br /&gt;
		else&lt;br /&gt;
			echo -e &amp;quot;Server is Already running you sure you want to start this up?&amp;quot;&lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
	&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
service_stop() {&lt;br /&gt;
&lt;br /&gt;
# This script is just getting the process id of the server that was written to the file it created earlier so it can kill it.   &lt;br /&gt;
    for vdspid in $(cat $DSPATH/$DSNAME.pid);&lt;br /&gt;
      do&lt;br /&gt;
        kill $vdspid;&lt;br /&gt;
	rm -rf $DSNAME.pid;&lt;br /&gt;
        break;&lt;br /&gt;
    done&lt;br /&gt;
    rm -rf $DSPATH/dod/$DSNAMESHORT.pid;&lt;br /&gt;
# This command is just clearing out any *DEAD* screen sessions. Those can become a pain really quick&lt;br /&gt;
    screen -wipe 1&amp;gt; /dev/null 2&amp;gt; /dev/null&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
service_restart() {&lt;br /&gt;
&lt;br /&gt;
# Simple enough. It is making a call to the stop service and then it waits for a second then it calls the start script&lt;br /&gt;
&lt;br /&gt;
  service_stop&lt;br /&gt;
  sleep 1&lt;br /&gt;
  service_start&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
service_status() {&lt;br /&gt;
# This is checking to see if $DSNAME.pid file exsists&lt;br /&gt;
if [ -f $DSPATH/$DSNAME.pid ]; then&lt;br /&gt;
# Pulling in the values to evaulate if they are true or not&lt;br /&gt;
PROCESSRUN=`cat $DSPATH/$DSNAME.pid`&lt;br /&gt;
PROCSERV=`ps -ef | grep SCREEN | grep &amp;quot;$CLIENT&amp;quot; | grep -v grep | awk '{ print $2 }'`&lt;br /&gt;
&lt;br /&gt;
# This is checking to see if the currently running process ID matches with the pid created when the server was started&lt;br /&gt;
	if [ &amp;quot;$PROCESSRUN&amp;quot; == &amp;quot;$PROCSERV&amp;quot; ]; then&lt;br /&gt;
	echo -e &amp;quot;$DSNAME is running on process `cat $DSPATH/$DSNAME.pid`\n&amp;quot; # It found this process ID matches and is outputting what it is currently running on&lt;br /&gt;
	fi&lt;br /&gt;
else&lt;br /&gt;
	echo -e &amp;quot;$DSNAME is offline. This could be due to someone or something else that killed it.&amp;quot; # Apparently the server is offline &lt;br /&gt;
			if [ &amp;quot;$PROCSERV&amp;quot; ]; then&lt;br /&gt;
			echo -e &amp;quot;However a Process Matching the same criteria was found at process ID $PROCSERV....\n Might be worth a investigation&amp;quot; # Wait, it found another server matching the same criteria running under a different process ID.&lt;br /&gt;
			fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#Checking to see if this file exsists&lt;br /&gt;
&lt;br /&gt;
if [ -f $DSPATH/$DSNAME.pid ]; then&lt;br /&gt;
echo &amp;quot;$DSNAMESHORT Server is running on process `cat $DSPATH/dod/$DSNAMESHORT.pid`&amp;quot; # It found the file exsists and is outputting the info&lt;br /&gt;
else &lt;br /&gt;
echo -e &amp;quot;$DSGAME Server is offline. This could be due to someone or something else that killed it\nor it is just rebooting&amp;quot; #Oops the server is active or the pid file got deleted.&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# This service is used watch the process that is currently running&lt;br /&gt;
service_watch(){&lt;br /&gt;
&lt;br /&gt;
# Check if there is someone already attached&lt;br /&gt;
&lt;br /&gt;
if [ `screen -wipe | grep $CLIENT | grep -v grep | awk '{ print $2 }'` == '(Attached)' ]; then&lt;br /&gt;
	echo -e &amp;quot;Someone is already attached to the console of the server.\n Might want to check who&amp;quot; # Oops someone is already attached to it..... better wait your turn or go chew someone $%^ out&lt;br /&gt;
else&lt;br /&gt;
&lt;br /&gt;
# Looks like noone is watching it right now.... peeping tom time !!!&lt;br /&gt;
&lt;br /&gt;
	screen -r $CLIENT &lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# This service is used to clean house if the script is reporting erroneous info.&lt;br /&gt;
&lt;br /&gt;
service_clean(){&lt;br /&gt;
&lt;br /&gt;
rm -rf *.pid;&lt;br /&gt;
rm -rf $DSPATH/dod/*.pid;&lt;br /&gt;
screen -wipe 1&amp;gt; /dev/null 2&amp;gt; /dev/null;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
case &amp;quot;$1&amp;quot; in&lt;br /&gt;
'start')&lt;br /&gt;
  service_start&lt;br /&gt;
  ;;&lt;br /&gt;
'stop')&lt;br /&gt;
  service_stop&lt;br /&gt;
  ;;&lt;br /&gt;
'restart')&lt;br /&gt;
  service_restart&lt;br /&gt;
  ;;&lt;br /&gt;
'status')&lt;br /&gt;
  service_status&lt;br /&gt;
  ;;&lt;br /&gt;
'watch')&lt;br /&gt;
  service_watch&lt;br /&gt;
  ;;&lt;br /&gt;
'clean')&lt;br /&gt;
  service_clean&lt;br /&gt;
  ;;&lt;br /&gt;
*)&lt;br /&gt;
  echo &amp;quot;usage $0 start|stop|restart|status|watch|clean&amp;quot;&lt;br /&gt;
esac&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
* startscript.conf&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
CLIENT='test';                # Unique handle this server uses. Hostname&lt;br /&gt;
                              # can be reset in your server.cfg&lt;br /&gt;
&lt;br /&gt;
TITLE='Test Script';          # Name that is shown during start-up messages&lt;br /&gt;
DSPATH='/home/gameserver/hldss/dods';    # Where Steam is installed&lt;br /&gt;
DSIP='70.85.36.186';		# IP address you want to use to start server with&lt;br /&gt;
DSNAME='srcds_run';           # Either hlds_run or srcds_run&lt;br /&gt;
DSNAMESHORT='source';		# Label only&lt;br /&gt;
DSGAME='dod';               # Game type (valve, cstrike, czero, etc)&lt;br /&gt;
DSIMAP='dod_donner';             # Load this map initially&lt;br /&gt;
DSPORT='27015';               # Game server listens on this UDP port&lt;br /&gt;
DSSIZE='21';                  # Maximum number of players to allow&lt;br /&gt;
DSUSER=`whoami`;             # Which user is running the process&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Don't edit this unless you need the script to do something special&lt;br /&gt;
DSOPTS=&amp;quot;-game $DSGAME +hostname \&amp;quot;$CLIENT\&amp;quot; +map $DSIMAP +ip $DSIP -port $DSPORT -autoupdate +maxplayers $DSSIZE -pidfile $DSNAMESHORT.pid&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This is the caller for the screen process. Only change if this is different from where your screen process currently resides.&lt;br /&gt;
DSINTERFACE=&amp;quot;/usr/bin/screen -A -m -d -S $CLIENT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Kategoria:SRCDS]]&lt;br /&gt;
[[Kategoria:Linux]]&lt;br /&gt;
[[Kategoria:Serwery gier]]&lt;br /&gt;
[[Kategoria:skróty]]&lt;br /&gt;
[[Kategoria:Skrypty]]&lt;/div&gt;</summary>
		<author><name>Trawiator</name></author>	</entry>

	</feed>