PDA

View Full Version : Autostarting the server on boot


Lazbien
01-03-2004, 05:17 PM
'Lo gents,

I'm in the midst of getting a new server running, but have a few questions regarding autostarting.

I've an account setup on my Debian Box specifically for admining the CoD server, so that if the server dies my root account doesn't suffer the ill effects. I have my dedicated.cfg sitting in the /cod/main directory. Now my big question is:

Has anyone set up an init.d (or rc.d for rh/mandrake) for CoD that brings the server up on boot time? While I don't mind logging in to start the server, I would prefer to run it as a daemon chown'd to my user account.

TIA.

Lazbien
01-03-2004, 05:30 PM
After a bit of following links, I stumbled across this. (http://www.ra.is/AQ/servers/tricks.html) While this is nice, it's a bit of a kludge. I'd prefer to run the server as a daemon, not as its own process.

TIA.

MOMMA
01-04-2004, 12:49 PM
Sorry I see no one has posted a response yet. I can tell you that our host does have something loaded to run the server on bootup but I don't know what it is. Also ours is a windows server as where yours appears to be linux (I think). Hopefully someone with more expertise will respond.

Lazbien
01-04-2004, 09:54 PM
Well, I put together a kludge, but here it is:
~~~~~~~~~~~~~~~~~~~~~
#!/bin/sh

BASEDIR=/cod
RUNASUSER=freedomfighters
SCROPT="./cod_lnxded +exec dedicated.cfg"
DESC="CoD Server"
export BASEDIR
export RUNASUSER
export SCROPT
export DESC

case $1 in
'start')
#
# We are going to run this script as the freedomfighters account.
#
echo "Starting $DESC"
su $RUNASUSER -c "cd $BASEDIR;$SCROPT" > /dev/null 2>&1 &
;;
'stop')
# put shutdown command(s) here
echo "Killing $DESC"
killall cod_lnxded
;;
'restart')
echo "Restarting $DESC"
killall cod_lnxded
su $RUNASUSER -c "cd $BASEDIR;$SCROPT" > /dev/null 2>&1 &
;;
*)
echo "Usage: $0 start|stop|restart" >&2
exit 1
;;
esac
exit 0
~~~~~~~~~~~~~~~~~

Debian Specific Install instructions:
1. Login as root
2. Touch a new file in /etc/init.d called codstartup
3. chmod the file to 755
4. Update the above file to meet your specifics
5. Save the file
6. At a prompt, type: update-rc.d codstartup defaults
7. Either at the console or upon reboot, the server will auto-start
8. To kill the server, type /etc/init.d/codstartup stop


It may be a little dirty on startup, but it works. If anyone can improve this script, please post here.