[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Running scripts at startup on fedora core 4

Posted on 2006-03-24
16
Medium Priority
?
376 Views
Last Modified: 2013-12-06
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
0
Comment
Question by:mindlessacts
  • 5
  • 5
  • 3
  • +1
16 Comments
 
LVL 14

Expert Comment

by:ppfoong
ID: 16286717

Yes.

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

0
 

Author Comment

by:mindlessacts
ID: 16286948
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
 
LVL 27

Expert Comment

by:Nopius
ID: 16287194
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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 17

Expert Comment

by:Dushan De Silva
ID: 16287347

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
 

Author Comment

by:mindlessacts
ID: 16290867
Still a little confused, I will try to read that link when I have time. Thanks for the quick responses. -brad
0
 
LVL 27

Expert Comment

by:Nopius
ID: 16296842
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
 

Author Comment

by:mindlessacts
ID: 16296979
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
 
LVL 27

Expert Comment

by:Nopius
ID: 16297103
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
 

Author Comment

by:mindlessacts
ID: 16307291
anyone?? sorry Im just not too good at this. A step by step would be great!
0
 
LVL 27

Expert Comment

by:Nopius
ID: 16307456
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
 
LVL 14

Expert Comment

by:ppfoong
ID: 16307534

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
 
LVL 27

Expert Comment

by:Nopius
ID: 16307557
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
 
LVL 14

Accepted Solution

by:
ppfoong earned 2000 total points
ID: 16307577

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
 
LVL 17

Expert Comment

by:Dushan De Silva
ID: 16458810
Great mindlessacts !
I think same I have suggested initially. Anyway I didn't had much time to expalain it.

BR Dushan
0
 

Author Comment

by:mindlessacts
ID: 16458963
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
 
LVL 17

Expert Comment

by:Dushan De Silva
ID: 16459023
No Worries mindlessacts !

BR Dushan
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question