VPSNET LT
Posted: 2015 Mar 01 18:48
Kaip nustatyti pagal VPSNET.LT
Start
Start_line
Start
Code: Select all
#!/bin/sh##Start/stop/restart a Valve dedicated server# All configuration changes should occur in <scriptname>.conf. Only change the name of the call below if you are using a different name for the scriptcd /usr/catch/servas. ./start_line service_start() { #This is the startup script, which will start the server based off of the .conf file specified above, and write the screen name as the pid if [ ! -f $DSPATH/$DSNAMEdonotuse.pid ] && [ ! -f $DSPATH/$DSNAMESHORT.pid ]; then if [ -x $DSPATH/$DSNAMEdonotuse ]; then echo "Starting $TITLE: Services" echo "$DSPATH/$DSNAME $DSOPTS" cd $DSPATH; $DSINTERFACE $DSPATH/$DSNAME $DSOPTS sleep 1 # prevent race condition on SMP kernels ps -ef |grep SCREEN |grep "$CLIENT" | grep -v grep | awk '{print $2 }' > $DSNAMESHORT.pid echo -e "$DSNAMESHORT Process ID Written to $DSNAMESHORT.pid\n$DSNAMESHORT Server Process ID Written to $DSNAMESHORT.pid" cp $DSNAMESHORT.pid /usr/catch/servas/$DSNAMESHORT.pid fi else echo -e "Server is Already running." fi} service_stop() { # This script is just getting the process id of the server that was written to the file it created earlier so it can kill it. for vdspid in $(cat $DSPATH/$DSNAMESHORT.pid); do kill $vdspid; rm -rf $DSNAMESHORT.pid; break; done rm -rf $DSPATH/cstrike/$DSNAMESHORT.pid;# This command is just clearing out any *DEAD* screen sessions. Those can become a pain really quick screen -wipe 1> /dev/null 2> /dev/null} service_restart() { # Simple enough. It is making a call to the stop service and then it waits for a second then it calls the start script service_stop sleep 1 service_start} service_status() {# This is checking to see if $DSNAMESHORT.pid file exsistsif [ -f $DSPATH/$DSNAME$DSNAMESHORT.pid ]; then# Pulling in the values to evaulate if they are true or notPROCESSRUN=`cat $DSPATH/$DSNAME$DSNAMESHORT.pid`PROCSERV=`ps -ef | grep SCREEN | grep "$CLIENT" | grep -v grep | awk '{ print $2 }'` # This is checking to see if the currently running process ID matches with the pid created when the server was started if [ "$PROCESSRUN" == "$PROCSERV" ]; then echo -e "$DSNAMESHORT is running on process `cat $DSPATH/$DSNAMESHORT.pid`\n" # It found this process ID matches and is outputting what it is currently running on fielse echo -e "$DSNAMESHORT is offline. This could be due to someone or something else that killed it." # Apparently the server is offline if [ "$PROCSERV" ]; then echo -e "However a Process Matching the same criteria was found at process ID $PROCSERV....\n Might be worth a investigation" # Wait, it found another server matching the same criteria running under a different process ID. fifi #Checking to see if this file exsists if [ -f $DSPATH/$DSNAMESHORT.pid ]; thenecho "$DSNAMESHORT Server is running on process `cat $DSPATH/$DSNAMESHORT.pid`" # It found the file exsists and is outputting the infoelseecho -e "$DSGAME Server is offline. This could be due to someone or something else that killed it\nor it is just rebooting" #Oops the server is active or the pid file got deleted.fi} # This service is used watch the process that is currently runningservice_watch(){ # Check if there is someone already attached if [ `screen -wipe | grep $CLIENT | grep -v grep | awk '{ print $2 }'` == '(Attached)' ]; then echo -e "Someone is already attached to the console of the server.\n Might want to check who"else # Looks like noone is watching it right now.... screen -r $CLIENTfi} # This service is used to clean house if the script is reporting erroneous info. service_clean(){ rm -rf *.pid;rm -rf $DSPATH/*.pid;screen -wipe 1> /dev/null 2> /dev/null;} case "$1" in'start') service_start ;;'stop') service_stop ;;'restart') service_stop service_restart ;;'status') service_status ;;'watch') service_watch ;;'clean') service_clean ;;*) echo "usage $0 start|stop|restart|status|watch|clean"esac
Code: Select all
#!/bin/shCLIENT='catch'; # Identifier for attaching screen sessionTITLE='servas'; # Name that is shown during start-up messagesDSPATH='/usr/catch/servas'; # Where Steam is installedDSIP='213.226.189.6'; # IP address you want to use to start server withDSNAME='hlds_run'; # Either hlds_run or srcds_runDSNAMESHORT='catch'; # Label onlyDSGAME='cstrike'; # Game type (valve, cstrike, czero, etc)DSIMAP='catch_dust2'; # Load this map initiallyDSPORT='27015'; # Game server listens on this UDP portDSSIZE='32'; # Maximum number of players to allowDSUSER='gaming'; # Which user is running the processDSTICKRATE='66'; # Tick RateDSSERVERFPS='600'; # Server FPS RateDSCFGFILE='server.cfg'; # Choice of which server config to draw from# Don't edit this unless you need the script to do something specialDSOPTS="-game $DSGAME +map $DSIMAP -ip $DSIP -port $DSPORT +maxplayers $DSSIZE -pidfile $DSNAMESHORT.pid +exec $DSCFGFILE"# This is the caller for the screen process. Only change if this is different from where your screen process currently resides.DSINTERFACE="/usr/bin/screen -A -m -d -S $CLIENT"