|
2 | 2 | # exit if anything returns failure |
3 | 3 | set -e |
4 | 4 |
|
| 5 | +if [ "$1" = "silent" ]; |
| 6 | +then |
| 7 | + GEOSHAPE_SILENT=true |
| 8 | + GEOSHAPE_VERSION="$2" |
| 9 | +elif [ "$2" = "silent" ]; |
| 10 | +then |
| 11 | + GEOSHAPE_SILENT=true |
| 12 | + GEOSHAPE_VERSION="$1" |
| 13 | +else |
| 14 | + GEOSHAPE_VERSION="$1" |
| 15 | +fi |
| 16 | + |
| 17 | +if [ "$GEOSHAPE_SILENT" != true ]; then |
| 18 | + echo "====[ WARNING: |
| 19 | + You are attempting to upgrade the installation of geoshape. Before proceeding, you should backup |
| 20 | + this machine. If it is a virtual machine, you should create a snapshot so that you can undo the changes |
| 21 | + if there are any incompatibilities. In some cases, the database may no longer operate as expented resulting |
| 22 | + in potential loss of data. Note that only some upgrades can complete successfully! Before continuing |
| 23 | + you should review changes introduced between the geoshape version you are currently on and the version |
| 24 | + you are attempting to upgrade to. There could be many backwards incompatible changes introduced at |
| 25 | + any of the geoshape dependencies. In some cases, a clean installation of geoshape might be necessary |
| 26 | + to get the latest functionality successfully. For example, the geoserver_data directory required by |
| 27 | + the latest version of geoshape, may contain some configuration or scripts that doesn't make it |
| 28 | + possible to simply keep your current /var/lib/geoserver_data directory. Similar issues could arise for |
| 29 | + many other dependencies of geoshape. This script is only intended for advanced users! The safest way |
| 30 | + the to upgrade geoshape is to create a new instance and migrate your data." |
| 31 | + |
| 32 | + while true; do |
| 33 | + read -p "=> Are you sure you want to continue? " yn |
| 34 | + case $yn in |
| 35 | + [Yy]* ) break;; |
| 36 | + [Nn]* ) echo " geoshape upgrade exited. ";exit;; |
| 37 | + * ) echo " Please answer yes or no.";; |
| 38 | + esac |
| 39 | + done |
| 40 | +fi |
| 41 | + |
5 | 42 | # store current directory |
6 | 43 | pushd . |
7 | 44 |
|
8 | 45 | cd /opt/rogue-chef-repo |
9 | 46 |
|
| 47 | +# get latest tags/branchs |
| 48 | +git fetch |
| 49 | + |
| 50 | +if [ -z "$GEOSHAPE_VERSION" ]; |
| 51 | +then |
| 52 | + # discover the latest release tag |
| 53 | + RELEASE_TAGS=(`git tag`) |
| 54 | + echo 'release tags: ' |
| 55 | + echo "${RELEASE_TAGS[@]}" |
| 56 | + # sort the list of branches that had '.' in them such that index 0 is the largest one |
| 57 | + RELEASE_TAGS_SORTED=($(printf '%s\n' "${RELEASE_TAGS[@]}"|sort -r)) |
| 58 | + UPGRADE_TO_GEOSHAPE_VERSION=${RELEASE_TAGS_SORTED[0]} |
| 59 | +fi |
| 60 | + |
| 61 | +if [ -z "$GEOSHAPE_VERSION" ]; |
| 62 | +then |
| 63 | + echo 'Note: geoshape version was not specified, did you intend to upgrade to release: '${UPGRADE_TO_GEOSHAPE_VERSION} |
| 64 | + while true; do |
| 65 | + read -p "=> Are you sure you want to continue? " yn |
| 66 | + case $yn in |
| 67 | + [Yy]* ) break;; |
| 68 | + [Nn]* ) echo " geoshape upgrade exited. ";exit;; |
| 69 | + * ) echo " Please answer yes or no.";; |
| 70 | + esac |
| 71 | + done |
| 72 | +fi |
| 73 | + |
| 74 | +GEOSHAPE_VERSION=$UPGRADE_TO_GEOSHAPE_VERSION |
| 75 | + |
| 76 | +# checkout the requests 'version' (tag, branch, commit) |
| 77 | +git checkout ${GEOSHAPE_VERSION} |
| 78 | + |
| 79 | +# if on a branch, do a pull to get latest on local branch. When a branch is used, user essentially wants the latets |
| 80 | +# 'snapshot' from the specified branch (version) |
10 | 81 | CURRENT_BRANCH=`git branch | sed -n '/\* /s///p'` |
11 | 82 | if ["$CURRENT_BRANCH" != "(no branch)"] |
12 | 83 | then |
|
0 commit comments