The Unreal Admins Page - Forums

The Unreal Admins Page - Forums (https://unrealadmin.org/forums/index.php)
-   UT3 Server - Linux Specific (https://unrealadmin.org/forums/forumdisplay.php?f=195)
-   -   UT3 Start/stop script (https://unrealadmin.org/forums/showthread.php?t=26685)

skully 19th December, 2007 04:00 PM

UT3 Start/stop script
 
Hey all,

dont know if anyone used the 2k4 version but here is my script adjusted for UT3 linux dedicated servers.

Direct links You can use wget to get them directly to your box
- Script
Command: wget http://aria.dominating.nl/ut-admin/ut3/ut3ss

- Install/Help
Command: wget http://aria.dominating.nl/ut-admin/ut3/INSTALL

Package
- Script+install/help
Command: wget http://aria.dominating.nl/ut-admin/ut3/ut3ss.tar.gz
Unpack: tar -xzf ut3ss.tar.gz

What it can do
Commandline options
- start, this starts the server in background. All server output goes into logfile
- stop, this stops the running server
- restart, this restarts the running server
- check, this checks if the server is running and gives online or offline back
- status, this checks if the server is running and if not restart the server
- debug, this starts the server but wont background the process. All server output
will be showed on screen. To stop hit CTRL+C (this kills the running server!).

Note: There was a line in the INSTALL file that said that it was not possible to run 2 servers from 1 dir.. That is a lie. Just make sure you use different logfiles and pids for each instance

Have fun and if there are comments they can be places here. There is also an irc channel and forum listed in the script for support.

Issues:
- Double spaces in gameopt makes in impossible to stop the server [fixed]

Download files are updated version 0.4.1

For people that dont want to redownload the files here is the fix IF you had problems with multiple spaces.

After this line:
realbin="./ut3-bin"

Add this line:
gameopt=`echo ${gameopt}| sed s/"[ ]\{2,\}"/" "/g`

This will remove all extra spaces in the gameopt.

Regards.

optarix12 19th December, 2007 05:15 PM

Brilliant! :D

---Mike

skully 19th December, 2007 05:26 PM

Thanks,

i live on these replies ;)

You got it working then i asume?

Regards

LODEEP 19th December, 2007 07:17 PM

BIG THXZ

i was looking for 1... THUMBS UP

edit:

Starting goes fine, stopping doesn't

Stopping Clan UT3 dedicated server: server not running or crashed.

(debian)

basedir="/home/serverut3/ut3-dedicated"
gamename="Clan UT3"
gamebin="Binaries/ut3"
gamepid="${basedir}/ut3.pid"
gamelog="${basedir}/ut3.log"
gameopt="server DM-Deck?MinPlayblablablabla

skully 20th December, 2007 12:53 PM

Hey Lodeep,

do you got awk installed?

You can use this command to check it. No result is not installed
dpkg -l |grep awk

If its not installed
apt-get install mawk

Other reason that might be the problem is that you changed the startup line (gameopt) once it was running. So, you start it.. Change the options, and then try to stop it. The checks in the script sees it as a different server and wont stop it because its not there. Because the server is started by the ut3 bin its hard to get a descent pid of the actual start of ut3-bin without modifying the ut3 file. By using the pid only its possible to start multiple servers with the same settings if you or someone delete the pid file. Thats not a good idea so thats why i use this method.

If you want to edit the line stop the server first, then edit and then start it again.

Kremlin 20th December, 2007 03:24 PM

Quote:

Originally Posted by LODEEP (Post 135986)
BIG THXZ

Starting goes fine, stopping doesn't

Stopping Clan UT3 dedicated server: server not running or crashed.

(debian)

gameopt="server DM-Deck?MinPlayblablablabla


Got the same prob here.

Anyways, good job :thumbup: many thanks :D

LODEEP 20th December, 2007 04:10 PM

dpkg -l |grep awk
ii mawk 1.3.3-11 a pattern scanning and text processing langu

and i didn't change the line's when server was running

everyone 20th December, 2007 06:36 PM

^^
 
Running OpenSuSE 10.1....

Script is very well !!! :thumbup:

Art_illery 20th December, 2007 07:51 PM

Try implementing this method i use in my Server Startscripts. This way, you should be able to get the right pid at anytime, no matter if the PID changed due to some restarting of the Server or anything like that:
Code:

check() {
        # Ueberprueft den Server
        # 0 = Server ist offline
        # 1 = Server ist online
        # 2 = Server befindet sich gerade in einer Update Prozedur (Muss noch eingebaut werden in die check()-Funktion

        # Ermitteln der PIDs des Scripts und der Serverbinary mittels pgrep
                pgrep -f -u ${CSS_UNIXUSER} srcds_[^r].*port.${CSS_NETPORT} > ${CSS_SERVERPIDFILE}
                pgrep -f -u ${CSS_UNIXUSER} srcds_run.*port.${CSS_NETPORT} > ${CSS_PIDFILE}

        # Prüfen ob pgrep valide Daten in die .pid dateien geschrieben hat
      serverpid=`cat ${CSS_SERVERPIDFILE}`
                scriptpid=`cat ${CSS_PIDFILE}`
      if [ -n "${scriptpid}" -o "${serverpid}" ]
      then
                        status=1
      else
                        status=0
                        rm $CSS_PIDFILE
                        rm $CSS_SERVERPIDFILE
      fi
}

This is only the check() - Function of a CS-Source Serverscript i wrote, and the comments are in German, sorry for that, but if you have some bash scripting experience you should be able to figure out the way this is working.

Basically what i am doing is getting the full command line of the process, then look at the ports that are used in the commandline and distinguish the different Serverprocesses by the ports they are running on. This would mean, you would always have to put the Port-option into your commandline. But that isn´t really a big issue i think ;o)
Let me know what you think, and if you can use it to some extend. If not, no problem, I just thought i might give you a little alternative way of querying the running Serverprocesses ;o)

skully 20th December, 2007 08:00 PM

Hey Art_illery,

thx for your reply i will look into this. And yeah is easy to understand and i know some german so it will be ok :)

For the ones having problems,

can you send the ut3ss file to me thru mail ( info at dominating.nl ) with a problem description. I will test it and fix it when needed. Remove gamespy id/pass.

Make sure you use a proper editor like VIM or Notepad++ under windows if you are editing it. Dos editors like Wordpad can make the file corrupt.

skully 20th December, 2007 08:16 PM

Just had a file and this one had 2 spaces in the gameopt between 2 options. Removing one space solved the problem that it cant be stopped.

I will fix something that removes all extra spaces.

skully 20th December, 2007 08:49 PM

Issue fixed. Check 1st post for the fix

[K*T]R!GGeD 5th February, 2008 04:47 PM

i would like to try your script but i get this when i try to d/l:

--09:39:17-- http://aria.dominating.nl/ut-admin/ut3/INSTALL
Resolving aria.dominating.nl... 213.207.100.54
Connecting to aria.dominating.nl|213.207.100.54|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
09:39:20 ERROR 403: Forbidden.


is this intentional?

skully 5th February, 2008 04:51 PM

Sorry,

edited some files a bit too hard. Fixed now

Asmodan 23rd February, 2008 12:53 PM

It's working fine for me - 2.6.23-gentoo-r8

:-)

Stalker729 23rd February, 2009 01:18 PM

Ty m8 - will try it. ;) CentOS 5.2


All times are GMT +1. The time now is 11:18 PM.

 


All pages are copyright The Unreal Admins Page.
You may not copy any pages without our express permission.