LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices


Reply
  Search this Thread
Old 10-18-2005, 01:44 AM   #1
a03gudhi
LQ Newbie
 
Registered: Oct 2005
Posts: 2

Rep: Reputation: 0
Starting a game server at startup


I'm trying to have Fedora start my COD game server at startup. The thing is I can only log in to the machine using ssh, and that's why I want the server to be started before I log in.
I've written a VERY basic bash script that starts the server with the parameters needed.
Code:
#!/bin/bash 

echo "Starting Call Of Duty: United Offensive....."
./coduo_lnxded +dedicated 2 +exec dedicated.cfg &

exit 0
(The working directory is /home/name/codserver/ )
(Any improvements on the script would be appreciated

The thing is that I have no idea where to put this script in order for it to run when the computer runs.
 
Old 10-18-2005, 04:13 AM   #2
Dr_P_Ross
Member
 
Registered: Nov 2003
Location: Edinburgh, UK
Distribution: Arch
Posts: 43

Rep: Reputation: 18
There are (at least) two ways to do what you want. The simple way is to add commands to the file /etc/rc.d/rc.local
(or /etc/rc.local, which is normally just a link to /etc/rc.d/rc.local); commands in this file get executed at the end of the startup process.

A better way is to treat your program like any other server process, and not only consider graceful startup but also graceful shutdown. Look at xfs, the font server as a fairly simple model. First, look at the executable script file /etc/rc.d/init.d/xfs; it can be called with any of the arguments 'start', 'stop', 'restart' or 'status' and these are handled by the case command. The script makes use of various functions defined in the file 'functions', such as gprintf which handles the translation of messages into other languages (by lookup rather than by advanced linguistic abilities!). There are links to this script in various companion directories:
/etc/rc.d/rc0.d/K10xfs
/etc/rc.d/rc1.d/K10xfs
/etc/rc.d/rc2.d/S20xfs
/etc/rc.d/rc3.d/S20xfs
...and so on...
The digit after the rc in rcN.d refers to a particular runlevel (look at /etc/inittab to see what runlevels are about), the various
scripts in /etc/rcN.d/ are executed when the system enters that runlevel. Scripts named Snn* are startup scripts, executed in alphabetic order so lower nn means executed sooner, and are called with argument 'start'; scripts named Knn* are shutdown (K for kill) scripts, called with the argument 'stop'. Whenever the system enters runlevel N it first runs the Knn* scripts and then runs the Snn* scripts for that runlevel -- look at the script /etc/rc, which is responsible for doing this. And read the man page for init. Also read the man page for chkconfig, a tool that makes it simple to create/delete the links referred to above. You'll
see the lines consulted by chkconfig in the xfs script.

Please don't try to mess with system scripts such as /etc/rc, you can very easily end up with an unmaintainable system -- eg,
even if you get it right, you find yourself upgrading your system to a more recent version of Linux in a few months time, and you forget about those idiosyncratic changes you made, and wonder why your game server no longer starts or stops gracefully. And if you get it wrong by messing with the system scripts, you can get your system into a truly awful mess.

All the best,

Peter R
 
Old 10-18-2005, 04:17 PM   #3
a03gudhi
LQ Newbie
 
Registered: Oct 2005
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks a lot....
Finally got it working after editing the rc.local file.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with StepMania-game starting.. CleFish Linux - Games 4 12-26-2008 08:54 PM
starting jabber server at startup lawadm1 Linux - Software 0 09-29-2004 09:55 PM
Game server at startup/boot pavalosv Linux - Games 2 08-05-2004 06:28 PM
game not receving game list from master server Rnastyracer Linux - Games 2 04-02-2004 10:20 PM
GLX visual errors while starting a game w0lv3rin3 Linux - Software 0 03-07-2004 12:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora

All times are GMT -5. The time now is 11:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration