• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

how to write a shell script for my CS server

hans007

Lifer
I installed mandrake 7.2 the other day on my other computer. After hours of mucking with it, i figured out how to get a working counterstrike server working. Now i've got to type this long string and well, i want to know how to make a script so i dont have to type

./hlds_run -nomaster +sv_lan 1 -game cstrike +maxplayers 16 +map de_dust


Also is there a wierd problem with the i810 chipset's video with linux because i get wierd screen corruption. Its not really a big deal, but i was just wondering
 
simple

#!/bin/sh

./hlds_run -nomaster +sv_lan 1 -game cstrike +maxplayers 16 +map de_dust

#eof

then chmod 755 it, and run away...
of course there's plenty of other things you can do... like make it loop automatically if it crashes, etc...
there's a few premade cs server scripts avail (some, or one, on the cs server page).

erm i dunno bout the i810, but search google and you'll prolly find a few ppl w/ similar probs if it's a common prob.
 
the following is a script i wrote for starting/stoping/restarting the halflife server. its mostly ment to be used as an init script. i wrote it with debian in mind, but it should be reasonably easy to adapt to your distribution.

the script requires start-stop-daemon (part of the debian dpkg system)

http://ftp.debian.org/debian/pool/main/d/dpkg/dpkg_1.8.3.1.tar.gz

and screen

ftp://mirrors.xmission.com/gnu/screen/screen-3.9.8.tar.gz

of course you will need to modify the default values for PATH, DAEMON, HLDIR, and ARGS to match your system's setup.

- c-dubs

script is as follows:

#! /bin/bash
#
# a script for starting/stopping/restarting the halflife server
# by cwj@rootdown.net
#

NAME=hld
PATH=/sbin:/bin:/usr/bin:/sbin:/usr/sbin
HLDIR=/usr/local/halflife/ # path to your hl server
DAEMON=/usr/local/halflife/hlds_run # path to your hlds_run binary
ARGS="-game cstrike -port 27015 +maxplayers 16 +map cs_italy" # arguments to pass to the halflife server
export LD_LIBRARY_PATH=$HLDIR:$LD_LIBRARY_PATH
trap "" 1
export LANG=C

test -f $DAEMON || exit 0

case "$1" in
start)
echo -ne "Starting server: $NAME.\n"
cd $HLDIR
screen -m -d -S hld $DAEMON $ARGS
;;
stop)
echo -ne "Stoping server: $NAME.\n"
start-stop-daemon --stop -x $DAEMON
;;
restart)
echo -ne "Restarting server: $NAME.\n"
start-stop-daemon --stop -x $DAEMON
cd $HLDIR
screen -m -d -S hld $DAEMON $ARGS
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
exit 1
;;
esac
exit 0
 
Back
Top