Call of duty Dedicated Server,, how to autoStart on Boot??

hello fellows , I have an Stock Server of Cod2 in linux, and I was wonder how can I make it to AutoStart the server when the computer boot’s, like a run-service ,can some one help me??

im using OpenSuse 11.0 x86_64

i found this script on internet but don’t know where to put it, nor if the lines on the script are correct.

this is the script:

#!/bin/sh -e

rc.local

This script is executed at the end of each multiuser runlevel.

Make sure that the script will “exit 0” on success or any other

value on error.

In order to enable or disable this script just change the execution

bits.

By default this script does nothing.

#Startup cod2 servers.

cd /home/larva/cod2

COD2PATH=/home/larva/cod2
COD2BIN=$COD2PATH/cod2_lnxded

su files -c “nohup $COD2BIN +set net_ip 192.168.1.137 +set dedicate 2 +exec dedicate.cfg +map_rotate >> /dev/null &”

sleep 8
rm /home/larva/.callofduty2/main/config_mp_server.cfg
exit 0

I made some changes to it. like the directory and the start line.

well I hope some one can help me.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Assuming the script just works properly copy it to /etc/init.d and then
run the following commands substituting your script name where appropriate:

#make executable:
chmod +x /etc/init.d/yourScriptName
ln -s /etc/init.d/yourScriptName /etc/init.d/rc3.d/S99yourScriptName
ln -s /etc/init.d/yourScriptName /etc/init.d/rc5.d/S99yourScriptName

Tada.

Good luck.

larva pro wrote:
> hello fellows , I have an Stock Server of Cod2 in linux, and I was
> wonder how can I make it to AutoStart the server when the computer
> boot’s, like a run-service ,can some one help me??
>
> im using OpenSuse 11.0 x86_64
>
> i found this script on internet but don’t know where to put it, nor if
> the lines on the script are correct.
>
>
> this is the script:
>
>> #!/bin/sh -e
>> #
>> # rc.local
>> #
>> # This script is executed at the end of each multiuser runlevel.
>> # Make sure that the script will “exit 0” on success or any other
>> # value on error.
>> #
>> # In order to enable or disable this script just change the execution
>> # bits.
>> #
>> # By default this script does nothing.
>>
>> #Startup cod2 servers.
>>
>>
>> cd /home/larva/cod2
>>
>> COD2PATH=/home/larva/cod2
>> COD2BIN=$COD2PATH/cod2_lnxded
>>
>> su files -c “nohup $COD2BIN +set net_ip 192.168.1.137 +set dedicate 2
>> +exec dedicate.cfg +map_rotate >> /dev/null &”
>>
>> sleep 8
>> rm /home/larva/.callofduty2/main/config_mp_server.cfg
>> exit 0
>
> I made some changes to it. like the directory and the start line.
>
> well I hope some one can help me.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIrfS83s42bA80+9kRAi2kAJ0UrNIstOwF+KXn+qDkqxVj88jzpACeK1vn
EfJ8lK1yL3LOjT6hKHaxoEI=
=PQ65
-----END PGP SIGNATURE-----

You need to fill in the metadata at the top of the script as exemplified by /etc/init.d/skeleton and to use:

insserv /etc/init.d/yourScriptName
chkconfig --set yourScriptName on

insserv will work out the correct sequencing based on the dependencies declared.

Failing to provide the dependency information means your manually created symlinks will get wiped out next time SuSEconfig runs which is usually when YaST rebuilds the config and dependencies after a package has been installed.

thanks for the answer.

im a little confuse with the S99

ok supose the name is cod2_autostart… i enter like this:

ln -s /etc/init.d/yourScriptName /etc/init.d/rc5.d/S99cod2_autostart
ln -s /etc/init.d/yourScriptName /etc/init.d/rc3.d/S99cod2_autostart

and. one more question. if theres an error on the script. how im going to see the error???

thanks.


You need to fill in the metadata at the top of the script as exemplified by /etc/init.d/skeleton and to use:

Code:

insserv /etc/init.d/yourScriptName
chkconfig --set yourScriptName on

insserv will work out the correct sequencing based on the dependencies declared.

Failing to provide the dependency information means your manually created symlinks will get wiped out next time SuSEconfig runs which is usually when YaST rebuilds the config and dependencies after a package has been installed.

sorry but how exactly do I do that,???

like this?? ::

code:
#!/bin/sh -e

rc.local

This script is executed at the end of each multiuser runlevel.

Make sure that the script will “exit 0” on success or any other

value on error.

In order to enable or disable this script just change the execution

bits.

By default this script does nothing.

#Startup cod2 servers.

insserv /etc/init.d/yourScriptName
chkconfig --set yourScriptName on

cd /home/larva/cod2

COD2PATH=/home/larva/cod2
COD2BIN=$COD2PATH/cod2_lnxded

su files -c “nohup $COD2BIN +set net_ip 192.168.1.137 +set dedicate 2 +exec dedicate.cfg +map_rotate >> /dev/null &”

sleep 8
rm /home/larva/.callofduty2/main/config_mp_server.cfg
exit 0

Look at the man page for insserv which describes the required header and then at /etc/init.d/skeleton for an example.

ok I have done everything the script now looks like this:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

#Startup cod2 servers.

### BEGIN INIT INFO
# Provides:          cod2_autoserv
# Required-Start:    $ALL
# Should-Start: $time ypbind smtp
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: auto start cod2 server
### END INIT INFO

insserv /etc/init.d/cod2_autostart
chkconfig --set cod2_autostart on

cd /home/larva/cod2

COD2PATH=/home/larva/cod2
COD2BIN=$COD2PATH/cod2_lnxded

su files -c "nohup $COD2BIN +set net_ip 192.168.1.129 +set dedicate 2 +exec dedicate.cfg +map_rotate >> /dev/null &"

sleep 8
rm /home/larva/.callofduty2/main/config_mp_server.cfg
exit 0

but I went Yast>System>System Services (runlevel)

the name of the scrip show’s there but wen I try to start the service it give me an erros.

**/etc/init.d/cod2_autostart start**returned 1 (unspecific error)

any ide?? im going to restart the pc , to see if work when boot.

insserv /etc/init.d/cod2_autostart
chkconfig --set cod2_autostart on

:slight_smile: These lines don’t go into the script. They are for you to run manually to install the script.

I can’t believed We did It

it’s not the first time I was asking this on a forum, like one year with this problem, thanks to the community for create this awesome Forum… thanks to all

thank you…

ok if some one have the same problem here how to fix it.

the script (tested and working) copy and paste to a new file. just change “larva” to you user name. and the path of the game.and “cod2_autostart” is the name of the script change it to your script file.

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

#Startup cod2 servers.

### BEGIN INIT INFO
# Provides:          cod2_autoserv
# Required-Start:    $ALL
# Should-Start: $time ypbind smtp
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: auto start cod2 server
### END INIT INFO

insserv /etc/init.d/cod2_autostart
chkconfig --set cod2_autostart on

cd /home/larva/cod2

COD2PATH=/home/larva/cod2
COD2BIN=$COD2PATH/cod2_lnxded

su larva -c "nohup $COD2BIN +set net_ip 192.168.1.129 +set dedicate 2 +exec dedicate.cfg +map_rotate >> /dev/null &"

sleep 8
rm /home/larva/.callofduty2/main/config_mp_server.cfg
exit 0

now copy the file to /etc/init.d

now make executable:
chmod +x /etc/init.d/yourScriptName

now link the files to the init’s
ln -s /etc/init.d/yourScriptName /etc/init.d/rc3.d/S99yourScriptName
ln -s /etc/init.d/yourScriptName /etc/init.d/rc5.d/S99yourScriptName

and that’s all

thanks a lot to : ken_yap … and… ab@novell.com

Wait, don’t celebrate yet, you’re not finished. :slight_smile: :frowning:

The init script is both a start script and a stop script. In fact is is also a status script and restart script and … But you should at least do the stop part. Because it will get called at shutdown time and if it behaves like a start script you will start another copy of the service only to have it killed soon.

If you look at /etc/init.d/skeleton, you are supposed to look at the first argument to see what action to take. So your code should look like this:


case $1 in
start)
    # your current code for starting the service
    ;;
stop)
    # write code to shutdown the service
    ;;
*)
    # print a message saying action not supported
    ;;
esac

And another thing you should look into is running the services as some account other than root. Services that are started at boot will start off running as the root user, unless the start script or the service changes to another account (and all the well-written services do). It’s a bad idea to run services as root unnecessarily.

your totally right, if I go to System services (runlevel). and I try to stop the service and it loops, and now it’s running twice, and yes I have to kill the services. I did the changes to the script like this:

### BEGIN INIT INFO
# Provides:          cod2_autoserv
# Required-Start:    $ALL
# Should-Start: $time ypbind smtp
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: auto start cod2 server
### END INIT INFO

cd /home/larva/cod2

COD2PATH=/home/larva/cod2
COD2BIN=$COD2PATH/cod2_lnxded

su larva -c "nohup $COD2BIN +set net_ip 192.168.1.129 +set dedicate 2 +exec dedicate.cfg +map_rotate >> /dev/null &"

sleep 8
rm /home/larva/.callofduty2/main/config_mp_server.cfg
exit 0

case "$1" in
    start)
	echo -n "Starting Cod2-server"
	## Start daemon with startproc(8). If this fails
	## the return value is set appropriately by startproc.
	/sbin/startproc $COD2BIN

	# Remember status and be verbose
	rc_status -v
	;;
    stop)
	echo -n "Shutting down cod2-server "
	## Stop daemon with killproc(8) and if this fails
	## killproc sets the return value according to LSB.

	/sbin/killproc -TERM $COD2BIN

	# Remember status and be verbose
	rc_status -v
	esac

but the problem persist. I’m not and experted on programing so I been having a little problems.

and I still looking how to change the “su” (root) to run the script but still no luck…

thanks. any idea?>?

Ok I have fix the loop of the script , now Im able to stop the service from Yast-(runlevels)…

now the script looks like this:


#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

#Startup cod2 servers.

### BEGIN INIT INFO
# Provides:          cod2_autoserv
# Required-Start:    $ALL
# Should-Start: $time ypbind smtp
# Default-Start:     3
# Default-Stop:      0 1 2 6
# Short-Description: auto start cod2 server
### END INIT INFO

cd /home/larva/cod2

COD2PATH=/home/larva/cod2
COD2BIN=$COD2PATH/cod2_lnxded

su larva -c "nohup $COD2BIN +set net_ip 192.168.1.129 +set dedicate 2 +exec dedicate.cfg +map_rotate >> /dev/null &"

sleep 8
rm /home/larva/.callofduty2/main/config_mp_server.cfg

case "$1" in
    start)
	echo -n "Starting Cod2-server"
	## Start daemon with startproc(8). If this fails
	## the return value is set appropriately by startproc.
	/sbin/startproc $COD2BIN

	# Remember status and be verbose
	rc_status -v
	;;
    stop)
	echo -n "Shutting down cod2-server "
	## Stop daemon with killproc(8) and if this fails
	## killproc sets the return value according to LSB.

	/sbin/killproc -TERM $COD2BIN
	esac
	exit 0

notice how I move the line of “exit 0” to bottom.

but now I notice one problem , the Script dont start until I log in to X11 , I have already modify the lines on the script to star the service on level 3 and also I did it on Yast (Runlevel) in expert mode. But it Just dont start on level 3 until I log in X11. Because I dont have the computer with Autologin.

any idea??? and thanks for all the advices.

Hi
You need to look at using Xvfb (X virtual frame buffer) then. Also, why
not setup a separate user (once you get it sorted) it will make things
a bit more secure.


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.0 x86 Kernel 2.6.25.11-0.1-default
up 3 days 22:23, 2 users, load average: 0.03, 0.04, 0.08
GPU GeForce 6600 TE/6200 TE - Driver Version: 173.14.12

Hi
Have a look at this thread;

http://tinyurl.com/666azw
or
http://forums.opensuse.org/applications/391511-gtk-warning-cannot-open-display-2.html


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.0 x86 Kernel 2.6.25.11-0.1-default
up 3 days 22:29, 2 users, load average: 0.21, 0.17, 0.11
GPU GeForce 6600 TE/6200 TE - Driver Version: 173.14.12

Thanks I already fix it… I set the script to run on levels 2,3,5 and now everything works perfect. now I don’t need to star X to get the script running…

And the user don’t matter because it’s a dedicated computer, so the only purpose of the computer it’s to run the server. I’m use other computer for myself, with OpenSuse too :wink:

thanks to all the team… :nerd::embarrassed::shake: