Jump to content
GIGN Forum

Cs Start On Linux Boot


Recommended Posts

Tipa taa ir uzlikts CS serveris...

OP:

Linux Debian

Starta script iebaazts pie /etc/init.d/ ar nosaukumu hlds.

ar sho tipa iedodu vinjam id level 3 lai starteetos augshaa automaatiski bet nekaa...

ln -s /etc/init.d/hlds

smiliez.de_2538.gif

Script:

#! /bin/sh

#

# Start the Counter-Strike dedicated server as non-root.

#

# A modification of the CS Server startup script, to run the server

# as a non-root user.

#

# ORIGINAL AUTHORS :

#

# Julien Escario ( [email protected] )

# &

# Cedric Rochat ( [email protected] )

#

# ===========================================

#

# What you need:

#

# Linux smile.gif

# awk

# screen

# the hlds_l & cstrike-files OR

# a STEAM-installation

#

# YES, this script works fine with STEAM and CS 1.6

#

# How to use:

#

# Edit the DIR-var to fit your system (just contains the path to the dir that contains hlds_run)

# Edit the PARAMS-var to fit your needs

# Edit the CS_USER-var to the name of the user that will run the server

#

# How to see the server-console:

#

# Just type in: screen -r hlds (or whatever you set $NAME to)

# More info about screen can be found by typing "man screen" or using this nice link

# http://server.counter-strike.net/server.ph...wto&show=screen

#

# The easist way is to use this script simple as a start-script for your server

# If you want to use it as a script to start the server at boot-time:

#

# When this is done, copy the file to /etc/rc.d/init.d (or whereever your system stores the

# scripts for starting the services

# Now you can link the script to your runlevel-dir, here's an example for runlevel 3:

#

# ln -s /etc/init.d/hlds /etc/rc3.d/S90hlds

# ln -s /etc/init.d/hlds /etc/rc6.d/K50hlds

#

# Or use it manualy like:

# /etc/rc.d/init.d/hlds start

# /etc/rc.d/init.d/hlds stop

#

# If you don't want to start the server as root you have to change this:

# add the var CS_USER and uncomment it

# change the lines at the "start-block"

#

# You must be logged in as this user to re-attach the screen!

#

# DOC by jwm ([email protected])

# The user that will run the server

# CS_USER=root

# Leave this alone.

NAME=hlds

PATH=/bin:/usr/bin:/sbin:/usr/sbin

# DON'T FORGET TO CHANGE THE PATH TO YOUR NEEDS!

DIR=/usr/local/games/hlds_l

# Leave this alone.

DAEMON=hlds_run

# Internet-server:

PARAMS="-game cstrike -insecure -nomaster +sv_lan 1 +maxplayers 20 +map de_dust"

# Leave this alone.

DESC="Counter-Strike dedicated server"

case "$1" in

start)

if [[ `su $CS_USER -c "screen -ls |grep $NAME"` ]]

then

echo "HLDS is already running!"

else

echo "Starting $DESC: $NAME"

su $CS_USER -c "cd $DIR; screen -m -d -S hlds ./$DAEMON $PARAMS"

fi

;;

stop)

if [[ `su $CS_USER -c "screen -ls |grep $NAME"` ]]

then

echo -n "Stopping $DESC: $NAME"

kill `ps aux | grep -v grep | grep -i $CS_USER | grep -i screen | grep -i $NAME | awk '{print $2}'`

echo " ... done."

else

echo "Coulnd't find a running $DESC"

fi

;;

restart)

if [[ `su $CS_USER -c "screen -ls |grep $NAME"` ]]

then

echo -n "Stopping $DESC: $NAME"

kill `ps aux | grep -v grep | grep -i $CS_USER | grep -i screen | grep -i $NAME | awk '{print $2}'`

echo " ... done."

else

echo "Coulnd't find a running $DESC"

fi

echo -n "Starting $DESC: $NAME"

su $CS_USER -c "cd $DIR; screen -m -d -S hlds ./$DAEMON $PARAMS"

echo " ... done."

;;

status)

ps aux | grep -v grep | grep hlds_r > /dev/null

CHECK=$?

[ $CHECK -eq 0 ] && echo "HLDS is UP" || echo "HLDS is DOWN"

;;

*)

echo "Usage: $0 {start|stop|status|restart}"

exit 1

;;

esac

exit 0

nu apmeeram taa!!!

Link to comment
Share on other sites

Tipa taa ir uzlikts CS serveris...

OP:

Linux Debian

Starta script iebaazts pie /etc/init.d/ ar nosaukumu hlds.

ar sho tipa iedodu vinjam id level 3 lai starteetos augshaa automaatiski bet nekaa...

ln -s /etc/init.d/hlds

smiliez.de_2538.gif

Script:

#! /bin/sh

#

# Start the Counter-Strike dedicated server as non-root.

#

# A modification of the CS Server startup script, to run the server

# as a non-root user.

#

# ORIGINAL AUTHORS :

#

# Julien Escario ( [email protected] )

# &

# Cedric Rochat ( [email protected] )

#

# ===========================================

#

# What you need:

#

# Linux smile.gif

# awk

# screen

# the hlds_l & cstrike-files OR

# a STEAM-installation

#

# YES, this script works fine with STEAM and CS 1.6

#

# How to use:

#

# Edit the DIR-var to fit your system (just contains the path to the dir that contains hlds_run)

# Edit the PARAMS-var to fit your needs

# Edit the CS_USER-var to the name of the user that will run the server

#

# How to see the server-console:

#

# Just type in: screen -r hlds (or whatever you set $NAME to)

# More info about screen can be found by typing "man screen" or using this nice link

# http://server.counter-strike.net/server.ph...wto&show=screen

#

# The easist way is to use this script simple as a start-script for your server

# If you want to use it as a script to start the server at boot-time:

#

# When this is done, copy the file to /etc/rc.d/init.d (or whereever your system stores the

# scripts for starting the services

# Now you can link the script to your runlevel-dir, here's an example for runlevel 3:

#

# ln -s /etc/init.d/hlds /etc/rc3.d/S90hlds

# ln -s /etc/init.d/hlds /etc/rc6.d/K50hlds

#

# Or use it manualy like:

# /etc/rc.d/init.d/hlds start

# /etc/rc.d/init.d/hlds stop

#

# If you don't want to start the server as root you have to change this:

# add the var CS_USER and uncomment it

# change the lines at the "start-block"

#

# You must be logged in as this user to re-attach the screen!

#

# DOC by jwm ([email protected])

# The user that will run the server

# CS_USER=root

# Leave this alone.

NAME=hlds

PATH=/bin:/usr/bin:/sbin:/usr/sbin

# DON'T FORGET TO CHANGE THE PATH TO YOUR NEEDS!

DIR=/usr/local/games/hlds_l

# Leave this alone.

DAEMON=hlds_run

# Internet-server:

PARAMS="-game cstrike -insecure -nomaster +sv_lan 1 +maxplayers 20 +map de_dust"

# Leave this alone.

DESC="Counter-Strike dedicated server"

case "$1" in

start)

if [[ `su $CS_USER -c "screen -ls |grep $NAME"` ]]

then

echo "HLDS is already running!"

else

echo "Starting $DESC: $NAME"

su $CS_USER -c "cd $DIR; screen -m -d -S hlds ./$DAEMON $PARAMS"

fi

;;

stop)

if [[ `su $CS_USER -c "screen -ls |grep $NAME"` ]]

then

echo -n "Stopping $DESC: $NAME"

kill `ps aux | grep -v grep | grep -i $CS_USER | grep -i screen | grep -i $NAME | awk '{print $2}'`

echo " ... done."

else

echo "Coulnd't find a running $DESC"

fi

;;

restart)

if [[ `su $CS_USER -c "screen -ls |grep $NAME"` ]]

then

echo -n "Stopping $DESC: $NAME"

kill `ps aux | grep -v grep | grep -i $CS_USER | grep -i screen | grep -i $NAME | awk '{print $2}'`

echo " ... done."

else

echo "Coulnd't find a running $DESC"

fi

echo -n "Starting $DESC: $NAME"

su $CS_USER -c "cd $DIR; screen -m -d -S hlds ./$DAEMON $PARAMS"

echo " ... done."

;;

status)

ps aux | grep -v grep | grep hlds_r > /dev/null

CHECK=$?

[ $CHECK -eq 0 ] && echo "HLDS is UP" || echo "HLDS is DOWN"

;;

*)

echo "Usage: $0 {start|stop|status|restart}"

exit 1

;;

esac

exit 0

nu apmeeram taa!!!

Varētu būt, ka šeit parto nekko daudzi nezinās, daži varbūt labāk prasi http://php.lv/f/

Link to comment
Share on other sites

Taatad... success!!!! laugh.gif

viss ir tik vienkaarshi cik vienkaarshi var buut he he...

Shis domaats prieksh Linux Debian

1d71.jpg

Paraugs:

1)

shis ir skripts kursh nosaukts par blah

#! /bin/sh
# /etc/init.d/blah
#

# Some things that run always
touch /var/lock/blah

# Carry out specific functions when asked to by the system
case "$1" in
 start)
   echo "Starting script blah "
   echo "Could do more here"
  ;;
 stop)
   echo "Stopping script blah"
   echo "Could do more here"
  ;;
 *)
   echo "Usage: /etc/init.d/blah {start|stop}"
   exit 1
  ;;
esac

exit 0

2)

iekopeejam skriptu shajaa direktorijaa /etc/init.d/blah

tad izpildam shaadu chmod 755 /etc/init.d/blah komandu lai dotu accsess uz failu pie boot.

3)

kad tas ir paveikt tad izpildam shaadu komandu update-rc.d blah defaults , tas noziimee ka shiii komada saliek visu pa plauktinjiem lai scripts palaistos pie boot vai reboot automaatiski

tam jaaizskataas aptuveni taa:

root@skx:~# update-rc.d blah defaults

Adding system startup for /etc/init.d/blah ...

/etc/rc0.d/K20blah -> ../init.d/blah

/etc/rc1.d/K20blah -> ../init.d/blah

/etc/rc6.d/K20blah -> ../init.d/blah

/etc/rc2.d/S20blah -> ../init.d/blah

/etc/rc3.d/S20blah -> ../init.d/blah

/etc/rc4.d/S20blah -> ../init.d/blah

/etc/rc5.d/S20blah -> ../init.d/blah

p.s ja veelies atsaukt to visu tad izpildi shaadu komandu:

update-rc.d -f blah remove

tas izskatiises apmeeram taa:

root@skx:/etc/rc2.d# update-rc.d -f blah remove

update-rc.d: /etc/init.d/blah exists during rc.d purge (continuing)

Removing any system startup links for /etc/init.d/blah ...

/etc/rc0.d/K20blah

/etc/rc1.d/K20blah

/etc/rc2.d/S20blah

/etc/rc3.d/S20blah

/etc/rc4.d/S20blah

/etc/rc5.d/S20blah

/etc/rc6.d/K20blah

tas nu viss!!!! 4.gif1d71.jpg

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...