[17] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
[258] | 3 | # Copyright 2016 Christian 'Alloc' Illy
|
---|
| 4 | #
|
---|
| 5 | # Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 6 | # you may not use this file except in compliance with the License.
|
---|
| 7 | # You may obtain a copy of the License at
|
---|
| 8 | #
|
---|
| 9 | # http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 10 | #
|
---|
| 11 | # Unless required by applicable law or agreed to in writing, software
|
---|
| 12 | # distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 14 | # See the License for the specific language governing permissions and
|
---|
| 15 | # limitations under the License.
|
---|
| 16 |
|
---|
| 17 |
|
---|
[48] | 18 | # Downloads SteamCMD, downloads/updates the 7dtd engine
|
---|
[17] | 19 |
|
---|
| 20 | sdtdCommandUpdateengine() {
|
---|
[248] | 21 | # local FORCED=no
|
---|
| 22 | # if [ "$1" = "--force" ]; then
|
---|
| 23 | # FORCED=yes
|
---|
| 24 | # fi
|
---|
[17] | 25 |
|
---|
[265] | 26 | local EXPERIMENTAL=no
|
---|
| 27 | if [ "$1" = "--experimental" ]; then
|
---|
| 28 | EXPERIMENTAL=yes
|
---|
| 29 | fi
|
---|
| 30 |
|
---|
[28] | 31 | if [ ! -e $SDTD_BASE/steamcmd ]; then
|
---|
| 32 | mkdir $SDTD_BASE/steamcmd
|
---|
[17] | 33 | cd /tmp
|
---|
| 34 | wget http://media.steampowered.com/installer/steamcmd_linux.tar.gz
|
---|
[28] | 35 | tar -xvzf steamcmd_linux.tar.gz -C $SDTD_BASE/steamcmd
|
---|
| 36 | cd $SDTD_BASE/steamcmd
|
---|
[17] | 37 | ./steamcmd.sh +quit
|
---|
| 38 | fi
|
---|
| 39 |
|
---|
[248] | 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
|
---|
[17] | 52 |
|
---|
[53] | 53 | for I in $(getInstanceList); do
|
---|
| 54 | if [ $(isRunning $I) -eq 1 ]; then
|
---|
| 55 | echo "At least one instance is still running (\"$I\")."
|
---|
| 56 | echo "Before updating the engine please stop all instances!"
|
---|
| 57 | return
|
---|
| 58 | fi
|
---|
| 59 | done
|
---|
[17] | 60 |
|
---|
[53] | 61 | local LOCAL=$(getLocalEngineVersion)
|
---|
[229] | 62 | #local REMOTE=$(getRemoteEngineVersion)
|
---|
[248] | 63 | #local LOCAL_SUPPORTED_BUILD=$(cat /usr/local/lib/7dtd/VERSION | grep "DediBuild" | cut -d\ -f2)
|
---|
[35] | 64 |
|
---|
[229] | 65 | # if [ "$FORCED" = "yes" -o $REMOTE -gt $LOCAL ]; then
|
---|
| 66 | # echo "A newer version of the engine is available."
|
---|
[53] | 67 | echo "Local buildid: $LOCAL"
|
---|
[229] | 68 | #echo "Available buildid: $REMOTE"
|
---|
[53] | 69 | echo
|
---|
[87] | 70 |
|
---|
[229] | 71 | # if [ "$LOCAL_SUPPORTED_BUILD" != "$REMOTE" ]; then
|
---|
[248] | 72 | # 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."
|
---|
[229] | 74 | # echo "Please wait for an updated release of the scripts or continue at your own risk."
|
---|
[248] | 75 | # echo
|
---|
[229] | 76 | # fi
|
---|
[87] | 77 |
|
---|
[53] | 78 | while : ; do
|
---|
| 79 | local CONTINUE
|
---|
| 80 | read -p "Continue? (yn) " CONTINUE
|
---|
| 81 | case $CONTINUE in
|
---|
| 82 | y)
|
---|
| 83 | echo "Updating..."
|
---|
| 84 | break
|
---|
| 85 | ;;
|
---|
| 86 | n)
|
---|
| 87 | echo "Canceled"
|
---|
| 88 | return
|
---|
| 89 | ;;
|
---|
| 90 | *)
|
---|
| 91 | echo "Wrong input"
|
---|
| 92 | esac
|
---|
| 93 | done
|
---|
[229] | 94 |
|
---|
[265] | 95 | local BRANCH_PARAM=
|
---|
| 96 | if [ "$EXPERIMENTAL" = "yes" ]; then
|
---|
| 97 | BRANCH_PARAM="-beta latest_experimental"
|
---|
| 98 | fi
|
---|
| 99 |
|
---|
[53] | 100 | cd $SDTD_BASE/steamcmd
|
---|
[265] | 101 | ./steamcmd.sh +login anonymous +force_install_dir $SDTD_BASE/engine +app_update 294420 -validate $BRANCH_PARAM +quit
|
---|
[53] | 102 |
|
---|
[248] | 103 | if [ -d /usr/local/lib/7dtd/server-fixes ]; then
|
---|
[257] | 104 | cp /usr/local/lib/7dtd/server-fixes/* $SDTD_BASE/engine/ -R
|
---|
[248] | 105 | fi
|
---|
[53] | 106 |
|
---|
| 107 | chown $SDTD_USER.$SDTD_GROUP -R $SDTD_BASE/engine
|
---|
[87] | 108 |
|
---|
[248] | 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
|
---|
[229] | 114 | # else
|
---|
| 115 | # echo "Engine is already at the newest build (local: $LOCAL, remote: $REMOTE)."
|
---|
| 116 | # fi
|
---|
[17] | 117 | }
|
---|
| 118 |
|
---|
| 119 | sdtdCommandUpdateengineHelp() {
|
---|
[265] | 120 | echo "Usage: $(basename $0) updateengine [--experimental]" # [--force | --check]"
|
---|
[17] | 121 | echo
|
---|
[53] | 122 | echo "Check for a newer version of engine (aka game) files of 7dtd. If there is a newer"
|
---|
[229] | 123 | echo "version they will be updated by this command."
|
---|
[265] | 124 | echo
|
---|
| 125 | echo "If --experimental is specified the server will be updated to the"
|
---|
| 126 | echo "latest_experimental Steam branch of the game."
|
---|
[229] | 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."
|
---|
[17] | 133 | }
|
---|
| 134 |
|
---|
| 135 | sdtdCommandUpdateengineDescription() {
|
---|
| 136 | echo "Update the 7dtd engine files"
|
---|
| 137 | }
|
---|
[53] | 138 |
|
---|
| 139 | sdtdCommandUpdateengineExpects() {
|
---|
[265] | 140 | case $1 in
|
---|
| 141 | 2)
|
---|
| 142 | echo "--experimental"
|
---|
| 143 | ;;
|
---|
| 144 | esac
|
---|
[229] | 145 | # case $1 in
|
---|
| 146 | # 2)
|
---|
| 147 | # echo "--force --check"
|
---|
| 148 | # ;;
|
---|
| 149 | # esac
|
---|
[231] | 150 | echo
|
---|
[53] | 151 | }
|
---|
| 152 |
|
---|