TMN on linux "autostart"
Moderators: Pit Crew, TM-Patrol
-
- wheelbarrow operator
- Posts: 19
- Joined: 24 Nov 2006 21:44
- Owned TM-games: TMN
- Location: Sweden
- Contact:
TMN on linux "autostart"
Well tried to post this under the tech support but didn't precisly get any responce there but has anyone worked on a script for init.d on linux so it'll easily kick started when the machine is
started? Have tried to search the forum after it but unfortunetly the search function isn't taking reasoning to init.d and only want to listen to just init which returns a tad to many hits
heh.
started? Have tried to search the forum after it but unfortunetly the search function isn't taking reasoning to init.d and only want to listen to just init which returns a tad to many hits
heh.


- CavalierDeVache
- smooth traffic navigator
- Posts: 191
- Joined: 23 May 2006 23:47
- Owned TM-games: tmu tmn tms tmo
- Location: Yellowstone Valley
- Contact:
Re: TMN on linux "autostart"
It would be helpful to know what Linux distribution you are talking about since there really is no common standard as to how /init.d is laid out file system wise. The Debian way and the Redhat way are two incompatible examples
I guess if you are only interested in the game server starting automatically at boot and don't really need sys V scripts to reload, restart, etc, the easiest would be to find /rc.local on your system then edit in the full path and command to start your game server there, "/home/userdirectory/tmserverdirectory/./TrackmaniaDedicatedServer.sh". But keep in mind that this will start the game server with root ownership.
I guess if you are only interested in the game server starting automatically at boot and don't really need sys V scripts to reload, restart, etc, the easiest would be to find /rc.local on your system then edit in the full path and command to start your game server there, "/home/userdirectory/tmserverdirectory/./TrackmaniaDedicatedServer.sh". But keep in mind that this will start the game server with root ownership.
-
- wheelbarrow operator
- Posts: 19
- Joined: 24 Nov 2006 21:44
- Owned TM-games: TMN
- Location: Sweden
- Contact:
Re: TMN on linux "autostart"
I'm runing Fedora Core 6 at the moment but will in a few day perhaps upgrade to Fedora Core 7.
But of course it would be handy having things like restart in there as well as it would only be to
type that and it'd would perform it as well heh.
But of course it would be handy having things like restart in there as well as it would only be to
type that and it'd would perform it as well heh.


Re: TMN on linux "autostart"
I am running Centos 4.x, i.e. a RedHat-based distro, and have my TMN server running under a user called 'tmn' with group 'tm'. Here are my init.d scripts for starting/stopping the TMN dedicated server and the Aseco/Rasp system.
/etc/init.d/tmnd:
with /home/tmn/TMN/RunTrackmaniaNations.sh:
and /etc/init.d/aseco:
Hope it helps.
Xymph
/etc/init.d/tmnd:
Code: Select all
#!/bin/sh
#
# Starts TMN script
#
# chkconfig: 345 94 06
# description: TMN is the TrackMania Nations server
MYDESC="tmn"
MYPATH=/home/tmn/TMN
MYNAME=tmnd
MYLOCK=$MYNAME
DAEMON=$MYPATH/RunTrackmaniaNations.sh
MYPIDF=/var/run/$MYNAME.pid
MYCMND="$MYPATH/RunTrackmaniaNations.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" tmn | tee $MYPIDF
PID=`sed -n 's~.*with pid=\([0-9][0-9]*\).*~\1~;/^[0-9]*$/p' $MYPIDF`
echo $PID > $MYPIDF
chown tmn.tm $MYPIDF
touch /var/lock/subsys/$MYLOCK
;;
stop)
echo -n "Shutting down $MYDESC: "
echo -n "$MYNAME "
killproc TrackManiaServer
rm -f $MYPIDF
echo
rm -f /var/lock/subsys/$MYLOCK
;;
status)
status $MYNAME
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
esac
exit 0
Code: Select all
cd /home/tmn/TMN
./TrackManiaServer /game=nations /internet /game_settings=MatchSettings/Internet/allraces.txt /dedicated_cfg=dedicated.cfg /autoquit
Code: Select all
#!/bin/sh
#
# Starts aseco script
#
# chkconfig: 345 94 06
# description: aseco is the TMN server controller.
MYDESC="aseco"
MYPATH=/home/tmn/aseco
MYNAME=aseco
MYLOCK=$MYNAME
DAEMON=$MYPATH/Aseco.sh
MYPIDF=/var/run/$MYNAME.pid
MYCMND="$MYPATH/Aseco.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 -n "$MYNAME "
su -l -c "$MYCMND &" tmn > $MYPIDF
chown tmn.tm $MYPIDF
echo
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 $MYNAME
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
esac
exit 0
Xymph
Last edited by Xymph on 29 Jan 2008 17:13, edited 2 times in total.
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
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub
-
- wheelbarrow operator
- Posts: 19
- Joined: 24 Nov 2006 21:44
- Owned TM-games: TMN
- Location: Sweden
- Contact:
Re: TMN on linux "autostart"
*bows and salitutes*
Thank you alot for that, it's perfect and precisly what i was out after.
*does a imitational cartwheel of joy*
Thank you alot for that, it's perfect and precisly what i was out after.
*does a imitational cartwheel of joy*


-
- pedestrian
- Posts: 7
- Joined: 18 Nov 2006 09:25
- Owned TM-games: TMN,TMU,TMX,TMF
- Location: Germany
- Contact:
Re: TMN on linux "autostart"
Hey guys,
i found this thread after searching for a solution to start my tmn servers automatically. I'm not sure about that solution because i'm using Debian 4 Etch, so it won't work for me. Could anyone write this script for the Debian Way?
Thx in Advance
VaterManiaC
______
Have a look at: http://die-maniacs.de/
i found this thread after searching for a solution to start my tmn servers automatically. I'm not sure about that solution because i'm using Debian 4 Etch, so it won't work for me. Could anyone write this script for the Debian Way?
Thx in Advance
VaterManiaC
______
Have a look at: http://die-maniacs.de/
Visit Us: http://www.die-maniacs.de
-
- happy cruiser
- Posts: 136
- Joined: 18 May 2006 01:13
- Owned TM-games: TMU, TMN, TMUF, TMNF
- Location: Germany
- Contact:
Re: TMN on linux "autostart"
Hi!
Just use this script, works here on my debian server without a problem:
http://counter-strike.de/content/server/srcds
Just use this script, works here on my debian server without a problem:
http://counter-strike.de/content/server/srcds
Re: TMN on linux "autostart"
My /etc/init.d/tmnd script would not always correctly write the server's PID to the /var/run/tmnd.pid file, so I changed the way that's done in the post above.
Just a FYI.
Just a FYI.
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
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub
Re: TMN on linux "autostart"
i've modified the scripts above a bit for using tmnf & aseco (using this guide)
running on centos 5, all files chmod 755
my user+group is tmf.tmf, directory is /home/tmf/tmf and /home/tmf/aseco
/etc/init.d/tmnfd
/home/tmf/tmf/RunTrackmaniaNations.sh
/etc/init.d/aseco
works just fine 
running on centos 5, all files chmod 755
my user+group is tmf.tmf, directory is /home/tmf/tmf and /home/tmf/aseco
/etc/init.d/tmnfd
Code: Select all
MYDESC="tmf"
MYPATH=/home/tmf/tmf
MYNAME=tmnfd
MYLOCK=$MYNAME
DAEMON=$MYPATH/RunTrackmaniaNations.sh
MYPIDF=/var/run/$MYNAME.pid
MYCMND="$MYPATH/RunTrackmaniaNations.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.tmf $MYPIDF
touch /var/lock/subsys/$MYLOCK
;;
stop)
echo -n "Shutting down $MYDESC: "
echo -n "$MYNAME "
killproc TrackManiaServer
rm -f $MYPIDF
echo
rm -f /var/lock/subsys/$MYLOCK
;;
status)
status $MYNAME
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
esac
exit 0
Code: Select all
#!/bin/bash
cd /home/tmf/tmf
./TrackmaniaServer /game_settings=MatchSettings/Nations/NationsBlue.txt /dedicated_cfg=dedicated_cfg.txt
Code: Select all
#!/bin/sh
#
# Starts aseco script
#
# chkconfig: 345 94 06
# description: aseco is the TMF server controller.
MYDESC="aseco"
MYPATH=/home/tmf/aseco
MYNAME=aseco
MYLOCK=$MYNAME
DAEMON=$MYPATH/Aseco.sh
MYPIDF=/var/run/$MYNAME.pid
MYCMND="$MYPATH/Aseco.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 -n "$MYNAME "
su -l -c "$MYCMND &" tmf > $MYPIDF
chown tmf.tmf $MYPIDF
echo
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 $MYNAME
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
esac
exit 0

Re: TMN on linux "autostart"
Oh good. I did that at the start of the alpha testing but forgot to post them. Thanks.hssemichi wrote:i've modified the scripts above a bit for using tmnf & aseco (using this guide)
[...]
works just fine

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
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub
-
- happy cruiser
- Posts: 111
- Joined: 08 Jun 2006 17:17
- Owned TM-games: Orig, Sunrise, Tmnuf
- Location: East Coast (UK)
- Contact:
Re: TMN on linux "autostart"
Would these work on fedora core 8 ??
Re: TMN on linux "autostart"
Yeah, any RedHat-spinoff should work, I used them on CentOS myself, so just give them a try. Debian and FreeBSD probably require tweaks.www.22ndsas.org.uk wrote:Would these work on fedora core 8 ??
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
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub
-
- wheelbarrow operator
- Posts: 19
- Joined: 24 Nov 2006 21:44
- Owned TM-games: TMN
- Location: Sweden
- Contact:
Re: TMN on linux "autostart"
Aye i can vouch for that as well with consideration that it is Fedora 8 which my server is running on.
But as Xymph said , every RedHat spinoff should be possible to run this script as they are based
more or less on the very same code.
But as Xymph said , every RedHat spinoff should be possible to run this script as they are based
more or less on the very same code.


Re: TMN on linux "autostart"
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 :
/etc/init.d/tmfd :
/home/tmf/aseco/Aseco.sh :
/etc/init.d/asecof :
A few things are important to note:
I have the dedicated in /home/tmf/TMF with the executable renamed to TrackmaniaServerF, to distinguish it from the TMN TrackmaniaServer executable that I still have running on the same machine. You can keep the original TrackmaniaServer name in both the RunTrackmaniaForever.sh and /etc/init.d/tmfd scripts, as long as that executable name is unique (in case of running multiple TMN and/or TMF servers) and is the same in both scripts.
Similarly, both the Aseco.sh and /etc/init.d/asecof scripts refer to XAseco with "aseco.php TMF", where "TMF" serves only one purpose: identifying which "php aseco.php" script belongs to which dedicated server. Again, the "TMF" can be anything as long as it's unique and the same in both scripts, and the same goes for the "asecof" script name itself.
From that follows how to start a second TMF server on the same box, the scripts then become:
/home/tmf2/TMF/RunTrackmaniaForever.sh :
/etc/init.d/tmf2d :
/home/tmf2/aseco/Aseco.sh :
/etc/init.d/asecof2 :
/home/tmf/TMF/RunTrackmaniaForever.sh :
Code: Select all
cd /home/tmf/TMF
./TrackmaniaServerF /game_settings=MatchSettings/stadium_all.txt /dedicated_cfg=dedicated_cfg.txt
Code: Select all
#!/bin/sh
#
# Starts TMF script
#
# chkconfig: 345 94 06
# description: TMF is the TrackMania Forever server
MYDESC="tmf"
MYPATH=/home/tmf/TMF
MYNAME=tmfd
MYPROC=TrackmaniaServerF
MYLOCK=$MYNAME
DAEMON=$MYPATH/RunTrackmaniaForever.sh
MYPIDF=/var/run/$MYNAME.pid
MYCMND="$MYPATH/RunTrackmaniaForever.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
Code: Select all
cd /home/tmf/aseco
php aseco.php TMF </dev/null >aseco.log 2>&1 &
echo $!
Code: Select all
#!/bin/sh
#
# Starts asecof script
#
# chkconfig: 345 94 06
# description: asecof is the TMF server controller
MYDESC="asecof"
MYPATH=/home/tmf/aseco
MYNAME=asecof
MYPROC="aseco.php TMF"
MYLOCK=$MYNAME
DAEMON=$MYPATH/Aseco.sh
MYPIDF=/var/run/$MYNAME.pid
MYCMND="$MYPATH/Aseco.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 -n "$MYNAME "
su -l -c "$MYCMND &" tmf > $MYPIDF
chown tmf.tm $MYPIDF
echo
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)
pid=`ps ax | grep "$MYPROC\>" | grep -v grep | awk '{print $1}'`
if [ -n "$pid" ]; then
echo "$MYPROC (pid $pid) is running..."
exit 0
fi
status $MYNAME
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
esac
exit 0
I have the dedicated in /home/tmf/TMF with the executable renamed to TrackmaniaServerF, to distinguish it from the TMN TrackmaniaServer executable that I still have running on the same machine. You can keep the original TrackmaniaServer name in both the RunTrackmaniaForever.sh and /etc/init.d/tmfd scripts, as long as that executable name is unique (in case of running multiple TMN and/or TMF servers) and is the same in both scripts.
Similarly, both the Aseco.sh and /etc/init.d/asecof scripts refer to XAseco with "aseco.php TMF", where "TMF" serves only one purpose: identifying which "php aseco.php" script belongs to which dedicated server. Again, the "TMF" can be anything as long as it's unique and the same in both scripts, and the same goes for the "asecof" script name itself.
From that follows how to start a second TMF server on the same box, the scripts then become:
/home/tmf2/TMF/RunTrackmaniaForever.sh :
Code: Select all
cd /home/tmf2/TMF
./TrackmaniaServerF2 /game_settings=MatchSettings/allraces.txt /dedicated_cfg=dedicated_cfg.txt
Code: Select all
#!/bin/sh
#
# Starts TMF2 script
#
# chkconfig: 345 94 06
# description: TMF2 is the TrackMania Forever server 2
MYDESC="tmf2"
MYPATH=/home/tmf2/TMF
MYNAME=tmf2d
MYPROC=TrackmaniaServerF2
MYLOCK=$MYNAME
DAEMON=$MYPATH/RunTrackmaniaForever.sh
MYPIDF=/var/run/$MYNAME.pid
MYCMND="$MYPATH/RunTrackmaniaForever.sh"
[...same as above...]
Code: Select all
cd /home/tmf2/aseco
php aseco.php TMF2 </dev/null >aseco.log 2>&1 &
echo $!
Code: Select all
#!/bin/sh
#
# Starts asecof2 script
#
# chkconfig: 345 94 06
# description: asecof2 is the TMF server controller 2
MYDESC="asecof2"
MYPATH=/home/tmf2/aseco
MYNAME=asecof2
MYPROC="aseco.php TMF2"
MYLOCK=$MYNAME
DAEMON=$MYPATH/Aseco.sh
MYPIDF=/var/run/$MYNAME.pid
MYCMND="$MYPATH/Aseco.sh"
[...same as above...]
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
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub
Re: TMN on linux "autostart"
Status dont wok on my server !
Replace status code with
Replace status code with
Code: Select all
status)
if [ -e $MYNAME.pid ]; then
echo "the server seems to be running"
exit 0
else
echo "the server seems to be stopped"
exit 3
fi
;;