Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # by DeaD_EyE
- #path to steamcmdbin
- steamcmd="/home/csgo/serverfiles_csgo/linux32/steamcmd"
- steambin="`basename $steamcmd`"
- steampath="`dirname $steamcmd`"
- login="+login anonymous"
- quit="+quit"
- #Servers + appids
- #####
- serverpath[0]="/home/csgo/serverfiles/csgo_dss"
- appid[0]="+app_update 740 validate"
- serverpath[1]="/home/csgo/servers/war12"
- appid[1]="+app_update 740 validate"
- #serverpath[2]="/home/anywehre/anyserver"
- #appid[2]="+app_update xxx [validate]"
- ############################
- #cecking human input
- #setting red color for text
- #maybe someone can do nicer output formating
- tput setf 4
- n=0
- error=0
- for installpath in ${serverpath[@]}; do
- if [[ ! -d "$installpath" ]]; then
- error=1
- format="%-40s%40s %-s\n"
- printf "$format" "$installpath" "${appid[$n]}" ":wrong directory"
- fi
- #inkrement +1
- (( n = $n + 1 ))
- done
- #if one installpath is wrong, the script will exit with errorcode 1
- #setting white color for text
- tput setf 7
- [[ $error == 1 ]] && exit 1
- ############################
- #############################
- #make batch command for updating
- #Yay, feel the power of steamcmd (head > desk!)
- STEAMCMDBATCH=""
- n=0
- for installpath in ${serverpath[@]}; do
- #build the middlepart for updater -> +force_install_dir /path +app_update xxx ...
- STEAMCMDBATCH="$STEAMCMDBATCH +force_install_dir ${serverpath[$n]} ${appid[$n]}"
- #inkrement +1
- (( n = $n + 1 ))
- done
- ############################
- #execute this shit
- command="$login $STEAMCMDBATCH $quit"
- ############################
- #################
- #export LD_LIBRARY_PATH for running steamcmd without the steamcmd.sh
- export LD_LIBRARY_PATH=$steampath
- ##################
- ##################
- #running steamcmd two times for updating
- #drink a coffee
- #I think it's better, nerver trust steamcmd
- echo "Updating the updater..."
- $steamcmd +quit &>/dev/null
- echo "Running the updater 2nd time"
- $steamcmd +quit &>/dev/null
- ##################
- ##################
- #running steamcmd update process for all games
- echo "Begin updating process..."
- $steamcmd $command &>/dev/null
- #use only $steamcmd $command if you want to watch the process
- #$steamcmd $command
- ###################
- ##################
- #setting permissions in a for loop
- for installpath in ${serverpath[@]}; do
- #Fix for all srcds based servers
- if [[ `find $installpath -type f -name 'srcds_*'` ]]; then
- echo "Setting permissions for $installpath with srcds-fix"
- find $installpath -type f -print0 | xargs -0 chmod 644 # all files
- find $installpath -type f -name 'srcds_*' -print0 | xargs -0 chmod 755 #fix for srcds_*
- # fix for hlds
- # elif [[ `find $installpath -type f -name 'hlds_*'` ]]; then
- # echo "Setting permissions for $installpath with hlds-fix"
- # find $installpath -type f -print0 | xargs -0 chmod 644 # all files
- # find $installpath -type f -name 'hlds_*' -print0 | xargs -0 chmod 755 #fix for srcds_*
- else
- #all other types of servers...
- echo "Setting permissions for $installpath"
- find $installpath -type f -executable -print0 | xargs -0 chmod 755 # executable files
- find $installpath -type f -not -executable -print0 | xargs -0 chmod 644 #non-executable files
- find $installpath -type d -print0 | xargs -0 chmod 755 # direcotries
- fi
- done
- ##################
- #Set color green
- tput setf 2
- echo "Done"
- #back to normal color
- tput setf 7
- #do anything after the updating process like rsync your slaves
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement