As Jesse pointed out attachments aren't allowed on the list, so here
it is inline. Indenting and linewrapping will probably screw it up,
but you're smart people so you'll figure it out ;-)

#!/bin/bash

## Set umask to give replay files the correct permissions
umask 0022

## Set the shell to evaluate patterns case-insensitive
shopt -s nocasematch

## First locate the screen program
SCREEN=`which screen`

## Determine where on the filesystem we are
BASE_DIR=`pwd`
SERVER_BIN="$BASE_DIR/srcds_linux"
SERVER_SCRIPT="$BASE_DIR/srcds_run"
DEFAULT_PORT="27015" ## This is the default SRCDS port

PS3="Please choose a gamemode from the list: "

## Some extra options we want to pass on to the server
OPTIONS="-replay -nohltv" # -strictportbind"

## Check if the SRCDS binary actually exists
## and is executable for the current user
if [[ ! -x ${SERVER_BIN} ]] && [[ ! -x ${SERVER_SCRIPT} ]]
    then
echo "SRCDS installation missing or not executable, exiting"
exit 1
fi

gamemenu () {
case ${gamemode} in
ar*)
GAMEMODE=arena
;;
a*d*|att*)
GAMEMODE=ad
;;
c*t*f*)
GAMEMODE=ctf
;;
c*p*)
GAMEMODE=cp
;;
k*o*t*h*)
GAMEMODE=koth
;;
m*v*m*|m*u*)
GAMEMODE=mvm
;;
p*l*)
GAMEMODE=pl
;;
s*d*)
GAMEMODE=sd
;;
ha*|ev*)
GAMEMODE=halloween
;;
*)
GAMEMODE=vanilla
;;
esac
}

## Start the gamemode specified on the command line or as a user selection
if [[ -z $1 ]]
    then
echo "Possible gamemodes on this server are:"
# select gamemode in arena attack-defend capture-the-flag
controlpoints king-of-the-hill mann-vs-machine payload
special-delivery halloween vanilla
select gamemode in "Arena" "Attack/Defend" "Capture the Flag" "Control \
Points" "King of the Hill" "Mann vs. Machine" "Payload" "Special \
Delivery" "Halloween" "Vanilla"
do gamemenu
   break
done
    else
gamemode=$1
gamemenu
fi

## Autoupdate defaults to NO, since we don't want multiple update
## processes running on the server installation at the same time.
## Autoupdate also prevents the PID file from being removed properly
## at server shutdown because of the automatic restart.
echo -n "Update the server before starting? [y/N]: "
read -n 1 -s -t 3 update
update=${update:=no}
echo ${update}

if [[ "$update" == y* ]] #|| [[ -z "$update" ]]
    then
OPTIONS="-autoupdate $OPTIONS"
fi

## We want to check for running instances, select an available portnumber,
## then add the -replayserverdir $port variable so replays won't overwrite
## eachother, and also register a unique server ID with the master servers
## and put logs in a seperate folder for each running instance
port=${DEFAULT_PORT}

while [ -e ${BASE_DIR}/${port}.pid ]
    do
port=$((${port} + 10 ))
done

## Check if there is an identity file for the server instance we're about
## to start and print a warning if it doesn't
if [ ! -r ${BASE_DIR}/tf/cfg/server_${port}.cfg ]
    then
echo "Server identity file not found, configuration"
echo "is not optimal for Quickplay matchmaking"
CONFIGFILE=server.cfg
    else
CONFIGFILE=server_${port}.cfg
fi

echo "Starting the server ${SERVER_SCRIPT}
  on port ${port} in 5 seconds, last chance to abort by pressing CTRL-C"
sleep 5

## Reset the shell to evaluate patterns case-sensitive again
shopt -u nocasematch

$SCREEN -A -U -d -m -S tf2-${port}-${GAMEMODE} -t TeamFortress2 \
${SERVER_SCRIPT} ${OPTIONS} -port ${port} -pidfile \
${BASE_DIR}/${port}.pid -replayserverdir ${port} +servercfgfile \
${CONFIGFILE} +exec ${GAMEMODE}.cfg +randommap

On Mon, Feb 11, 2013 at 11:23 PM, Jesse Molina <je...@opendreams.net> wrote:
>
> No attachments allowed.  Use pastbin and share your script that way.
>
>
>
>
> Rudy Bleeker wrote:
>>
>> I've attached the bash script that I've used and improved upon for
>> years now to start my TF2 servers. It assumes there's a servercfgfile
>> named server_<portnumber>.cfg that contains the settings specific for
>> that instance, for example your server identity and logdir. It starts
>> the first server on port 27015 and works it's way up in increments of
>> 10.
>>
>> Using the -strictportbind option just makes the server quit (and
>> restart over and over if autoupdate is set) if one or more of the
>> ports it wants to use is unavailable, instead of just picking a higher
>> portnumber. For that reason I stopped using it, since I let the server
>> assign all other ports by itself.
>>
>> If anyone has any comments, questions or suggestions about my script
>> feel free to ask.
>>
>> On Sun, Feb 10, 2013 at 6:11 AM, Landon Orr <lando...@gmail.com> wrote:
>>>
>>> Alright, so I've disabled sourcetv and set the client port, that seems to
>>> have cleared it up. I'm working on a script that will start multiple
>>> servers, and have the server's ports be in intervals of 5. Here's the
>>> command I'm using to start them, it's been working great so far but let
>>> me
>>> know if you guys have any suggestions.
>>>
>>> ./srcds_run -game tf -autoupdate -steambin /home/tf2user/hlds/steam
>>> -maxplayers 32 -port 27015 -nohltv +clientport 27115 +map mvm_coaltown
>>> +servercfgfile mvmserver1.cfg +motdfile mvmmotd.txt +mapcyclefile
>>> mvmmapcycle.txt
>>>
>>> I specify the maplist, mapcycle and motd files as I have different
>>> configs
>>> for MvM.
>>>
>>>
>>>
>>> On Sat, Feb 9, 2013 at 10:06 PM, Nomaan Ahmad <n0man....@gmail.com>
>>> wrote:
>>>
>>>> You can put it in the startup like: +tv_port 27021
>>>>
>>>> On 10 February 2013 04:49, Sam White <s...@zamnet.co.uk> wrote:
>>>>
>>>>> I believe it's tv_port
>>>>>
>>>>> On 10 February 2013 04:15, Joel Zhang <know.thine.en...@gmail.com>
>>>>
>>>> wrote:
>>>>>
>>>>>
>>>>>> I am pretty sure there is a parameter for changing source TV's port as
>>>>>> well, but I can't remember offhand which.
>>>>>> On Feb 9, 2013 7:25 PM, "[BT]Black V" <bt.bla...@gmail.com> wrote:
>>>>>>
>>>>>>> Isn't there a strict port command too?
>>>>>>> On 10 Feb 2013 15:47, "Andreas Grimm" <l...@gmx.net> wrote:
>>>>>>>
>>>>>>>> You can add "-nohltv" to your start parameters if you don't use
>>>>>
>>>>> source
>>>>>>>
>>>>>>> tv.
>>>>>>>>
>>>>>>>> Then the gameserver doesn't bind additional ports.
>>>>>>>>
>>>>>>>>   - Andreas
>>>>>>>>
>>>>>>>> -----Original Message-----
>>>>>>>> From: hlds_linux-boun...@list.valvesoftware.com
>>>>>>>> [mailto:hlds_linux-boun...@list.valvesoftware.com] On Behalf Of
>>>>>
>>>>> Steve
>>>>>>>>
>>>>>>>> Dudenhoeffer
>>>>>>>> Sent: Sunday, February 10, 2013 3:38 AM
>>>>>>>> To: Half-Life dedicated Linux server mailing list
>>>>>>>> Subject: Re: [hlds_linux] Overlapping port usage when running
>>>>>
>>>>> multiple
>>>>>>>>
>>>>>>>> servers on one machine
>>>>>>>>
>>>>>>>> tv_port defaults to 27020
>>>>>>>>
>>>>>>>> On Sat, Feb 9, 2013 at 9:17 PM, Giovanni Harting <
>>>>>>>> chefeification...@gmail.com> wrote:
>>>>>>>>
>>>>>>>>> There are some port that the game tries to bound automaticly,
>>>>
>>>> maybe
>>>>>>>
>>>>>>> there
>>>>>>>>>
>>>>>>>>> are some cvars to control that ....
>>>>>>>>>
>>>>>>>>> For all command line specific, look here:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>> https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicat
>>>>>>>>
>>>>>>>> ed_Server
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> 2013/2/10 Landon Orr <lando...@gmail.com>
>>>>>>>>>
>>>>>>>>>> So that specified one of the ports, however when I run the
>>>>>
>>>>> server,
>>>>>>>
>>>>>>> it's
>>>>>>>>>>
>>>>>>>>>> still trying to use 27020, which is in use. Is it possible to
>>>>>>
>>>>>> specify
>>>>>>>>>
>>>>>>>>> that
>>>>>>>>>>
>>>>>>>>>> one as well?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Sat, Feb 9, 2013 at 7:03 PM, Joel Zhang <
>>>>>>>
>>>>>>> know.thine.en...@gmail.com
>>>>>>>>>>>
>>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> The parameter is "-port 27025", for example.
>>>>>>>>>>> On Feb 9, 2013 6:00 PM, "Landon Orr" <lando...@gmail.com>
>>>>>
>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> Currently I'm trying to host multiple servers on one
>>>>
>>>> machine.
>>>>>>>
>>>>>>> It's
>>>>>>>>
>>>>>>>> a
>>>>>>>>>>
>>>>>>>>>> very
>>>>>>>>>>>>
>>>>>>>>>>>> beefy machine, two 16-core AMD processors and 64 gigs of
>>>>>>
>>>>>> memory,
>>>>>>>
>>>>>>> so
>>>>>>>>>
>>>>>>>>> I'd
>>>>>>>>>>>>
>>>>>>>>>>>> like to run quite a bit of servers, 30+ if possible.
>>>>
>>>> However,
>>>>>>
>>>>>> I'm
>>>>>>>>>>
>>>>>>>>>> running
>>>>>>>>>>>>
>>>>>>>>>>>> into an issue when I spin up more than fiver servers or so.
>>>>>>
>>>>>> Right
>>>>>>>>
>>>>>>>> now
>>>>>>>>>>
>>>>>>>>>> I'm
>>>>>>>>>>>>
>>>>>>>>>>>> having issues with ports overlapping, as in the servers try
>>>>>
>>>>> to
>>>>>>>>>
>>>>>>>>> request
>>>>>>>>>>
>>>>>>>>>> a
>>>>>>>>>>>>
>>>>>>>>>>>> port but it's already in use. For the first five they would
>>>>>>
>>>>>> just
>>>>>>>>
>>>>>>>> use
>>>>>>>>>>
>>>>>>>>>> the
>>>>>>>>>>>>
>>>>>>>>>>>> next port up. However, it seems that a server uses two
>>>>
>>>> ports
>>>>>>>>
>>>>>>>> (correct
>>>>>>>>>>
>>>>>>>>>> me
>>>>>>>>>>>
>>>>>>>>>>> if
>>>>>>>>>>>>
>>>>>>>>>>>> I'm wrong) 27015 and 27020. After five servers, the next
>>>>>
>>>>> server
>>>>>>>>
>>>>>>>> tries
>>>>>>>>>>
>>>>>>>>>> to
>>>>>>>>>>>>
>>>>>>>>>>>> use 27015, it's in use so it tries 27020 and then it gives
>>>>>
>>>>> up.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> I know when you use the srcds_run command, there is a way
>>>>
>>>> to
>>>>>>>>
>>>>>>>> specify
>>>>>>>>>>
>>>>>>>>>> the
>>>>>>>>>>>>
>>>>>>>>>>>> port to use, but I can't remember the command. Also, how
>>>>
>>>> many
>>>>>>>
>>>>>>> ports
>>>>>>>>>
>>>>>>>>> do
>>>>>>>>>>
>>>>>>>>>> I
>>>>>>>>>>>>
>>>>>>>>>>>> have to specify? Just two, or are there more than that?
>>>>>>>>>>>> _______________________________________________
>>>>>>>>>>>> To unsubscribe, edit your list preferences, or view the
>>>>
>>>> list
>>>>>>>>>
>>>>>>>>> archives,
>>>>>>>>>>>>
>>>>>>>>>>>> please visit:
>>>>>>>>>>>>
>>>>>>> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlds_linux
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>> _______________________________________________
>>>>>>>>>>> To unsubscribe, edit your list preferences, or view the list
>>>>>>>>
>>>>>>>> archives,
>>>>>>>>>>>
>>>>>>>>>>> please visit:
>>>>>>>>>>>
>>>>>> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlds_linux
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> _______________________________________________
>>>>>>>>>> To unsubscribe, edit your list preferences, or view the list
>>>>>>>
>>>>>>> archives,
>>>>>>>>>>
>>>>>>>>>> please visit:
>>>>>>>>>>
>>>>> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlds_linux
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> To unsubscribe, edit your list preferences, or view the list
>>>>>>
>>>>>> archives,
>>>>>>>>>
>>>>>>>>> please visit:
>>>>>>>>>
>>>> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlds_linux
>>>>>>>>>
>>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> To unsubscribe, edit your list preferences, or view the list
>>>>>
>>>>> archives,
>>>>>>>>
>>>>>>>> please visit:
>>>>>>>> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlds_linux
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> To unsubscribe, edit your list preferences, or view the list
>>>>>
>>>>> archives,
>>>>>>>>
>>>>>>>> please visit:
>>>>>>>> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlds_linux
>>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> To unsubscribe, edit your list preferences, or view the list
>>>>
>>>> archives,
>>>>>>>
>>>>>>> please visit:
>>>>>>> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlds_linux
>>>>>>>
>>>>>> _______________________________________________
>>>>>> To unsubscribe, edit your list preferences, or view the list archives,
>>>>>> please visit:
>>>>>> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlds_linux
>>>>>>
>>>>> _______________________________________________
>>>>> To unsubscribe, edit your list preferences, or view the list archives,
>>>>> please visit:
>>>>> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlds_linux
>>>>>
>>>> _______________________________________________
>>>> To unsubscribe, edit your list preferences, or view the list archives,
>>>> please visit:
>>>> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlds_linux
>>>>
>>> _______________________________________________
>>> To unsubscribe, edit your list preferences, or view the list archives,
>>> please visit:
>>> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlds_linux
>>
>>
>>
>>
>> --
>> Idleness is not doing nothing. Idleness is being free to do anything.
>>    - Floyd Dell
>>
>>
>>
>> _______________________________________________
>> To unsubscribe, edit your list preferences, or view the list archives,
>> please visit:
>> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlds_linux
>>
>
> --
> # Jesse Molina
> # Mail = je...@opendreams.net
> # Cell = 1-602-323-7608
>
>
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlds_linux



--
Idleness is not doing nothing. Idleness is being free to do anything.
  - Floyd Dell

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlds_linux

Reply via email to