2019-03-14 09:33:35 +00:00
|
|
|
#!/bin/bash
|
2018-06-22 13:29:47 +00:00
|
|
|
|
2018-06-26 10:09:08 +00:00
|
|
|
#
|
|
|
|
# Copyright (C) 2018 GNS3 Technologies Inc.
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#
|
|
|
|
# Syncs WebUI with gns3server
|
|
|
|
#
|
2019-03-07 10:56:15 +00:00
|
|
|
# For updating with fresh latest repo just type (latest, development version):
|
2019-03-14 09:33:35 +00:00
|
|
|
# $ ./scripts/update-bundled-web-ui.sh
|
2018-06-26 10:09:08 +00:00
|
|
|
#
|
2019-03-07 10:56:15 +00:00
|
|
|
# It's also possible to update with custom repo:
|
2019-03-14 09:33:35 +00:00
|
|
|
# $ ./scripts/update-bundled-web-ui.sh --repository ../my-custom-web-ui-repo/
|
2019-03-07 10:56:15 +00:00
|
|
|
#
|
|
|
|
# And for proper tag:
|
2019-03-14 09:33:35 +00:00
|
|
|
# $ ./scripts/update-bundled-web-ui.sh --tag=v2019.1.0-alpha.1
|
2018-06-26 10:09:08 +00:00
|
|
|
#
|
2019-03-07 10:56:15 +00:00
|
|
|
set -e
|
2018-06-26 10:09:08 +00:00
|
|
|
|
2019-01-29 09:02:39 +00:00
|
|
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
2018-06-26 10:09:08 +00:00
|
|
|
GNS3SERVER_DIR=$(realpath "$CURRENT_DIR/..")
|
|
|
|
REPO_DIR="/tmp/gns3-web-ui"
|
|
|
|
CUSTOM_REPO=false
|
|
|
|
|
2019-03-07 10:56:15 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2018-06-26 10:09:08 +00:00
|
|
|
|
|
|
|
echo "Removing: $GNS3SERVER_DIR/gns3server/static/web-ui/*"
|
|
|
|
|
|
|
|
rm -rf $GNS3SERVER_DIR/gns3server/static/web-ui/*
|
|
|
|
|
|
|
|
echo "Re-create: $GNS3SERVER_DIR/gns3server/static/web-ui"
|
|
|
|
|
|
|
|
mkdir -p "$GNS3SERVER_DIR/gns3server/static/web-ui/"
|
|
|
|
|
|
|
|
if [ "$CUSTOM_REPO" = false ] ; then
|
|
|
|
if [ ! -d /tmp/gns3-web-ui ]; then
|
|
|
|
git clone https://github.com/GNS3/gns3-web-ui.git "$REPO_DIR"
|
2019-01-29 09:02:39 +00:00
|
|
|
else
|
|
|
|
cd "$REPO_DIR"
|
2019-03-14 09:33:35 +00:00
|
|
|
|
|
|
|
git checkout master
|
2019-03-22 13:12:51 +00:00
|
|
|
git fetch --tags
|
2019-01-29 09:02:39 +00:00
|
|
|
git pull
|
2019-03-07 10:56:15 +00:00
|
|
|
|
2022-04-27 11:24:36 +00:00
|
|
|
if [[ -n "$TAG" ]]
|
2019-03-07 10:56:15 +00:00
|
|
|
then
|
|
|
|
echo "Switching to tag: ${TAG}"
|
|
|
|
git checkout "tags/${TAG}"
|
|
|
|
fi
|
|
|
|
|
2019-01-29 09:02:39 +00:00
|
|
|
cd "$CURRENT_DIR"
|
2018-06-26 10:09:08 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Current working dir $REPO_DIR"
|
|
|
|
|
|
|
|
cd "$REPO_DIR"
|
|
|
|
|
|
|
|
yarn install
|
2019-03-27 11:34:45 +00:00
|
|
|
yarn ng build --source-map=false --configuration=production --base-href /static/web-ui/
|
2018-06-26 10:09:08 +00:00
|
|
|
|
|
|
|
cp -R $REPO_DIR/dist/* "$GNS3SERVER_DIR/gns3server/static/web-ui/"
|
|
|
|
|
|
|
|
cd "$GNS3SERVER_DIR"
|