COD4 Wrapper / SysV init

Brandon Ewing nicotine at warningg.com
Thu Nov 29 21:11:18 EST 2007


Attached is a tarball containing two files, that I shall explain.

cod4_lnxded-wrap.pl
This is a wrapper script for admins that are perfectly happy with the way
their servers are performing, and no longer really need console access to
them.  

You must have the following perlmods installed from CPAN in order for the
wrapper to work:
Proc::UID
File::Pid
Getopt::Long
Proc::Daemon

You may have to force the install of Proc::UID -- but it will work fine.

The script accepts the following options:

--user=[username] -- If running as root, switch to this user prior to
launching the server.  You MUST specify this option if you are the root
user.
--pidfile=[filename] -- specify a pidfile to write the pid to -- if none is
provided, pid is written to /var/run/cod4.pid
--logfile=[filename] -- specify a logfile to direct the console to -- if
none is provided, the console is written to /dev/null (not logged)
--options="[full options string]" -- This is everything you want to pass to
the actual server.

Prior to running the script, you MUST edit it to ensure that $binaryLocation
is set correctly.

Here's an example:
./cod4_lnxded-wrap.pl --user=nicotine --pidfile=/var/run/cod4.pid
--logfile=/var/log/cod4.log --options="+set dedicated 2 +set net_port 28970
+set sv_punkbuster 1 +set fs_homepath /home/nicotine +set fs_basepath
/usr/local/games/cod4-linux-server/ +exec server.cfg +exec
hardcore_settings.cfg +exec custom_hq.cfg +map_rotate"

At launch, the script will daemonize, write its pid file, redirect logging
if desired, drop privs, and then execute the server.

Also in the tarball is "cod4.init", a chkconfig-enabled SysV-style init
script.  Those of you with RedHat derivitive systems can drop the script in
/etc/init.d, and do "chkconfig --add cod4" to set the server to start at
runlevels 3-5.

You should edit the script to set the wrapper options correctly (which will 
get passed to the wrapper, which will get passed to the binary) prior to
running.

Confidential to Ryan:  I tried writing this in C, and got pretty far on it.
But when I read the C man page for execve (after figuring out daemonizing,
privilege dropping, and output redirection), and read "argv must be an 
array of strings terminated etc etc", I gave up and wrote it in Perl. My 
C-foo is much too weak for that. :)

-- 
Brandon Ewing                                        (nicotine at warningg.com)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cod4_init.tar.gz
Type: application/x-gzip
Size: 1303 bytes
Desc: not available
URL: <http://icculus.org/pipermail/cod/attachments/20071129/ea0e668b/attachment.gz>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://icculus.org/pipermail/cod/attachments/20071129/ea0e668b/attachment.pgp>


More information about the Cod mailing list