Commit cea1381482bead3271998408cc1cb73506061e7b

Authored by Michael Hamburger
Committed by Igor Kulikov
1 parent 89dbad2c

add upgrade_dev_db.sh script, which allows to upgrade an already existing developer database (#2267)

  1 +#!/bin/bash
  2 +#
  3 +# Copyright © 2016-2019 The Thingsboard Authors
  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 +
  18 +for i in "$@"
  19 +do
  20 +case $i in
  21 + --fromVersion=*)
  22 + FROM_VERSION="${i#*=}"
  23 + shift
  24 + ;;
  25 + *)
  26 + # unknown option
  27 + ;;
  28 +esac
  29 +done
  30 +
  31 +if [[ -z "${FROM_VERSION// }" ]]; then
  32 + echo "--fromVersion parameter is invalid or unspecified!"
  33 + echo "Usage: upgrade_dev_db.sh --fromVersion={VERSION}"
  34 + exit 1
  35 +else
  36 + fromVersion="${FROM_VERSION// }"
  37 +fi
  38 +
  39 +BASE=${project.basedir}/target
  40 +CONF_FOLDER=${BASE}/conf
  41 +jarfile="${BASE}/thingsboard-${project.version}-boot.jar"
  42 +installDir=${BASE}/data
  43 +loadDemo=true
  44 +
  45 +
  46 +export JAVA_OPTS="$JAVA_OPTS -Dplatform=@pkg.platform@"
  47 +export LOADER_PATH=${BASE}/conf,${BASE}/extensions
  48 +export SQL_DATA_FOLDER=${SQL_DATA_FOLDER:-/tmp}
  49 +
  50 +
  51 +run_user="$USER"
  52 +
  53 +sudo -u "$run_user" -s /bin/sh -c "java -cp ${jarfile} $JAVA_OPTS -Dloader.main=org.thingsboard.server.ThingsboardInstallApplication \
  54 + -Dinstall.data_dir=${installDir} \
  55 + -Dinstall.load_demo=${loadDemo} \
  56 + -Dspring.jpa.hibernate.ddl-auto=none \
  57 + -Dinstall.upgrade=true \
  58 + -Dinstall.upgrade.from_version=${fromVersion} \
  59 + -Dlogging.config=logback.xml \
  60 + org.springframework.boot.loader.PropertiesLauncher"
  61 +
  62 +if [ $? -ne 0 ]; then
  63 + echo "ThingsBoard DB installation failed!"
  64 +else
  65 + echo "ThingsBoard DB installed successfully!"
  66 +fi
  67 +
  68 +exit $?
... ...