apres de nombreuses heures de taf et de recherche, je vais vous mettre le script que j'ai trouver pour demarrer un serveur sc (ou autre comme dod,...) automatiquement au demarrage sous linux. Je pense que sa pourrait servir a certains.
[cpp]#!/bin/sh
#
# Start the Counter-Strike dedicated server.
#
# AUTHORS :
#
# Julien Escario ( pandemik@azilog.net )
# &
# Cedric Rochat ( crochat@younics.org )
#
# ===========================================
#
# What you need:
#
# Linux
# awk
# screen
# the hlds_l & cstrike-files
#
# 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
# - standard is startup as LAN-server
#
# 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:
[ $CHECK -eq 0 ] && echo "HLDS is UP" || echo "HLDS is DOWN"
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
exit 0
[/cpp]
voili voilou, sa servira pas mal je pense mais moi je n'arrive pas a faire demarrer le serveur sous un autre utilisateur que root donc si dark ou quelq'un d'autre pouvait m'aider, se serait sympa et peut etre qu'il serait interesant d'epingle ce topic, ce genre de script est super dure a trouver donc sa servirait pour les autres
Question
santino10
salut a tous,
apres de nombreuses heures de taf et de recherche, je vais vous mettre le script que j'ai trouver pour demarrer un serveur sc (ou autre comme dod,...) automatiquement au demarrage sous linux. Je pense que sa pourrait servir a certains.
[cpp]#!/bin/sh
#
# Start the Counter-Strike dedicated server.
#
# AUTHORS :
#
# Julien Escario ( pandemik@azilog.net )
# &
# Cedric Rochat ( crochat@younics.org )
#
# ===========================================
#
# What you need:
#
# Linux
# awk
# screen
# the hlds_l & cstrike-files
#
# 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
# - standard is startup as LAN-server
#
# 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/rc.d/init.d/hlds /etc/rc.d/rc3.d/S90hlds
# ln -s /etc/rc.d/init.d/hlds /etc/rc.d/rc3.d/K50hlds
#
# Or use it manualy like:
# /etc/rc.d/init.d/hlds start
# /etc/rc.d/init.d/hlds stop
#
# How to see the server-console:
#
# Just type in: screen -r cstrike
# More info about screen can be found by typing "man screen" or using this nice link
# http://server.counter-strike.net/help/linuxscreen.html
#
# 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 (jwm@counter-strike.de)
clear
# Edit and uncomment it to run the server as non-root
# CS_USER="jwm"
PATH=/bin:/usr/bin:/sbin:/usr/sbin
# # DON'T FORGET TO CHANGE THE PATH TO YOUR NEEDS!
DIR=/hlds
DAEMON=$DIR/hlds_run
# LAN-server:
#PARAMS="-game cstrike -nomaster -insecure +sv_lan 1 +maxplayers 16 +map de_dust"
# Internet-server:
PARAMS="-game cstrike +ip YOUR WAN-IP +map de_dust +maxplayers 16"
NAME=cstrike
DESC="CounterStrike dedicated server"
case "$1" in
start)
echo "Starting $DESC: $NAME"
if [ -e $DIR ];
then
cd $DIR
# Change the lines for running as non-root!
# su $CS_USER - -c "screen -d -m -S $NAME $DAEMON $PARAMS"
screen -d -m -S $NAME $DAEMON $PARAMS
else echo "No such directory: $DIR!"
fi
;;
stop)
if [[ `screen -ls |grep $NAME` ]]
then
echo -n "Stopping $DESC: $NAME"
kill `screen -ls |grep $NAME |awk -F . '{print $1}'|awk '{print $1}'`
echo " ... done."
else
echo "Coulnd't find a running $DESC"
fi
;;
restart)
if [[ `screen -ls |grep $NAME` ]]
then
echo -n "Stopping $DESC: $NAME"
kill `screen -ls |grep $NAME |awk -F . '{print $1}'|awk '{print $1}'`
echo " ... done."
else
echo "Coulnd't find a running $DESC"
fi
echo -n "Starting $DESC: $NAME"
cd $DIR
screen -d -m -S $NAME $DAEMON $PARAMS
echo " ... done."
;;
status)
# Check whether there's a "hlds" process
# if "checkproc" is installed, you can use this:
# checkproc $DIR/hlds_run && echo "CS-Server RUNNING" || echo "CS-Server NOT RUNNING"
# (thx to commander)
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
[/cpp]
voili voilou, sa servira pas mal je pense mais moi je n'arrive pas a faire demarrer le serveur sous un autre utilisateur que root donc si dark ou quelq'un d'autre pouvait m'aider, se serait sympa et peut etre qu'il serait interesant d'epingle ce topic, ce genre de script est super dure a trouver donc sa servirait pour les autres
21 réponses à cette question
Messages recommandés
Archivé
Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.