TMN on linux "autostart"

This is the place where you can find everything related to the dedicated server, control scripts and community tools.

Moderators: Pit Crew, TM-Patrol

ming
smooth traffic navigator
smooth traffic navigator
Posts: 260
Joined: 04 Dec 2006 11:10
Owned TM-games: all
Manialink(s): redlion, ming

Re: TMN on linux "autostart"

Post by ming » 27 Nov 2008 09:15

i run all my tm server and record scripts through webmin.
since i need to reboot my server at least once a day, this fits my needs quite well.

i created 2 tiny startup scripts, one for the server and one for aseco (both can also be combined into one file) and added those in the "scheduled cron jobs" in webmin

tm-server.sh:

Code: Select all

#!/bin/sh
sleep 5
cd /home/gamesrv/tm/united
./TrackmaniaServer /game=united /dedicated_cfg=dedicated_cfg.txt /game_settings=rasp-tracklist.txt /internet 
echo "tm united started"
aseco.sh:

Code: Select all

#!/bin/sh
sleep 10
cd /home/gamesrv/tm/united/xaseco
./xaseco.sh
echo "united aseco started"
but dont forget to add some more sleeptime in the aseco startscript to make sure your tm server is already running, otherwise aseco wont be able to connect to it.
you should also create a new user on your box, to avoid running those processes as root!

you can either let them boot with the server, or give them a specific time to start.
check and/or kill the process under the "running processes" tab.

hope this is useful to some people ;)

cheers
Manialink: mingcolor>

Luxembourg's TM-community website: www.trackmania.lu

User avatar
k4nm4n
smooth traffic navigator
smooth traffic navigator
Posts: 262
Joined: 11 Feb 2008 10:30
Owned TM-games: TMUF
Location: Slovenia
Contact:

Re: TMN on linux "autostart"

Post by k4nm4n » 30 Nov 2008 09:24

Can someone tell me why i get this when i try to start XAseco: /home/k4nm4n/tmf/xaseco/Aseco.sh: 2: php: not found
I have LAMP installed on Ubuntu Desktop

nouseforname
swift roadking
swift roadking
Posts: 840
Joined: 20 Apr 2008 08:58
Owned TM-games: TMUF,TMNF, TMN
Manialink(s): therookies
Location: Germany
Contact:

Re: TMN on linux "autostart"

Post by nouseforname » 30 Nov 2008 09:43

k4nm4n wrote:Can someone tell me why i get this when i try to start XAseco: /home/k4nm4n/tmf/xaseco/Aseco.sh: 2: php: not found
I have LAMP installed on Ubuntu Desktop

looks like the path to the php executing file is wrong.
should be more like this:

Code: Select all

/opt/lampp/bin/php Aseco.php
Owner of the Rookie servers and some more. :)
Rookies HP
My Project
Rookies Manialinkcolor>

User avatar
k4nm4n
smooth traffic navigator
smooth traffic navigator
Posts: 262
Joined: 11 Feb 2008 10:30
Owned TM-games: TMUF
Location: Slovenia
Contact:

Re: TMN on linux "autostart"

Post by k4nm4n » 30 Nov 2008 10:10

nouseforname wrote: looks like the path to the php executing file is wrong.
should be more like this:

Code: Select all

/opt/lampp/bin/php Aseco.php
OPT folder is empty and i don't know what to write inside Aseco.sh file :(
Is this right? I just changed the path to xaseco folder. Before was cd /home/tmf/xaseco

Code: Select all

cd /home/k4nm4n/tmf/xaseco
php aseco.php TMN </dev/null >aseco.log 2>&1 &
echo $!

nouseforname
swift roadking
swift roadking
Posts: 840
Joined: 20 Apr 2008 08:58
Owned TM-games: TMUF,TMNF, TMN
Manialink(s): therookies
Location: Germany
Contact:

Re: TMN on linux "autostart"

Post by nouseforname » 30 Nov 2008 11:02

k4nm4n wrote: Is this right? I just changed the path to xaseco folder. Before was cd /home/tmf/xaseco

Code: Select all

cd /home/k4nm4n/tmf/xaseco
php aseco.php TMN </dev/null >aseco.log 2>&1 &
echo $!

no. the path inside the aseco.sh should be the path to the php executing. the file itself (aseco.sh) must be inside the aseco dir.
in my case, i use xampp, the content of aseco.sh is:

Code: Select all

/opt/lampp/bin/php Aseco.php TMU </dev/null >aseco.log 2>&1 &
echo $!
this part must be the path to the php executing

Code: Select all

/opt/lampp/bin/php
i dont know where it is at your system.
Owner of the Rookie servers and some more. :)
Rookies HP
My Project
Rookies Manialinkcolor>

User avatar
k4nm4n
smooth traffic navigator
smooth traffic navigator
Posts: 262
Joined: 11 Feb 2008 10:30
Owned TM-games: TMUF
Location: Slovenia
Contact:

Re: TMN on linux "autostart"

Post by k4nm4n » 30 Nov 2008 12:40

The Lampp in Ubuntu doesn't have the php executable file and i don't know why. I figured out that is missing because I run the old TrackManiaServer in a Box and there is the executable file with the link php. I'll try to look on Ubuntu forums for the solution. tnx :(

User avatar
k4nm4n
smooth traffic navigator
smooth traffic navigator
Posts: 262
Joined: 11 Feb 2008 10:30
Owned TM-games: TMUF
Location: Slovenia
Contact:

Re: TMN on linux "autostart"

Post by k4nm4n » 30 Nov 2008 13:07

Tnx for your help again, I found the solution here: LINK :thumbsup:

penguisher
pedestrian
pedestrian
Posts: 12
Joined: 15 Oct 2009 15:11
Owned TM-games: TMNF

Re: TMN on linux "autostart"

Post by penguisher » 16 Oct 2009 07:27

Hello,

Got a problem here.
When I try to start that script I get this error:
.: 18: Can't open /etc/rc.d/init.d/functions

my startup script is like this.

Code: Select all

#!/bin/sh
#
# Starts TMF script
#
# chkconfig: 345 94 06
# description: TMF is the TrackMania Forever server

MYDESC="penguisher"
MYPATH=/home/penguisher/TrackmaniaServer_2009-08-01
MYNAME=TM
MYPROC=TrackmaniaServerF
MYLOCK=$MYNAME
DAEMON=$MYPATH/server.sh
MYPIDF=/var/run/$MYNAME.pid
MYCMND="$MYPATH/server.sh"

# Source function library.
. /etc/rc.d/init.d/functions

# Make sure the daemon directory is in the front of the path list
PATH=$MYPATH:$PATH

# See how we were called.
case "$1" in
  start)
        # Change to package directory so config paths can be relative
        cd $MYPATH || \
          { echo "$0: Can't cd to $MYPATH" ; exit 1 ; }
        # Make sure the daemon exists
        [ -f $DAEMON ] || \
          { echo "$0: Daemon not found: $DAEMON" ; exit 1 ; }
        # See if we are already running
        # Note: kill -0 _PID_
        #       returns true if process _PID_ is alive and accepting signals.
        [ -f $MYPIDF ] && kill -0 `cat $MYPIDF` 2>/dev/null && \
          { echo "$0: $MYPIDF exists and process is running" ; exit 1 ; }
        echo -n "Starting $MYDESC: "
        echo "$MYNAME "
        su -l -c "$MYCMND" tmf | tee $MYPIDF
        PID=`sed -n 's~.*with pid=\([0-9][0-9]*\).*~\1~;/^[0-9]*$/p' $MYPIDF`
        echo $PID > $MYPIDF
        chown tmf.tm $MYPIDF
        touch /var/lock/subsys/$MYLOCK
        ;;
  stop)
        echo -n "Shutting down $MYDESC: "
        echo -n "$MYNAME "
        killproc $MYNAME
        rm -f $MYPIDF
        echo
        rm -f /var/lock/subsys/$MYLOCK
        ;;
  status)
        status $MYPROC
        ;;
  restart)
        $0 stop
        sleep 1
        $0 start
        ;;
  *)
        echo "Usage: $0 {start|stop|status|restart}"
        exit 1
esac

exit 0
And can you tell me what this line means? MYPROC=TrackmaniaServerF
I'm not familiar with startup scripts so I don't understand what the code does, I just replaced the standard directories with my own.

ferenyl
cyclist
cyclist
Posts: 37
Joined: 26 Jul 2008 13:37
Owned TM-games: tmuf

Re: TMN on linux "autostart"

Post by ferenyl » 11 Nov 2009 03:17

Xymph wrote:I belatedly discovered that the 'status' option for these scripts doesn't work, due to the fact that the startup scripts call wrapper scripts which in turn call the dedicated server and XAseco PHP system. Here are updated versions to correct that:

/home/tmf/TMF/RunTrackmaniaForever.sh :

Code: Select all

cd /home/tmf/TMF
./TrackmaniaServerF /game_settings=MatchSettings/stadium_all.txt /dedicated_cfg=dedicated_cfg.txt
/etc/init.d/tmfd :
.......
does this work on debian systems like ubuntu?

Xymph
Pit Crew
Pit Crew
Posts: 5719
Joined: 19 Aug 2007 12:58
Owned TM-games: TMN, TMU, TMF, TM²
Contact:

Re: TMN on linux "autostart"

Post by Xymph » 11 Nov 2009 11:39

ferenyl wrote:does this work on debian systems like ubuntu?
No, but this should.
Developer of XASECO for TMF/TMN ESWC & XASECO2 for TM²: see XAseco.org
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub

frank1985au
wheelbarrow operator
wheelbarrow operator
Posts: 19
Joined: 22 Nov 2009 08:45
Owned TM-games: TMUF

Re: TMN on linux "autostart"

Post by frank1985au » 03 Dec 2009 03:31

For those of us using Arch Linux, this script will do the job:

Code: Select all

#!/bin/bash
# tmf-dedi - Control the TMF Dedicated Server
#
# general config

TMF_TYPE=lan
TMF_CONF=dedicated_cfg.txt
TMF_SETTINGS=MatchSettings/Nations/NationsWhite.txt
TMF_BINDIP=""
TMF_PIDFILE=/var/run/tmf-dedi.pid
TMF_SERVNAME=TestServ
TMF_PATH=/home/tmnf/TMForever
TMF_FORCEIP=""
TMF_USER=tmnf

. /etc/conf.d/tmf-dedi
. /etc/rc.conf
. /etc/rc.d/functions

getval () {
  eval echo \$$1
}

check_conf () {
  stat_busy "Checking TMF configuration"
  case $TMF_TYPE in
    lan|internet) ;;
    *) stat_busy "TMF_TYPE may only be 'internet' or 'lan'"
       stat_die
    ;;
  esac

  for i in TMF_CONF TMF_SETTINGS TMF_PATH TMF_PIDFILE TMF_SERVNAME; do
     if [ ! "$(getval $i)" ]; then
       stat_busy "$i must have a value"
       stat_die
     fi
  done
  stat_done
}

case "$1" in
  start)
    check_conf
    stat_busy "Starting Trackmania Forever"
    if [ -s $TMF_PIDFILE ]; then
      stat_fail
      # probably ;)
      stat_busy "Trackmania Forever is already running"
      stat_die
    fi

    options="/$TMF_TYPE /dedicated_cfg=$TMF_CONF /game_settings=$TMF_SETTINGS"
    options="$options /servername=$TMF_SERVNAME"

    if [ "$TMF_BINDIP" ]; then
        options="$options /bindip=$TMF_BINDIP"
    fi
    if [ "$TMF_FORCEIP" ]; then
        options="$options /forceip=$TMF_FORCEIP"
    fi

    cd $TMF_PATH; sudo -u $TMF_USER ./TrackmaniaServer $options &>/tmp/startlog.$$

    if [ $? -ne 0 ]; then
      stat_fail
    else
      grep '^Trackmania server' /tmp/startlog.$$ | \
        sed -e 's/^.*pid=//' -e 's/ .*$//' > $TMF_PIDFILE
      rm /tmp/startlog.$$
      add_daemon tmf-dedi
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping Trackmania Forever"
    kill -TERM `cat $TMF_PIDFILE` &>/dev/null
    if [ $? -ne 0 ]; then
      stat_fail
    else
      rm $TMF_PIDFILE
      rm_daemon tmf-dedi
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  check)
    check_conf
    ;;
  *)
    echo "usage: $0 {start|stop|restart|check}"
esac
and the config file - /etc/conf.d/tmf-dedi (configured for an online server):

Code: Select all

TMF_TYPE=internet
TMF_CONF=dedicated_cfg.txt
TMF_SETTINGS=MatchSettings/Nations/NationsBlue.txt
TMF_BINDIP=""
TMF_PIDFILE=/var/run/tmf-dedi.pid
TMF_SERVNAME=TestServ
TMF_PATH=/home/tmnf/TMForever
TMF_FORCEIP=""
TMF_USER=tmnf
EDIT: You'll need to install sudo for this to work - it's not included.
MOBO: Gigabyte GA-M720-US3 AM2+
CPU: AMD Phenom X4 9750
RAM: 4GB DDR2-800
HDD: 1TB SATAII
GPU: nVidia 9600GT
NET: ADSL2+ (~6Mbit)
OS: Win 7 Pro
Image

thleeree
highway camper
highway camper
Posts: 1
Joined: 19 Jul 2011 08:46
Owned TM-games: TMU

Re: TMN on linux "autostart"

Post by thleeree » 19 Jul 2011 08:49

EDIT: You'll need to install sudo for this to work - it's not included.
that was my problem until i found it out))

Post Reply