Advertisement
dgibbs

SteamCMD Guardian 1.2 Linux

Sep 7th, 2013
38,685
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.51 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # ==> MODIFY THIS
  4.  
  5. #What user you want to use (default: anonymous)
  6. STEAM_USER=anonymous
  7.  
  8. #If you are not using anonymous, specify a password here.
  9. STEAM_PASS=
  10.  
  11. #The default location of the server, relative to this script (default: server).
  12. #If no directory is specified for the server, it'll fall back on this one.
  13. #Don't add a trailing /
  14. INSTALL_DIR=server
  15.  
  16. #The location of the SteamCMD, relative to this script (default: bin). Don't add a trailing /
  17. STEAM_DIR=bin
  18.  
  19. #Ids of the servers you want to install, leave empty to skip
  20. #First item is the directory, second item is the AppID. Directory is relative to script directory
  21. DL_DIR0=
  22. DL_SV0=
  23.  
  24. DL_DIR1=
  25. DL_SV1=
  26.  
  27. DL_DIR2=
  28. DL_SV2=
  29.  
  30. DL_DIR3=
  31. DL_SV3=
  32.  
  33. DL_DIR4=
  34. DL_SV4=
  35.  
  36. DL_DIR5=
  37. DL_SV5=
  38.  
  39. DL_DIR6=
  40. DL_SV6=
  41.  
  42. DL_DIR7=
  43. DL_SV7=
  44.  
  45. #Repeat this and the call to add_game at the bottom of this
  46. #script to add more servers
  47.  
  48. # ==> (optional) INTERNAL SETTINGS, MODIFY IF REQUIRED
  49.  
  50. STEAMCMD_URL="http://media.steampowered.com/client/steamcmd_linux.tar.gz"
  51. STEAMCMD_TARBALL="steamcmd_linux.tar.gz"
  52.  
  53. #
  54. #   Don't modify below here, unless you know what you're doing.
  55. #
  56.  
  57. #Get the current directory (snippet from SourceCMD's sourcecmd.sh)
  58. BASE_DIR="$(cd "${0%/*}" && echo $PWD)"
  59.  
  60. #Relocate downloads to absolute url
  61. INSTALL_DIR=$BASE_DIR/$INSTALL_DIR
  62. STEAM_DIR=$BASE_DIR/$STEAM_DIR
  63.  
  64. if [ -z "$BASE_DIR" -o -z "$INSTALL_DIR" -o -z "$STEAM_DIR" ]; then
  65.     echo "Base directory, Install directory or SteamCMD directory is empty."
  66.     echo "Please check if lines 14 and 17 have content behind the = sign."
  67.     exit 1
  68. fi
  69.  
  70. if [ ! -e "$STEAM_DIR" ]; then
  71.         mkdir $STEAM_DIR
  72.         MADEDIR=$?
  73.         if [ "$MADEDIR" != "0" ]; then
  74.         echo "Failed to make directory for Steam. Do you have sufficient priviliges?"
  75.         exit 1
  76.     fi
  77.     cd $STEAM_DIR
  78.     echo "Fetching SteamCMD from servers..."
  79.     wget $STEAMCMD_URL
  80.     if [ ! -e "$STEAMCMD_TARBALL" ]; then
  81.         echo "ERROR! Failed to get SteamCMD"
  82.         exit 1
  83.     fi
  84.     echo "Completed. Extracting file..."
  85.  
  86.     #Hide the output
  87.     (tar -xvzf $STEAMCMD_TARBALL)
  88.  
  89.     #Install SteamCMD now and try to login, if required
  90.     if [ "$STEAM_USER" != "anonymous" ]; then
  91.         $STEAM_DIR/steamcmd.sh +login $STEAM_USER $STEAM_PASS +quit
  92.     else
  93.         $STEAM_DIR/steamcmd.sh +quit
  94.     fi
  95. fi
  96.  
  97. cd $BASE_DIR
  98.  
  99. CmdArgs="+login $STEAM_USER $STEAM_PASS"
  100. ShouldRun=0
  101.  
  102. add_game(){
  103.     GAME="$1"
  104.     DIR="$2"
  105.     if [ ! -z "$GAME" ]; then
  106.         if [ -z "$DIR" ]; then
  107.             DIR=$INSTALL_DIR
  108.         else
  109.             DIR=$BASE_DIR/$DIR
  110.         fi
  111.  
  112.         OK=0
  113.         if [ ! -d "$DIR" ]; then
  114.             echo "Creating directory $DIR..."
  115.             (mkdir $DIR)
  116.             if [ ! -d "$DIR" ]; then
  117.                 OK=1
  118.             fi
  119.         fi
  120.         if [ "$OK" == "0" ]; then
  121.             CmdArgs="$CmdArgs +force_install_dir \"$DIR\" +app_update $GAME validate"
  122.             ShouldRun=1
  123.         else
  124.             echo "WARNING! Cannot add AppId $GAME into $DIR. Failed to create directory"
  125.         fi
  126.     fi
  127. }
  128.  
  129. add_game "$DL_SV0" "$DL_DIR0"
  130. add_game "$DL_SV1" "$DL_DIR1"
  131. add_game "$DL_SV2" "$DL_DIR2"
  132. add_game "$DL_SV3" "$DL_DIR3"
  133. add_game "$DL_SV4" "$DL_DIR4"
  134. add_game "$DL_SV5" "$DL_DIR5"
  135. add_game "$DL_SV6" "$DL_DIR6"
  136. add_game "$DL_SV7" "$DL_DIR7"
  137.  
  138. CmdArgs="$CmdArgs +quit"
  139.  
  140. if [ "$ShouldRun" == "0" ]; then
  141.     echo "ERROR! No game IDs specified. Please specify at least one id"
  142.     exit 1
  143. fi
  144.  
  145. cd "$BASE_DIR"
  146.  
  147. #Workaround for SteamCMD continuously re-installing apps
  148. echo "cd \"$BASE_DIR\"" > call.sh
  149. echo "$STEAM_DIR/steamcmd.sh $CmdArgs" >> call.sh
  150. chmod u+x ./call.sh
  151. ./call.sh
  152. rm call.sh
  153.  
  154. echo "OK! Completed updating files!"
  155.  
  156. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement