LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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

Reply
 
LinkBack Search this Thread
Old 07-26-2004, 09:29 PM   #1
Kahless
Member
 
Registered: Jul 2003
Location: Pennsylvainia
Distribution: Slackware / Debian / *Ubuntu / Opensuse / Solaris uname: Brian Cooney
Posts: 503

Rep: Reputation: 30
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?
 
Old 07-27-2004, 12:30 AM   #2
idaho
Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: RedHat, Libranet
Posts: 438

Rep: Reputation: 30
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
 
Old 07-27-2004, 01:41 AM   #3
MS3FGX
Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,850

Rep: Reputation: 350Reputation: 350Reputation: 350Reputation: 350
You would usually put something like that in your systems boot scripts.
 
Old 07-27-2004, 03:07 AM   #4
Kahless
Member
 
Registered: Jul 2003
Location: Pennsylvainia
Distribution: Slackware / Debian / *Ubuntu / Opensuse / Solaris uname: Brian Cooney
Posts: 503

Original Poster
Rep: Reputation: 30
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.
 
Old 07-27-2004, 11:01 AM   #5
idaho
Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: RedHat, Libranet
Posts: 438

Rep: Reputation: 30
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.
 
Old 07-28-2004, 02:56 AM   #6
Kahless
Member
 
Registered: Jul 2003
Location: Pennsylvainia
Distribution: Slackware / Debian / *Ubuntu / Opensuse / Solaris uname: Brian Cooney
Posts: 503

Original Poster
Rep: Reputation: 30
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.
 
Old 08-01-2004, 01:23 AM   #7
floop
LQ Newbie
 
Registered: Aug 2004
Posts: 2

Rep: Reputation: 0
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Start a server automatically? timmyk0 Linux - General 8 06-24-2006 02:58 AM
Disable Start-Up Sound as system boots up jwhibdon Suse/Novell 12 12-09-2005 05:03 PM
Start game server at boottime. jp_ Slackware 8 10-10-2005 01:51 PM
how to start automatically apache server when boot-up? eye Linux - Software 7 10-28-2003 01:22 PM
Start Apache when system boots up eweborg Linux - General 1 03-05-2002 12:37 AM


All times are GMT -5. The time now is 01:48 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration