Advertisement
Guest User

simple_updatescript_for_steamcmd_with_permissions

a guest
Feb 24th, 2013
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.45 KB | None | 0 0
  1. #!/bin/bash
  2. # by DeaD_EyE
  3.  
  4. #path to steamcmdbin
  5. steamcmd="/home/csgo/serverfiles_csgo/linux32/steamcmd"
  6. steambin="`basename $steamcmd`"
  7. steampath="`dirname $steamcmd`"
  8.  
  9. login="+login anonymous"
  10. quit="+quit"
  11.  
  12.  
  13. #Servers + appids
  14. #####
  15. serverpath[0]="/home/csgo/serverfiles/csgo_dss"
  16. appid[0]="+app_update 740 validate"
  17.  
  18. serverpath[1]="/home/csgo/servers/war12"
  19. appid[1]="+app_update 740 validate"
  20.  
  21. #serverpath[2]="/home/anywehre/anyserver"
  22. #appid[2]="+app_update xxx [validate]"
  23.  
  24.  
  25. ############################
  26. #cecking human input
  27. #setting red color for text
  28. #maybe someone can do nicer output formating
  29. tput setf 4
  30. n=0
  31. error=0
  32. for installpath in ${serverpath[@]}; do
  33.   if [[ ! -d "$installpath" ]]; then
  34.     error=1
  35.     format="%-40s%40s   %-s\n"
  36.     printf "$format" "$installpath" "${appid[$n]}" ":wrong directory"
  37.   fi
  38.   #inkrement +1
  39.   (( n = $n + 1 ))
  40. done
  41.  
  42. #if one installpath is wrong, the script will exit with errorcode 1
  43. #setting white color for text
  44. tput setf 7
  45. [[ $error == 1 ]] && exit 1
  46. ############################
  47.  
  48.  
  49. #############################
  50. #make batch command for updating
  51. #Yay, feel the power of steamcmd (head > desk!)
  52. STEAMCMDBATCH=""
  53.  
  54. n=0
  55. for installpath in ${serverpath[@]}; do
  56.   #build the middlepart for updater -> +force_install_dir /path +app_update xxx ...
  57.   STEAMCMDBATCH="$STEAMCMDBATCH +force_install_dir ${serverpath[$n]} ${appid[$n]}"
  58.   #inkrement +1
  59.   (( n = $n + 1 ))
  60. done
  61.  
  62. ############################
  63. #execute this shit
  64. command="$login $STEAMCMDBATCH $quit"
  65. ############################
  66.  
  67.  
  68. #################
  69. #export LD_LIBRARY_PATH for running steamcmd without the steamcmd.sh
  70. export LD_LIBRARY_PATH=$steampath
  71. ##################
  72.  
  73. ##################
  74. #running steamcmd two times for updating
  75. #drink a coffee
  76. #I think it's better, nerver trust steamcmd
  77. echo "Updating the updater..."
  78. $steamcmd +quit &>/dev/null
  79. echo "Running the updater 2nd time"
  80. $steamcmd +quit &>/dev/null
  81. ##################
  82.  
  83. ##################
  84. #running steamcmd update process for all games
  85. echo "Begin updating process..."
  86. $steamcmd $command &>/dev/null
  87. #use only $steamcmd $command if you want to watch the process
  88. #$steamcmd $command
  89. ###################
  90.  
  91. ##################
  92. #setting permissions in a for loop
  93. for installpath in ${serverpath[@]}; do
  94.   #Fix for all srcds based servers
  95.   if [[ `find $installpath -type f -name 'srcds_*'` ]]; then
  96.     echo "Setting permissions for $installpath with srcds-fix"
  97.     find $installpath -type f -print0 | xargs -0 chmod 644 # all files
  98.     find $installpath -type f -name 'srcds_*' -print0 | xargs -0 chmod 755 #fix for srcds_*
  99. #  fix for hlds
  100. #  elif [[ `find $installpath -type f -name 'hlds_*'` ]]; then
  101. #    echo "Setting permissions for $installpath with hlds-fix"
  102. #    find $installpath -type f -print0 | xargs -0 chmod 644 # all files
  103. #    find $installpath -type f -name 'hlds_*' -print0 | xargs -0 chmod 755 #fix for srcds_*
  104.   else
  105.     #all other types of servers...
  106.     echo "Setting permissions for $installpath"
  107.     find $installpath -type f -executable -print0 | xargs -0 chmod 755 # executable files
  108.     find $installpath -type f -not -executable -print0 | xargs -0 chmod 644 #non-executable files
  109.     find $installpath -type d -print0 | xargs -0 chmod 755 # direcotries
  110.   fi
  111. done
  112. ##################
  113.  
  114. #Set color green
  115. tput setf 2
  116. echo "Done"
  117. #back to normal color
  118. tput setf 7
  119.  
  120. #do anything after the updating process like rsync your slaves
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement