This is a Bash Script vor Linux. With it can you run the CSGO Server in the backround this has the advantage, when you colse the connection the Server continues.
In this example my file means csgo.sh .

Install:

1.You Copy this Code in a file, add the Config and save it as bash file.
2.Add rights with the comand „chmod u+x csgo.sh“ (You need Root rights)

Comands:

./mcStrat.sh start #Start Server.
./mcStrat.sh stop #Stop Server.
./mcStrat.sh status #Check is Server running.
./mcStrat.sh console #Open the Console of Program. You can close the console with CTRL + A and D.

###############################
#  CS1.6/CSS/CSGO Startscript #
#   Created by Rainbow-six3   #
# Visite www.rainbow-six3.com #
###############################    


#######CONFIG########
# add your settings #					#######EXAMPLE#######
SERVERNAME=""					#SERVERNAME="csgo-server"
SORTSERVERNAME=""				#SORTSERVERNAME="CSGO"
SERVERIP=""					#SERVERIP="217.79.177.22"
PORT=""					#PORT="27015"
SRCDS=""					#SRCDS="/opt/csgoserver/srcds_linux" 

######SCRIPT#############
# Dont change anything!!!
COMMANDLINE_COMMAND="${1}"
COMMANDLINE_MODE="${2}"
function nocommand(){
        echo ${SORTSERVERNAME}":  Add the Command start , stop , status or console in the Commandline"
        echo ${SORTSERVERNAME}":  Example:"
        echo ${SORTSERVERNAME}":  ./csStart.sh start ca"
        exit 5
}
function nomode(){
        echo ${SORTSERVERNAME}":  Add Gamemode  ca = Classic Casual , co = Classic Competitive , ac = Arms Race or de = Demolition in the Commandline"
        echo ${SORTSERVERNAME}":  Example:"
        echo ${SORTSERVERNAME}":  ./csStart.sh start ca"
        exit 5
}
function noconf(){
		echo "###############################"
		echo "#  CS1.6/CSS/CSGO Startscript #"
		echo "#   Created by Rainbow-six3   #"
		echo "# Visite www.rainbow-six3.com #"
		echo "###############################"  
        echo "##Add Configuration in the Startscript!!##"
		exit 5
}
function conf(){
		echo ${SORTSERVERNAME}": Screenname: " ${SERVERNAME}
		echo ${SORTSERVERNAME}": Consolename: " ${SORTSERVERNAME}
		echo ${SORTSERVERNAME}": Pfad:" ${SRCDS}
		echo ${SORTSERVERNAME}": IP: " ${SERVERIP} 
		echo ${SORTSERVERNAME}": Port: " ${PORT}
}
if [ -z $SERVERNAME ]; then
                noconf
fi
if [ -z $SORTSERVERNAME ]; then
                noconf
fi
if [ -z $SERVERIP ]; then
                noconf
fi
if [ -z $SRCDS ]; then
                noconf
fi
case $COMMANDLINE_COMMAND in
        start)
				if [[ `screen -ls | grep $SERVERNAME` ]];then
					echo ${SORTSERVERNAME}":  Server is already running"
					conf
					exit 5
				fi
				if [ -z $COMMANDLINE_MODE ]; then
					nomode
				fi
				conf
				case $COMMANDLINE_MODE in
					ca)
						screen -A -m -d -S ${SERVERNAME} ${SRCDS} srcds -game csgo -console -usercon +game_type 0 +game_mode 0 +mapgroup mg_bomb +map de_dust2  -ip ${SERVERIP} -port ${PORT} -autoupdate -verify_all
						echo ${SORTSERVERNAME}":  Server running Classic Casual"
						exit 5
					;;
					co)
						screen -A -m -d -S ${SERVERNAME} ${SRCDS} srcds -game csgo -console -usercon +game_type 0 +game_mode 1 +mapgroup mg_bomb +map de_dust2  -ip ${SERVERIP} -port ${PORT}  -autoupdate -verify_all
						echo ${SORTSERVERNAME}":  Server running Classic Competitive"
						exit 5
					;;
					ac)
						screen -A -m -d -S ${SERVERNAME} ${SRCDS} srcds -game csgo -console -usercon +game_type 1 +game_mode 0 +mapgroup mg_bomb +map de_dust2  -ip ${SERVERIP} -port ${PORT}  -autoupdate -verify_all
						echo ${SORTSERVERNAME}":  Server running Arms Race"
						exit 5
					;;
					de)
						screen -A -m -d -S ${SERVERNAME} ${SRCDS} srcds -game csgo -console -usercon +game_type 1 +game_mode 1 +mapgroup mg_bomb +map de_dust2  -ip ${SERVERIP} -port ${PORT}  -autoupdate -verify_all
						echo ${SORTSERVERNAME}":  Server running Demolition"
						exit 5
				esac
		;;
        stop)
            if [[ `screen -ls | grep $SERVERNAME` ]];then
				screen -r ${SERVERNAME} -X quit
				echo "exit"
				echo ${SORTSERVERNAME}": Server is stopped"
				exit 5
			else
				echo ${SORTSERVERNAME}": No Server is running"
			fi
		;;
        status)
             if [[ `screen -ls | grep $SERVERNAME` ]];then
				echo ${SORTSERVERNAME}": Server is already running"
			else
				echo ${SORTSERVERNAME}": Server is down"
			fi
			exit 5
		;;
		console)
			if [[ `screen -ls | grep $SERVERNAME` ]];then
		        screen -x ${SERVERNAME}
			else
				echo ${SORTSERVERNAME}": Server is down"
				exit 5
            fi
		;;
        *)
            nocommand
esac

Schreibe einen Kommentar