Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
07-26-2004, 09:29 PM
|
#1
|
|
Member
Registered: Jul 2003
Location: Pennsylvainia
Distribution: Slackware / Debian / *Ubuntu / Opensuse / Solaris uname: Brian Cooney
Posts: 503
Rep:
|
Automatically start a game server when system boots
We are setting up a gameserver that is going to be colocated in a closet off-site.
Normally to start the server:
Sombody has to:
log in as "Gameserver" with the password
cd to the game dir: cd hlds_l
run the script to start the game: screen -S hlds ./hlds_run -game cstrike +map de_dust +maxplayers 26
Does anybody know where I can find info on how to make this all happen automatically, so all the guy at the server colo has to do is plug it in, turn it on, and the server will start?
|
|
|
|
07-27-2004, 12:30 AM
|
#2
|
|
Member
Registered: Aug 2003
Location: Portland, Oregon
Distribution: RedHat, Libranet
Posts: 438
Rep:
|
You can probably use an /etc/inittab entry to do this.
set your default init level to 3 (networking enabled, no X)
id:3:initdefault
set your script to auto restart itself doing something like (see the inittab man page for details):
GS:3:respawn:/home/Gameerver/hlds_l/hlds_run -game cstrike +map de_dust +maxplayers 26
|
|
|
|
07-27-2004, 01:41 AM
|
#3
|
|
Guru
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,817
|
You would usually put something like that in your systems boot scripts.
|
|
|
|
07-27-2004, 03:07 AM
|
#4
|
|
Member
Registered: Jul 2003
Location: Pennsylvainia
Distribution: Slackware / Debian / *Ubuntu / Opensuse / Solaris uname: Brian Cooney
Posts: 503
Original Poster
Rep:
|
ok: a couple of thoughts.
I got it working by adding these lines to rc.M echo
=======================
echo Entering HLDS directory
cd /home/gameserver/steam/
echo Trying to start HLDS
./hlds_run -game cstrike +map de_dust +maxplayers 21 &
========================
This works, but its a bit sloppy. Any text sent to the game's console pops into the login screen console, and it doesnt give me a way to actually log into the server console.
I also cant join the server... It runs, but the clients wont connect. They start to try, but it dies. NFI why.
It would be better If I could start the server as the user "gameserver" in a screen session, so I could log into it from console. It would also be nice if the process would respawn if it died.
Ideas friendly hackers?
Edit: another improtant tidbit: hlds gets pissed if you dont cd to its directory before you run it. Running it with a full path make it crash, cding to its dir and then running it make it happy. so any script would need to cd, then run it.
Last edited by Kahless; 07-27-2004 at 03:15 AM.
|
|
|
|
07-27-2004, 11:01 AM
|
#5
|
|
Member
Registered: Aug 2003
Location: Portland, Oregon
Distribution: RedHat, Libranet
Posts: 438
Rep:
|
I suggested the inittab approach instead of an rc script to address the respawning issue.
It sounds like you are going to have use an Expect script to launch this.
|
|
|
|
07-28-2004, 02:56 AM
|
#6
|
|
Member
Registered: Jul 2003
Location: Pennsylvainia
Distribution: Slackware / Debian / *Ubuntu / Opensuse / Solaris uname: Brian Cooney
Posts: 503
Original Poster
Rep:
|
Bump?
I tried your initab thing, and i tried running it from rc.local and rc.M All had the same result.
The server runs, but it wont allow clients to connect. Clients see it, but they cant connect to it.
Isnt there a way to tell the computer to automactically run a few commands as a certain user at boot time, without that user needing to log in to make it happen?
ffs. Its gotta be do-able.
|
|
|
|
08-01-2004, 01:23 AM
|
#7
|
|
LQ Newbie
Registered: Aug 2004
Posts: 2
Rep:
|
I'm having the same issure. I've been messing around with scripts to try to make HLDS start in screen automatically so that I can SSH to the server and view the HLDS console. If anyone can tell me how to do this it would be great. What I Kahless and I need is for HLDS_run to automatically start in a screen session so we can connect to it later. I have been using Linux for about a week now and don't know anything about scripting and stuff so I have no idea if I've done any of it right.  Here's what I've done...
Created a file in /home/hlds called hook with these lines:
Code:
#!/bin/sh
su hlds
cd /home/hlds/hlds_hook
screen -dmS hook -X ./hlds_run...yadda yadda with the rest of the HLDS switches
HLDS is installed in /home/hlds/hlds_hook and hlds_run will re-start the server if it crashes. What seems to happen is that it switches user to hlds and sits at a command prompt without continuing with any of the other lines. I've tried several variations of that script with varying results but no luck. It seems to me that if I can make this script work from the command line when logged in as root, that I can add it to rc.local and have it run when the system boots up.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 04:39 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|