Running scripts at startup on fedora core 4

Hi I run a game server company, and the other day I had a HUGE problem, that I dont want to ever face again. Problem is, it could happen anytime so I really need some help.

My server that I run in Michigan, crashed. And all the game servers on it went down. The problem is, when the server went back up, the game servers did not. So I had to manually go into every server, and restart them up. Using the command line:

'screen -A -m -d -S hlds ./hlds_run -game cstrike +maxplayers 12 +map de_dust2 +port 27015 +sys_ticrate 333 +fps_max 125 +ip 63.216.32.52 -autoupdate'


Is there anyway to run this at server bootup, its not that its hard to do it manually, but if Im not around, my customers go hours without a server. So any help would be GREATLY appreciated. Thank you all in advanced! -Brad
mindlessactsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ppfoongCommented:

Yes.

Append the command to be run into the script file /etc/rc.d/rc.local

0
mindlessactsAuthor Commented:
So If I wanted to run the script:

"screen -A -m -d -S hlds ./hlds_run -game cstrike +maxplayers 12 +map de_dust2 +port 27015 +sys_ticrate 333 +fps_max 125 +ip 63.216.32.52 -autoupdate"

And I wanted to run it for the user 'brad' in the directory 'hlds', how would I do that. I just dont understand how to run the script in specific places. Thanks for the help, look forward to a response. Thanks! -Brad


0
NopiusCommented:
I where an admin of HalfLife server (game.primorye.ru) about 4 years ago
and there where _exactly_ the same problem :)

Yes, it requires some dances around screen. You also need .screenrc file in user directory.
Read this post: http://www.mail-archive.com/hlds_linux@list.valvesoftware.com/msg16399.html

And DONT forget to include 'detach' as last line of your screenrc. That's importent. Else your 'Linux startup procedure' will never gets control back.

Create something like /home/brad/my_startup_script.sh:
/home/brad/hlds_run -game cstrike +maxplayers 12 +map de_dust2 +port 27015 +sys_ticrate 333 +fps_max 125 +ip 63.216.32.52 -autoupdate"

Your rc.local file will look like:
su brad -c /usr/bin/screen -c /home/brad/.screenrc -S hlds /home/brad/my_startup_script.sh

Your /home/brad/.screenrc:
miltiuser on
detach

If something will go wrong, let me know. It was 4 years ago, I can miss something.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Dushan De SilvaTechnology ArchitectCommented:

Let say you have have that your game program at /opt/games/ .


And Edit file in /etc/rc.d/rc.local
Then add follwing lines to the end of the script.

----------------------------------------------------------------------------
cd /opt/games/
'screen -A -m -d -S hlds ./hlds_run -game cstrike +maxplayers 12 +map de_dust2 +port 27015 +sys_ticrate 333 +fps_max 125 +ip 63.216.32.52 -autoupdate'

-----------------------------------------------------------------------------

BR Dushan
0
mindlessactsAuthor Commented:
Still a little confused, I will try to read that link when I have time. Thanks for the quick responses. -brad
0
NopiusCommented:
mindlessacts, you are confused of what?

first question: do you have a root access to the machin where you are running hlds?
If yes, fix your /etc/rc.d/rc.local
If not, there is completely another solution (none of them was mentioned above).

here are references:
man inittab (execution of machine startup scripts begins from inittab)
man screen
0
mindlessactsAuthor Commented:
Yes I do have root access. Im just still confused. Ok I will give a perfect example of what I need to do. Ok I have about 12 users per machine. Brad, Chase, Ryan, Tom, ect. They are all located in the home directory. For each of these I go into the directory hlds_l, by using cd hlds_l. Then I run this command line:

'screen -A -m -d -S hlds ./hlds_run -game cstrike +maxplayers 12 +map de_dust2 +port 27015 +sys_ticrate 333 +fps_max 125 +ip 63.216.32.52 -autoupdate'


 How would I set that up for all my users?

Thanks -Brad
0
NopiusCommented:
What exactly do you need to setup for all users?
Running HalfLife server? It's not needed, server will be started only once from only one user.
Running HalfLife client? It's also a problematic for all users because 'client' is a graphical application and cannot be run in 'screen'
Administering HalfLife server once it has been started? Yes, it can be done via screen command and 'multiuser' mode, without fixing rc.local file.
0
mindlessactsAuthor Commented:
anyone?? sorry Im just not too good at this. A step by step would be great!
0
NopiusCommented:
mindlessacts, please give more details on your problem to get a step-by-step instraction.
I still don't understand what the problem is and what do you want to get as a result.
0
ppfoongCommented:

Create a shell script like this, lets call it myscript.sh and put it in /opt directory:

#!/bin/sh
screen -A -m -d -S hlds /home/$1/hlds_run -game cstrike +maxplayers 12 +map de_dust2 +port 27015 +sys_ticrate 333 +fps_max 125 +ip 63.216.32.52 -autoupdate


Issue the command "chmod 755 myscript.sh".

Then in rc.local file:

/opt/myscript.sh Brad
/opt/myscript.sh Chase
/opt/myscript.sh Ryan
/opt/myscript.sh Tom
.....

0
NopiusCommented:
ppfoong, what happens in boot time with this rc.local script?
First script will start half life server with user root priveledges from Bred's homedir.

Second and others will fail because they will not be able to bind port 27015
That's probably not that mindlessacts wants.
0
ppfoongCommented:

I don't play Halflife and just suggest according to his requirement. If that is the case, make the port a second parameter, becomes:


#!/bin/sh
screen -A -m -d -S hlds /home/$1/hlds_run -game cstrike +maxplayers 12 +map de_dust2 +port $2 +sys_ticrate 333 +fps_max 125 +ip 63.216.32.52 -autoupdate


In rc.local file:

opt/myscript.sh Brad 27015
/opt/myscript.sh Chase 27016
/opt/myscript.sh Ryan 27017
/opt/myscript.sh Tom 27018
.....

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dushan De SilvaTechnology ArchitectCommented:
Great mindlessacts !
I think same I have suggested initially. Anyway I didn't had much time to expalain it.

BR Dushan
0
mindlessactsAuthor Commented:
o wow,  I'm truly sorry, I just noticed that I had an open question, and remember following those guidelines, I should have split the points. My apologies, I owe you one.

0
Dushan De SilvaTechnology ArchitectCommented:
No Worries mindlessacts !

BR Dushan
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Distributions

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.