diff --git a/scripts/update-bundled-web-ui.sh b/scripts/update-bundled-web-ui.sh index 401bc511..bb3987e6 100755 --- a/scripts/update-bundled-web-ui.sh +++ b/scripts/update-bundled-web-ui.sh @@ -19,24 +19,44 @@ # # Syncs WebUI with gns3server # -# For updating with fresh latest repo just type: +# For updating with fresh latest repo just type (latest, development version): # $ sh update-bundled-web-ui.sh # -# It's also possible to update with custom repo and branch by: -# $ sh update-bundled-web-ui.sh ../my-custom-web-ui-repo/ +# It's also possible to update with custom repo: +# $ sh update-bundled-web-ui.sh --repository ../my-custom-web-ui-repo/ +# +# And for proper tag: +# $ sh update-bundled-web-ui.sh --tag 2019.1.0-alpha.0 # +set -e CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" GNS3SERVER_DIR=$(realpath "$CURRENT_DIR/..") REPO_DIR="/tmp/gns3-web-ui" CUSTOM_REPO=false -if [ $# -eq 1 ]; then - PARAM="$1" - CUSTOM_REPO=true - REPO_DIR=$(realpath "$PWD/${PARAM%/}") - echo "Custom repo dir: $REPO_DIR" -fi + +for i in "$@" +do + case $i in + -r=*|--repository=*) + REPOSITORY="${i#*=}" + CUSTOM_REPO=true + REPO_DIR=$(realpath "$PWD/${REPOSITORY%/}") + echo "Custom repo dir: $REPO_DIR" + shift + ;; + -t=*|--tag=*) + TAG="${i#*=}" + echo "Using tag: $TAG" + shift + ;; + *) + # unknown option + ;; + esac +done + echo "Removing: $GNS3SERVER_DIR/gns3server/static/web-ui/*" @@ -52,6 +72,13 @@ if [ "$CUSTOM_REPO" = false ] ; then else cd "$REPO_DIR" git pull + + if [[ ! -z "$TAG" ]] + then + echo "Switching to tag: ${TAG}" + git checkout "tags/${TAG}" + fi + cd "$CURRENT_DIR" fi fi