- Timestamp:
- Aug 7, 2017, 7:18:35 AM (7 years ago)
- Location:
- scripts/usr/local/lib/7dtd
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
scripts/usr/local/lib/7dtd/VERSION
r304 r308 1 Version: 10 82 Release: 2017-0 6-291 Version: 109 2 Release: 2017-08-07 3 3 -
scripts/usr/local/lib/7dtd/commands/backup.sh
r258 r308 48 48 fi 49 49 fi 50 50 51 51 if [ ! -d $SDTD_BACKUP_ROOT ]; then 52 52 # Create new backup dir 53 53 mkdir $SDTD_BACKUP_ROOT 54 54 fi 55 56 for H in $(getHooksFor serverPreBackup); do 57 $H 58 done 55 59 56 60 $RSYNC -a --delete --numeric-ids --delete-excluded $SDTD_BASE/instances/./ $NewBackup … … 125 129 fi 126 130 done 131 for H in $(getHooksFor serverPostBackup); do 132 if [ "$SDTD_BACKUP_COMPRESS" = "all" ]; then 133 $H $NewBackup.tar.gz 134 else 135 $H $NewBackup 136 fi 137 done 127 138 } 128 139 -
scripts/usr/local/lib/7dtd/commands/instances.sh
r258 r308 30 30 fi 31 31 32 if [ -z $cur ]; then 33 cur="?" 34 fi 32 35 max=$(getConfigValue $I ServerMaxPlayerCount) 33 36 port=$(getConfigValue $I ServerPort) -
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 -
scripts/usr/local/lib/7dtd/commands/updatescripts.sh
r264 r308 62 62 cd $TMPPATH 63 63 for SRCFILE in `find * -type f`; do 64 DESTFOLDER=/`dirname $SRCFILE` 65 mkdir -p $DESTFOLDER 66 cp -a $SRCFILE $DESTFOLDER/ 64 if [[ $SRCFILE != etc* ]] || [[ $SRCFILE == etc/bash_completion+ ]]; then 65 DESTFOLDER=/`dirname $SRCFILE` 66 mkdir -p $DESTFOLDER 67 cp -a $SRCFILE $DESTFOLDER/ 68 fi 67 69 done 68 70 rm -R $TMPPATH 69 71 70 chown root.root /etc/init.d/7dtd.sh72 # chown root.root /etc/init.d/7dtd.sh 71 73 chown root.root /etc/bash_completion.d/7dtd 72 74 chown root.root /usr/local/bin/7dtd.sh 73 75 chown root.root /usr/local/lib/7dtd -R 74 chmod 0755 /etc/init.d/7dtd.sh76 # chmod 0755 /etc/init.d/7dtd.sh 75 77 chmod 0755 /etc/bash_completion.d/7dtd 76 78 chmod 0755 /usr/local/bin/7dtd.sh -
scripts/usr/local/lib/7dtd/common.sh
r304 r308 111 111 } 112 112 113 # Get the installed branch name 114 # Returns: 115 # "public" if no engine installed or no appmanifest found or buildid could not be read 116 # Branch name 117 getLocalBranch() { 118 local APPMANIFEST=$(find $SDTD_BASE/engine -type f -name "appmanifest_294420.acf") 119 local LOCAL="public" 120 if [ -f "$APPMANIFEST" ]; then 121 LOCAL=$(grep betakey "$APPMANIFEST" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3) 122 if [[ -z $LOCAL ]]; then 123 LOCAL="public" 124 else 125 echo $LOCAL 126 return 127 fi 128 fi 129 echo $LOCAL 130 } 131 113 132 # Get the local engine version number (i.e. build id) 114 133 # Returns: … … 127 146 } 128 147 129 # Get the latest remote engine version number (i.e. build id) 130 # Returns: 131 # 1 if build id could not be retrieved 132 # Build Id otherwise 133 getRemoteEngineVersion() { 134 cd $SDTD_BASE/steamcmd 135 local REMOTE=$(wget -qO- http://steamdb.info/api/GetRawDepots/?appid=294420 | sed 's/\\n/\n/g' | grep -EA 1000 "^\s+\[branches\]" | grep -EA 5 "^\s+\[public\]" | grep -m 1 -EB 10 "^\s+\)$" | grep -E "^\s+\[buildid\]\s+" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f4) 136 137 if [ $(isANumber "$REMOTE") -eq 0 ]; then 138 REMOTE=1 139 fi 140 echo $REMOTE 148 # Get the local engine update time 149 # Returns: 150 # 0 if no engine installed or no appmanifest found or buildid could not be read 151 # Update time otherwise 152 getLocalEngineUpdateTime() { 153 local APPMANIFEST=$(find $SDTD_BASE/engine -type f -name "appmanifest_294420.acf") 154 local LOCAL=0 155 if [ -f "$APPMANIFEST" ]; then 156 LOCAL=$(grep LastUpdated "$APPMANIFEST" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3) 157 if [ $(isANumber "$LOCAL") -eq 0 ]; then 158 LOCAL=0 159 else 160 date --date="@${LOCAL}" "+%Y-%m-%d %H:%M:%S" 161 return 162 fi 163 fi 164 echo $LOCAL 141 165 } 142 166 … … 234 258 # Names of hook files 235 259 getHooksFor() { 236 if [ -n $2]; then260 if [ -n "$2" ]; then 237 261 if [ -d $(getInstancePath $2)/hooks/$1 ]; then 238 262 local H -
scripts/usr/local/lib/7dtd/monitor-log.sh
r298 r308 56 56 for H in $(getHooksFor playerDisconnect $INSTANCE); do 57 57 $H $INSTANCE "$playerId" "$entityId" "$NICKNAME" "$STEAMID" 58 done 59 } 60 61 handlePlayerSpawnedInWorld() { 62 local entityId="$1" 63 local playerId="$2" 64 local ownerId="$3" 65 local playerName="$4" 66 local reason="$5" 67 local position="$6" 68 69 for H in $(getHooksFor playerSpawned $INSTANCE); do 70 $H $INSTANCE "$entityId" "$playerId" "$ownerId" "$playerName" "$reason" "$position" 58 71 done 59 72 } … … 133 146 handleConnect "$entityId" "$playerName" "$steamId" "$ip" "$steamOwner" 134 147 unset entityId playerName steamId steamOwner ip 135 else136 148 #Player disconnected: EntityID=[0-9]*, PlayerID='[0-9]*', OwnerID='[0-9]*', PlayerName='.*'$ 137 if [ -n "$(echo "$line" | grep '^Player disconnected: ')" ]; then149 elif [ -n "$(echo "$line" | grep '^Player disconnected: ')" ]; then 138 150 playerId=$(expr "$line" : "Player disconnected: EntityID=[0-9]*, PlayerID='\([0-9]*\)', OwnerID='[0-9]*', PlayerName='.*'$") 139 151 entityId=$(expr "$line" : "Player disconnected: EntityID=\([0-9]*\), PlayerID='[0-9]*', OwnerID='[0-9]*', PlayerName='.*'$") 140 152 handleDisconnect "$playerId" "$entityId" 141 153 unset playerId entityId 142 else 154 #PlayerSpawnedInWorld (reason: .+, position: [0-9]+, [0-9]+, [0-9]+): EntityID=[0-9]+, PlayerID='[0-9]+', OwnerID='[0-9]+', PlayerName='.*' 155 elif [ -n "$(echo "$line" | grep '^PlayerSpawnedInWorld ')" ]; then 156 reason=$(expr "$line" : "PlayerSpawnedInWorld (reason: \(.+\), position: [0-9]+, [0-9]+, [0-9]+): EntityID=[0-9]+, PlayerID='[0-9]+', OwnerID='[0-9]+', PlayerName='.*'$") 157 position=$(expr "$line" : "PlayerSpawnedInWorld (reason: .+, position: \([0-9]+, [0-9]+, [0-9]+\)): EntityID=[0-9]+, PlayerID='[0-9]+', OwnerID='[0-9]+', PlayerName='.*'$") 158 entityId=$(expr "$line" : "PlayerSpawnedInWorld (reason: .+, position: [0-9]+, [0-9]+, [0-9]+): EntityID=\([0-9]+\), PlayerID='[0-9]+', OwnerID='[0-9]+', PlayerName='.*'$") 159 playerId=$(expr "$line" : "PlayerSpawnedInWorld (reason: .+, position: [0-9]+, [0-9]+, [0-9]+): EntityID=[0-9]+, PlayerID='\([0-9]+\)', OwnerID='[0-9]+', PlayerName='.*'$") 160 ownerId=$(expr "$line" : "PlayerSpawnedInWorld (reason: .+, position: [0-9]+, [0-9]+, [0-9]+): EntityID=[0-9]+, PlayerID='[0-9]+', OwnerID='\([0-9]+\)', PlayerName='.*'$") 161 playerName=$(expr "$line" : "PlayerSpawnedInWorld (reason: .+, position: [0-9]+, [0-9]+, [0-9]+): EntityID=[0-9]+, PlayerID='[0-9]+', OwnerID='[0-9]+', PlayerName='\(.*\)'$") 162 handlePlayerSpawnedInWorld "$entityId" "$playerId" "$ownerId" "$playerName" "$reason" "$position" 163 unset reason position entityId playerId ownerId playerName 143 164 #GMSG: .*$ 144 if [ -n "$(echo "$line" | grep -E '^GMSG: .+')" ]; then165 elif [ -n "$(echo "$line" | grep -E '^GMSG: .+')" ]; then 145 166 msg=$(expr "$line" : 'GMSG: \(.*\)$') 146 167 handleGmsg "$msg" 147 168 unset msg 148 else149 169 #Chat: 'name': .*$ 150 if [ -n "$(echo "$line" | grep -E '^Chat: .+')" ]; then170 elif [ -n "$(echo "$line" | grep -E '^Chat: .+')" ]; then 151 171 name=$(expr "$line" : "Chat: '\(.*\)': .*$") 152 172 msg=$(expr "$line" : "Chat: '.*': \(.*\)$") 153 173 handleChat "$name" "$msg" 154 174 unset name msg 155 else156 175 #Executing command ".*" from client ".*"$ 157 if [ -n "$(echo "$line" | grep '^Executing command '.*' from client')" ]; then176 elif [ -n "$(echo "$line" | grep '^Executing command '.*' from client')" ]; then 158 177 cmd=$(expr "$line" : "Executing command '\(.*\)' from client .*$") 159 178 nick=$(expr "$line" : "Executing command '.*' from client \(.*\)$") 160 179 handleRemoteCommand "$cmd" "$nick" 161 180 unset cmd nick 162 else163 181 #Executing command ".*" by Telnet from .*$ 164 if [ -n "$(echo "$line" | grep '^Executing command '.*' by Telnet from ')" ]; then182 elif [ -n "$(echo "$line" | grep '^Executing command '.*' by Telnet from ')" ]; then 165 183 cmd=$(expr "$line" : "Executing command '\(.*\)' by Telnet from .*$") 166 184 ip=$(expr "$line" : "Executing command '.*' by Telnet from \(.*\)$") … … 168 186 unset cmd ip 169 187 fi 170 fi171 fi172 fi173 fi174 fi175 188 fi 176 189 done -
scripts/usr/local/lib/7dtd/serverconfig.sh
r303 r308 330 330 } 331 331 serverconfig_DayNightLength_Default() { 332 echo " 50"332 echo "60" 333 333 } 334 334
Note:
See TracChangeset
for help on using the changeset viewer.