PDA

View Full Version : linux startup script


[ck]ruberducky
03-21-2009, 20:46
hey i was wondering if someone has made a script that automatically starts a counter-strike server upon computer boot.

directions on how to make this startup script would be appreciated.

*server runs on a linux OS

fysiks
03-21-2009, 22:59
I'm using Fedora Core 6 and I have a ventrilo server that I start on boot up. You just need to put the command in /etc/rc.d/rc.local (plain text file, it should exist already) and it will execute the command on startup.

But, since ventrilo has a daemon it is really simple. HLDS does not have a daemon so what I use is the program called "screen". Do you have Screen or something similar?

If so you can do something like this:

Man, put the command:get with this command.

screen -A -m -d -S cs27015 ./hlds_run -game cstrike -port 27015 +ip XXX.XXX.XXX.XXX +map de_aztec +maxplayers 26 +sys_tickrate 100 +sv_maxupdaterate 101 +exec server.cfg

With this command... is much lighter than either.

This command is more optimized.

Although, you don't need "+exec server.cfg" since it is already automatically executed.

I have not tested this on boot up though.

[ck]ruberducky
03-22-2009, 23:31
yea i dont know what exactly that is, but yes i did use screen.
i did (just in case anyone else wants this, and its in linux)

sudo emacs /etc/init.d/start_counterstrike

then in the file....

#!/bin/bash

cd /home/NAME/hlds

screen -d -m ./hlds_run -game cstrike (and so on)

yea i found that way of doing it, it will start in a detached screen. To recover it just type,

sudo screen -r

then to detach it again,

ctrl a d

then just to make it easier i changed the bios to start computer when it is connected to power (just in case the power goes out and im not home to do stuff). pretty much after doing this, you can forget about ever starting your server manually agian. its kinda like a self feeding pet :o

[ck]ruberducky
03-22-2009, 23:32
oh and what does the -A -s do

fysiks
03-23-2009, 00:07
You still had to do the rc.local stuff right?

ruberducky;786926']then just to make it easier i changed the bios to start computer when it is connected to power (just in case the power goes out and im not home to do stuff). pretty much after doing this, you can forget about ever starting your server manually agian. its kinda like a self feeding pet :o

:shock: I didn't know you could do that!

ruberducky;786928']oh and what does the -A -s do

I found a good website for screen commands (man page) http://linux.die.net/man/1/screen.

Cap S lets you give your session a useful name. So, all you need to do is type "screen -r hlds" or something else (I use "hlds").

[ck]ruberducky
03-23-2009, 22:54
i dont know what "rc.local" stuff is, so i assume not because i didnt do that and it runs fine now.

fysiks
03-24-2009, 00:30
I'm a bit confused now and I don't think understood your last post :|. lol Just because you put a script in init.d doesn't mean that it will be run at boot up. You have to put it in rc.d somehow, my method is using rc.local instead of messing with symlinks in one of the runlevels.

EDIT: I just read that Debian doesn't use a rc.local file so I'm assuming you would have to add a symlink to one of the runlevels. . . . Oh, apparently there are commands to add scripts the the run levels, I just always do stuff by hand :).

[ck]ruberducky
03-29-2009, 19:30
nope you are doing it wrong, you're supposed to use init.d with the chconfig command, because rc.local is "oldschool" style and init.d is just more organized. so i guess it doesnt really matter, but i like things to be organized.