Willkommen Gast
Du bist nicht angemeldet, um alle Funktionen des Forums zu nutzen musst du dich registrieren und anmelden. Die Registrierung ist natürlich völlig kostenlos und kann jeder Zeit wiederrufen werden.

Aktuelle Zeit: 6. Feb 2012 00:07

UT 2004 Dedicated Server Startscript

Server automatisch oder per /etc/init.d/ut2004 starten



Code: Alles auswählen
#!/bin/sh
            ###########################################################
            #                                                         #
            # Sys V init Script for Unreal Tournament 2004 dedserver  #
            #                                                         #
            # Based on the script by
            abfackeln@abfackeln.com 
                    #
            #                                                         #
            # Added some features like support of chrooted server     #
            # That's what MYLOCKFILEOUTSIDE is used for               #
            # MYPORT wase not used yet, added appropriate entry in    #
            # MYEXECMD to override .ini Settings.                     #
            #                                                         #
            # Script was modified by                                  #
            # Takayoshi Sasano <tcs@gentoo-clan.org>                  #
            # gnupg:                                                  #
            # 4817 C343 2BA5 700E 2017  C4F7 4D31 FB7D 896C 937A      #
            #                                                         #
            # Code protected by GNU/GPL                               #
            # No warranty for anything.                               #
            # If you brake your system I DON'T CARE!!!                #
            # And I WON'T FIX IT!!!                                   #
            #                                                         #
            ###########################################################
            
            # displayed name, also name of log- and lockfile
            MYNAME="2k4-CTF"
            
            # binary
            MYAPP="ucc-bin"
            
            # gametype
            MYGAME="xGame.xCTFGame"
            
            # map
            MYMAP="CTF-Orbital2"
            
            # don't even think of using root!!!
            MYUSERID="ut2004"
            
            # directory of server
            MYDIR="/home/ut2004/server/System"
            
            # gameport
            MYPORT="8500"
            
            # IP to listen on
            MYIP="192.168.0.1"
            
            # gamemods and mutators
            MYMODS="xGame.MutNoAdrenaline,xWeapons.MutNoSuperWeapon"
            
            # additional stuff
            MYEXTRAS="AdminName=admin?AdminPassword=xxxxx"
            
            # ini to use
            MYINI="UT2004_CTF.ini"
            
            # logfile
            MYLOGFILE="$MYDIR/$MYNAME.log"
            
            # lockfile
            MYLOCKFILE="$MYDIR/$MYNAME.lock"
            
            # used for chrooted servers
            MYLOCKFILEOUTSIDE="$MYDIR/$MYNAME.lock"
            
            # change this to "YES, I configured this script"
            MYCONFIG=""
            
            
            # no user servicable parts beyond this point
            
            
            TMP="$MYMAP\?Game=$MYGAME"
            
            if [ -n "$MYMODS" ]; then
            TMP="$TMP\?mutator=$MYMODS"
            fi
            
            if [ -n "$MYEXTRAS" ]; then
            TMP="$TMP\?$MYEXTRAS"
            fi
            
            if [ -n "$MYPORT" ]; then
            TMP="$TMP\?Port=$MYPORT"
            fi
            
            if [ -n "$MYIP" ]; then
            TMP="$TMP multihome=$MYIP"
            fi
            
            if [ "$MYCONFIG" != "YES, I configured this script" ]; then
            echo "###############################################"
            echo "#                                             #"
            echo "# trojan... installed                         #"
            echo "# connection to irc... established            #"
            echo "# there was a problem when starting b4ckd00r  #"
            echo "# starting anyway                             #"
            echo "# exploiting kernel... done                   #"
            echo "# System ready!                               #"
            echo "# enjoy yourself                              #"
            echo "# See h4cked.id for details                   #"
            echo "#                                             #"
            echo "# Shocked?                                    #"
            echo "#                                             #"
            echo "# Go configure your f****n stuff!!!           #"
            echo "#                                             #"
            echo "###############################################"
            exit 1
            fi
            
            if [ "$MYUSERID" = "root" ]; then
            echo "###############################################"
            echo "#                                             #"
            echo "# You were told NOT to use root, weren't you? #"
            echo "# Well, suppose you're quite stupid...        #"
            echo "# I'm NOT doing this.                         #"
            echo "# Go get a windoze box.                       #"
            echo "#                                             #"
            echo "###############################################"
            exit 1
            fi
            
            MYEXECMD="./$MYAPP server $TMP -nohomedir ini=$MYINI
            log=$MYLOGFILE"
            if [ `whoami` = "root" ]; then
            SUID="/bin/su $MYUSERID -c"
            else
            SUID=
            fi
            
            ulimit -c 0
            
            case "$1" in
            start)
            echo -n "Starting Unreal Tournament 2004: "
            if [ -f $MYLOCKFILEOUTSIDE ]; then
            echo "already running according to $MYLOCKFILEOUTSIDE. Not
            started."
            else
            cd $MYDIR
            if [ -n "$SUID" ]; then
            $SUID "$MYEXECMD > /dev/null & echo \$! > $MYLOCKFILE" >
            /dev/null &
            else
            /bin/sh -c "$MYEXECMD & echo \$! > $MYLOCKFILE" > /dev/null &
            
            fi
            echo "$MYNAME"
            fi
            ;;
            
            stop)
            echo -n "Stopping Unreal Tournament 2004: "
            if [ ! -f $MYLOCKFILEOUTSIDE ]; then
            echo "not found"
            exit 2
            fi
            kill -TERM `cat $MYLOCKFILEOUTSIDE`
            rm -f $MYLOCKFILEOUTSIDE
            echo "$MYNAME"
            ;;
            
            restart)
            if [ -f $MYLOCKFILEOUTSIDE ]; then
            $0 stop
            fi
            $0 start
            ;;
            
            check)
            ## the next condition was devised by Chris Weiss for his
            ut-check script
            ## ftp://xplug.sourceforge.net/pub/xplug/ut-check.tar.gz
            ## i have slightly modified it and integrated it here
            
            ## usage: call "ucc.init check" from a cron task every 5 minutes
            or so
            ## output will be nothing if it was running
            ## else output will be a start message and the server will
            restart
            
            if [ -z "$(ps --no-headers -p $(cat $MYLOCKFILEOUTSIDE
            2>/dev/null) 2>/dev/null)" ]; then
            $0 restart
            fi
            ;;
            
            infinity)
            ## infinite loop to ensure that server is always up without use
            of cron
            
            echo $$ > $MYLOCKFILEOUTSIDE.8
            ## the number 8 is the infinity symbol sideways icon_wink.gif
            -abf.
            
            while [ 1 ]; do
            $0 check
            sleep 60
            done
            ;;
            
            die)
            $0 stop
            
            ## break infinity
            kill -TERM `cat $MYLOCKFILEOUTSIDE.8`
            rm -f $MYLOCKFILEOUTSIDE.8
            ;;
            *)
            echo "Usage: $0 {start|stop|restart|check|infinity|die}"
            echo "Note that the last three options have to do with
            auto-recover from server crash"
            exit 1
            esac
            
            exit 0


Anmerkungen:


Lesen bevor man's einsetzt.
Anmerkungen/Verbesserungsvorschläge bitte gerne hier im Forum diskutieren.


Automatische Start- und Stoplinks bei debian setzen (Filename: /etc/init.d/ut2004):
Code: Alles auswählen
update-rc.d ut2004 defaults




Veröffentlicht am: 14. Nov 2007 12:20
von: Tobi
Artikeltyp: Script
Zugriffe: 2208
Bewertung: 5/5 (1 Bewertungen)

[ Thema anzeigen ]

Werbung



Ähnliche Artikel


Zurück zu Gameserver unter Linux