Changeset 308 for scripts/usr/local/lib/7dtd/commands/updateengine.sh
- Timestamp:
- Aug 7, 2017, 7:18:35 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
scripts/usr/local/lib/7dtd/commands/updateengine.sh
r265 r308 19 19 20 20 sdtdCommandUpdateengine() { 21 # local FORCED=no 22 # if [ "$1" = "--force" ]; then 23 # FORCED=yes 24 # fi 25 26 local EXPERIMENTAL=no 27 if [ "$1" = "--experimental" ]; then 28 EXPERIMENTAL=yes 29 fi 30 21 local FORCED=no 22 local CHECKONLY=no 23 local SHOWINTERNAL=no 24 25 local BRANCHNAME="$(getLocalBranch)" 26 local BRANCHPASSWORD="" 27 28 while test $# -gt 0; do 29 case "$1" in 30 --check) 31 CHECKONLY=yes 32 ;; 33 --showinternal) 34 SHOWINTERNAL=yes 35 ;; 36 --experimental) 37 BRANCHNAME="latest_experimental" 38 ;; 39 --stable) 40 BRANCHNAME="public" 41 ;; 42 --branch) 43 if [ -z "$2" ]; then 44 echo "Argument --branch not followed by a branch name. Aborting." 45 return 46 fi 47 BRANCHNAME=$2 48 shift 49 ;; 50 --password) 51 if [ -z "$2" ]; then 52 echo "Argument --password not followed by a branch password value. Aborting." 53 return 54 fi 55 BRANCHPASSWORD=$2 56 shift 57 ;; 58 --force) 59 FORCED=yes 60 ;; 61 esac 62 shift 63 done 64 31 65 if [ ! -e $SDTD_BASE/steamcmd ]; then 32 66 mkdir $SDTD_BASE/steamcmd … … 37 71 ./steamcmd.sh +quit 38 72 fi 39 40 # if [ "$1" = "--check" -o "$2" = "--check" ]; then 41 # local LOCAL=$(getLocalEngineVersion) 42 # local REMOTE=$(getRemoteEngineVersion) 43 # if [ $REMOTE -gt $LOCAL ]; then 44 # echo "Newer engine version available." 45 # else 46 # echo "Engine up to date." 47 # fi 48 # echo "Local buildid: $LOCAL" 49 # echo "Available buildid: $REMOTE" 50 # return 51 # fi 73 74 updateRemoteEngineInfo 75 76 if [ "$CHECKONLY" = "yes" ]; then 77 local LOCAL=$(getLocalEngineVersion) 78 local REMOTE=$(getBuildId $(getLocalBranch)) 79 local REMOTETIME=$(getBuildUpdateTime $(getLocalBranch)) 80 81 echo "Installed:" 82 echo " Build ID: $(getLocalEngineVersion)" 83 echo " Installed on: $(getLocalEngineUpdateTime)" 84 echo " From branch: $(getLocalBranch)" 85 echo 86 87 echo "Available branches:" 88 printf "%-*s | %-*s | %-*s\n" 22 "Branch" 8 "Build ID" 19 "Build set on" 89 printf -v line "%*s-+-%*s-+-%*s\n" 22 " " 8 " " 19 " " 90 echo ${line// /-} 91 for I in $(getBranchNames); do 92 if [[ $I != test* ]] || [ "$SHOWINTERNAL" = "yes" ]; then 93 local BUILD=$(getBuildId $I) 94 local CREATED=$(getBuildUpdateTime $I) 95 printf "%-*s | %*s | %2s\n" 22 "$I" 8 "$BUILD" "$CREATED" 96 fi 97 done | sort -k 3 -n -r 98 99 echo 100 101 if [ $REMOTE -gt $LOCAL ]; then 102 echo "Newer engine version available on the currently installed branch (build id $REMOTE from $REMOTETIME)." 103 else 104 local MAXREMOTE=0 105 local MAXREMOTEBRANCH=0 106 local MAXREMOTETIME=0 107 for I in $(getBranchNames); do 108 if [[ $I != test* ]] || [ "$SHOWINTERNAL" = "yes" ]; then 109 local BUILD=$(getBuildId $I) 110 local CREATED=$(getBuildUpdateTime $I) 111 if [ $BUILD -gt $MAXREMOTE ]; then 112 MAXREMOTE=$BUILD 113 MAXREMOTETIME=$CREATED 114 MAXREMOTEBRANCH=$I 115 fi 116 fi 117 done 118 if [ $MAXREMOTE -gt $LOCAL ]; then 119 echo "Newer engine version available on the branch \"$MAXREMOTEBRANCH\" (build id $MAXREMOTE from $MAXREMOTETIME)." 120 else 121 echo "Engine on the latest build." 122 fi 123 fi 124 return 125 fi 52 126 53 127 for I in $(getInstanceList); do … … 60 134 61 135 local LOCAL=$(getLocalEngineVersion) 62 #local REMOTE=$(getRemoteEngineVersion) 63 #local LOCAL_SUPPORTED_BUILD=$(cat /usr/local/lib/7dtd/VERSION | grep "DediBuild" | cut -d\ -f2) 64 65 # if [ "$FORCED" = "yes" -o $REMOTE -gt $LOCAL ]; then 66 # echo "A newer version of the engine is available." 67 echo "Local buildid: $LOCAL" 68 #echo "Available buildid: $REMOTE" 136 local REMOTE=$(getBuildId $BRANCHNAME) 137 138 if [ "$FORCED" = "yes" -o $REMOTE -gt $LOCAL ]; then 139 echo "A newer version of the engine is available." 140 echo "Local build id: $LOCAL (installed on $(getLocalEngineUpdateTime))" 141 echo "Available build id: $REMOTE (from $(getBuildUpdateTime $BRANCHNAME))" 69 142 echo 70 143 71 # if [ "$LOCAL_SUPPORTED_BUILD" != "$REMOTE" ]; then72 # echo "WARNING!!! The currently installed version of the scripts might not support the newer dedicated server build!"73 # echo "If you continue you might not be able to start the server."74 # echo "Please wait for an updated release of the scripts or continue at your own risk."75 # echo76 # fi77 78 144 while : ; do 79 145 local CONTINUE … … 93 159 done 94 160 95 local BRANCH_PARAM=96 if [ "$EXPERIMENTAL" = "yes" ]; then97 BRANCH_PARAM="-beta latest_experimental"98 fi99 100 161 cd $SDTD_BASE/steamcmd 101 ./steamcmd.sh +login anonymous +force_install_dir $SDTD_BASE/engine +app_update 294420 -validate $BRANCH_PARAM +quit 162 local PASSWORDARG= 163 if [ -n "$BRANCHPASSWORD" ]; then 164 PASSWORDARG=-betapassword $BRANCHPASSWORD 165 fi 166 #echo ./steamcmd.sh +login anonymous +force_install_dir $SDTD_BASE/engine +app_update 294420 -validate -beta $BRANCHNAME $PASSWORDARG +quit 167 ./steamcmd.sh +login anonymous +force_install_dir $SDTD_BASE/engine +app_update 294420 -validate -beta $BRANCHNAME $PASSWORDARG +quit 102 168 103 169 if [ -d /usr/local/lib/7dtd/server-fixes ]; then … … 106 172 107 173 chown $SDTD_USER.$SDTD_GROUP -R $SDTD_BASE/engine 108 109 # if [ "$LOCAL_SUPPORTED_BUILD" != "$REMOTE" ]; then 110 # echo 111 # echo "Also update the scripts as soon as there is a new release for this dedicated server build." 112 # echo 113 # fi 114 # else 115 # echo "Engine is already at the newest build (local: $LOCAL, remote: $REMOTE)." 116 # fi 174 else 175 echo "Engine is already at the newest build on the selected branch \"$BRANCHNAME\" (local: $LOCAL, remote: $REMOTE)." 176 echo "Run with the --force parameter to update/validate the engine files anyway." 177 echo "Run with --experimental, --stable or --branch to switch to a different branch." 178 fi 117 179 } 118 180 119 181 sdtdCommandUpdateengineHelp() { 120 echo "Usage: $(basename $0) updateengine [-- experimental]" # [--force | --check]"182 echo "Usage: $(basename $0) updateengine [--check [--showinternal]] [--experimental | --stable] [--branch BRANCHNAME [--password BRANCHPASSWORD]] [--force]" 121 183 echo 122 184 echo "Check for a newer version of engine (aka game) files of 7dtd. If there is a newer" 123 185 echo "version they will be updated by this command." 124 186 echo 125 echo "If --experimental is specified the server will be updated to the" 187 echo "If neither --stable, nor --experimental nor --branch is specified the server will" 188 echo "updated to the latest build on the currently installed Steam branch of the game." 189 echo 190 echo "If --stable is specified the server will be switched to the" 191 echo "default public stable Steam branch of the game." 192 echo 193 echo "If --experimental is specified the server will be switched to the" 126 194 echo "latest_experimental Steam branch of the game." 127 # echo 128 # echo "If --force is specified you are asked if you want to redownload the engine" 129 # echo "even if there is no new version available." 130 # echo 131 # echo "If --check is specified it will only output the current local and remote build ids" 132 # echo "and if an update is available." 195 echo 196 echo "If --branch SOMEBRANCH is specified the server will be switched to the" 197 echo "given Steam branch of the game. Additionally if password is required to acess" 198 echo "the branch this can be specified with the --password argument." 199 echo "NOTE that --password is also required if you previously switched to a branch that" 200 echo "requires a password and want to update to the latest build on that branch now." 201 echo 202 echo "If --force is specified you are asked if you want to redownload the engine" 203 echo "even if there is no new version detected." 204 echo 205 echo "If --check is specified it will only output the current local and remote build ids" 206 echo "and if an update is available." 207 echo "TFP internal branches are only shown if --showinternal is also given." 133 208 } 134 209 … … 138 213 139 214 sdtdCommandUpdateengineExpects() { 140 case $1 in 141 2) 142 echo "--experimental" 143 ;; 144 esac 145 # case $1 in 146 # 2) 147 # echo "--force --check" 148 # ;; 149 # esac 150 echo 151 } 152 215 if [ "$2" = "--password" ]; then 216 echo "" 217 elif [ "$2" = "--branch" ]; then 218 updateRemoteEngineInfo 219 getBranchNames 220 else 221 echo "--check --showinternal --experimental --branch --password --stable --force" 222 fi 223 } 224 225 # Get the latest remote (on Steam) engine version numbers etc 226 updateRemoteEngineInfo() { 227 local DOCHECK=no 228 if [ ! -e /tmp/7dtd-appinfo ]; then 229 DOCHECK=yes 230 else 231 AGE=$((`date +%s` - `stat -L --format %Y /tmp/7dtd-appinfo`)) 232 if [ $AGE -gt 600 ]; then 233 DOCHECK=yes 234 fi 235 fi 236 if [ "$DOCHECK" = "yes" ]; then 237 cd $SDTD_BASE/steamcmd 238 239 ./steamcmd.sh +login anonymous +app_info_request 294420 +app_info_update 1 +app_info_print 294420 +quit | grep -A 1000 \"294420\" 2>/dev/null > /tmp/7dtd-appinfo 240 241 local BUILDID=$(grep -A 1000 \"branches\" /tmp/7dtd-appinfo | grep -A 1000 \"public\" | grep -B 10 \} --max-count=1 | grep \"buildid\" | cut -d\" -f4) 242 243 if [ $(isANumber "$BUILDID") -eq 0 ]; then 244 rm -f /tmp/7dtd-appinfo 245 fi 246 fi 247 } 248 249 # Get the latest build id (on Steam) 250 # Params: 251 # 1. Branch name 252 # Returns: 253 # "?" if data could not be retrieved 254 # BuildId otherwise 255 getBuildId() { 256 local BUILDID=$(grep -A 1000 \"branches\" /tmp/7dtd-appinfo | grep -A 1000 \"$1\" | grep -B 10 \} --max-count=1 | grep \"buildid\" | cut -d\" -f4) 257 258 if [ $(isANumber "$BUILDID") -eq 0 ]; then 259 echo "?" 260 else 261 echo $BUILDID 262 fi 263 } 264 265 # Get the update time of the latest build (on Steam) 266 # Params: 267 # 1. Branch name 268 # Returns: 269 # "?" if data could not be retrieved 270 # Update timestamp otherwise 271 getBuildUpdateTime() { 272 local TIMESTAMP=$(grep -A 1000 \"branches\" /tmp/7dtd-appinfo | grep -A 1000 \"$1\" | grep -B 10 \} --max-count=1 | grep \"timeupdated\" | cut -d\" -f4) 273 274 if [ $(isANumber "$TIMESTAMP") -eq 0 ]; then 275 echo "?" 276 else 277 date --date="@${TIMESTAMP}" "+%Y-%m-%d %H:%M:%S" 278 fi 279 } 280 281 # Get a list of available branch names, blank separated 282 # Returns: 283 # Blank separated list of branch names (can be empty if an error occured) 284 getBranchNames() { 285 grep -A 1000 \"branches\" /tmp/7dtd-appinfo | grep -E '^[[:space:]]*"[^"]+"[[:space:]]*$' | tail --lines=+2 | cut -d\" -f2 286 } 287
Note:
See TracChangeset
for help on using the changeset viewer.