diff --git a/installation/resource/installer/bin/upgrade.sh b/installation/resource/installer/bin/upgrade.sh index 68d3b9fdd9ead8d19e7dbe263c7e27d17b5f3812..0fe91fcdacbbc1f1c700dad055f261de713270e1 100755 --- a/installation/resource/installer/bin/upgrade.sh +++ b/installation/resource/installer/bin/upgrade.sh @@ -2,6 +2,37 @@ # Upgrades openbis AS and DSS. # Assumes that openbis is installed in the 'servers' directory on the same level as this script parent directory +# +# Upgrades the installation from an installer tarball +# +upgrade_from_installer_tarball() +{ + +OPENBIS_INSTALL_DIR=$BASE/.. +TARBALL=$1 +INSTALLER_DIR=${TARBALL%.tar.gz} + +pushd $ROOT_DIR > /dev/null + +echo "Extracting installation tarball $TARBALL.." +tar xzf $TARBALL + +popd > /dev/null + +# set INSTALL_PATH in the console.properties +sed_params='s#^INSTALL_PATH=.*$#INSTALL_PATH='$OPENBIS_INSTALL_DIR'#' +sed -i '' "$sed_params" $INSTALLER_DIR/console.properties + +# run the installation +$INSTALLER_DIR/run-console.sh + +rm -rf $INSTALLER_DIR + +echo "Moving $TARBALL to $OPENBIS_INSTALL_DIR/backup ..." +mkdir -p $OPENBIS_INSTALL_DIR/backup +mv $TARBALL $OPENBIS_INSTALL_DIR/backup +} + BASE=`dirname "$0"` if [ ${BASE#/} == ${BASE} ]; then BASE="`pwd`/${BASE}" @@ -12,36 +43,19 @@ source $BASE/common-functions.sh ROOT_DIR=$BASE/../servers -NOW=`date +%y%m%d-%H%M` -BACKUP_DIR=$BASE/../backup/$NOW - $BASE/alldown.sh +installer_tarball="" +for installer_tarball in $ROOT_DIR/*.tar.gz; do + : # only use the loop to assign the correct value of the installer_tarball +done -CONFIG=$BACKUP_DIR/config-backup -mkdir -p $CONFIG -$BASE/backup-config.sh $CONFIG - -OLD_BIS=$BACKUP_DIR/openBIS-server - -echo "Copying old installation to backup dir" -echo "mv $ROOT_DIR/openBIS-server $OLD_BIS" -echo "mv $ROOT_DIR/datastore_server $BACKUP_DIR/datastore_server" - -mv $ROOT_DIR/openBIS-server $OLD_BIS -mv $ROOT_DIR/datastore_server $BACKUP_DIR/datastore_server - -# Note: to restore the database afterwards one can use: -# pg_restore -d db-name db-file.dmp -$PG_DUMP -U $DB_USER_NAME -Fc $OPENBIS_DB > $BACKUP_DIR/$OPENBIS_DB-${NOW}.dmp -# screening-specific -$PG_DUMP -U $DB_USER_NAME -Fc $IMAGING_DB > $BACKUP_DIR/$IMAGING_DB-${NOW}.dmp - -installOpenBisServer $ROOT_DIR -installDataStoreServer $ROOT_DIR +if [ -f "$installer_tarball" ]; then + upgrade_from_installer_tarball $installer_tarball +else + echo "No installer tarball has been found under $ROOT_DIR. Aborting..." + exit 1 +fi -$BASE/restore-config-from-backup.sh $CONFIG -cp -r $OLD_BIS/jetty/indices* $ROOT_DIR/openBIS-server/jetty/ -mv $ROOT_DIR/*.zip $BACKUP_DIR/ $BASE/allup.sh \ No newline at end of file diff --git a/installation/resource/tarball/run-console.sh b/installation/resource/tarball/run-console.sh index b146ea323c1692033080cd9bc4a4e6ff1be42fed..de53b5299bb0adaffd215b56f060bdec1e7ed9cc 100755 --- a/installation/resource/tarball/run-console.sh +++ b/installation/resource/tarball/run-console.sh @@ -42,27 +42,26 @@ if [ ${BASE#/} == ${BASE} ]; then BASE="`pwd`/${BASE}" fi +ensureToolOnPath "java" +ensureToolOnPath "psql" +ensureToolOnPath "pg_dump" + install_path=$( grep -e "^INSTALL_PATH=.*$" $BASE/console.properties | sed "s/INSTALL_PATH=//" ) if [ -z "$install_path" ]; then echo "The property INSTALL_PATH must be configured in $BASE/console.properties." echo "Please edit the file and run the installation script again." exit 1 fi - -dss_root_dir=$( grep -e "^DSS_ROOT_DIR=.*$" $BASE/console.properties | sed "s/DSS_ROOT_DIR=//" ) -if [ -z "$dss_root_dir" ]; then - echo "The property DSS_ROOT_DIR must be configured in $BASE/console.properties." - echo "Please edit the file and run the installation script again." - exit 1 -fi - -ensureToolOnPath "java" -ensureToolOnPath "psql" -ensureToolOnPath "pg_dump" if [ -d "$install_path" ]; then echo "Previous openBIS installation detected. Upgrading..." else + dss_root_dir=$( grep -e "^DSS_ROOT_DIR=.*$" $BASE/console.properties | sed "s/DSS_ROOT_DIR=//" ) + if [ -z "$dss_root_dir" ]; then + echo "The property DSS_ROOT_DIR must be configured in $BASE/console.properties." + echo "Please edit the file and run the installation script again." + exit 1 + fi readAdminPassword fi diff --git a/openbis/dist/admin/upgrade.sh b/openbis/dist/admin/upgrade.sh index c876c12acb700ff0f06eb7414a7d032840e03fe7..e654693d19af8e4cc0eb3cfe8717e5e303e6d6c7 100755 --- a/openbis/dist/admin/upgrade.sh +++ b/openbis/dist/admin/upgrade.sh @@ -2,22 +2,16 @@ # Upgrades openbis AS and DSS. # Assumes that openbis is installed in the 'servers' directory on the same level as this script parent directory -BASE=`dirname "$0"` -if [ ${BASE#/} == ${BASE} ]; then - BASE="`pwd`/${BASE}" -fi - -source $BASE/env -source $BASE/common-functions.sh -ROOT_DIR=$BASE/../servers +# +# Upgrades the installation from two separate ZIP files +# (AS, DSS) dropped into the "servers" directory. +# +upgrade_from_zips() +{ NOW=`date +%y%m%d-%H%M` BACKUP_DIR=$BASE/../backup/$NOW - -$BASE/alldown.sh - - CONFIG=$BACKUP_DIR/config-backup mkdir -p $CONFIG $BASE/backup-config.sh $CONFIG @@ -33,7 +27,7 @@ mv $ROOT_DIR/datastore_server $BACKUP_DIR/datastore_server # Note: to restore the database afterwards one can use: # pg_restore -d db-name db-file.dmp -pg_dump -U $DB_USER_NAME -Fc $OPENBIS_DB > $BACKUP_DIR/$OPENBIS_DB-${NOW}.dmp +$PG_DUMP -U $DB_USER_NAME -Fc $OPENBIS_DB > $BACKUP_DIR/$OPENBIS_DB-${NOW}.dmp installOpenBisServer $ROOT_DIR installDataStoreServer $ROOT_DIR @@ -42,4 +36,62 @@ $BASE/restore-config-from-backup.sh $CONFIG cp -r $OLD_BIS/jetty/indices* $ROOT_DIR/openBIS-server/jetty/ mv $ROOT_DIR/*.zip $BACKUP_DIR/ + +} + +# +# Upgrades the installation from an installer tarball +# +upgrade_from_installer_tarball() +{ + +OPENBIS_INSTALL_DIR=$BASE/.. +TARBALL=$1 +INSTALLER_DIR=${TARBALL%.tar.gz} + +pushd $ROOT_DIR > /dev/null + +echo "Extracting installation tarball $TARBALL.." +tar xzf $TARBALL + +popd > /dev/null + +# set INSTALL_PATH in the console.properties +sed_params='s#^INSTALL_PATH=.*$#INSTALL_PATH='$OPENBIS_INSTALL_DIR'#' +sed -i '' "$sed_params" $INSTALLER_DIR/console.properties + +# run the installation +$INSTALLER_DIR/run-console.sh + +rm -rf $INSTALLER_DIR + +echo "Moving $TARBALL to $OPENBIS_INSTALL_DIR/backup ..." +mkdir -p $OPENBIS_INSTALL_DIR/backup +mv $TARBALL $OPENBIS_INSTALL_DIR/backup +} + +BASE=`dirname "$0"` +if [ ${BASE#/} == ${BASE} ]; then + BASE="`pwd`/${BASE}" +fi + +source $BASE/env +source $BASE/common-functions.sh + +ROOT_DIR=$BASE/../servers + +$BASE/alldown.sh + +installer_tarball="" +for installer_tarball in $ROOT_DIR/*.tar.gz; do + : # only use the loop to assign the correct value of the installer_tarball +done + +if [ -f "$installer_tarball" ]; then + upgrade_from_installer_tarball $installer_tarball +else + upgrade_from_zips +fi + + $BASE/allup.sh \ No newline at end of file diff --git a/screening/dist/admin/upgrade.sh b/screening/dist/admin/upgrade.sh index 68d3b9fdd9ead8d19e7dbe263c7e27d17b5f3812..ebd5520a8eeda58d71e737c0efd5db158ff7de07 100755 --- a/screening/dist/admin/upgrade.sh +++ b/screening/dist/admin/upgrade.sh @@ -2,22 +2,16 @@ # Upgrades openbis AS and DSS. # Assumes that openbis is installed in the 'servers' directory on the same level as this script parent directory -BASE=`dirname "$0"` -if [ ${BASE#/} == ${BASE} ]; then - BASE="`pwd`/${BASE}" -fi - -source $BASE/env -source $BASE/common-functions.sh -ROOT_DIR=$BASE/../servers +# +# Upgrades the installation from two separate ZIP files +# (AS, DSS) dropped into the "servers" directory. +# +upgrade_from_zips() +{ NOW=`date +%y%m%d-%H%M` BACKUP_DIR=$BASE/../backup/$NOW - -$BASE/alldown.sh - - CONFIG=$BACKUP_DIR/config-backup mkdir -p $CONFIG $BASE/backup-config.sh $CONFIG @@ -44,4 +38,62 @@ $BASE/restore-config-from-backup.sh $CONFIG cp -r $OLD_BIS/jetty/indices* $ROOT_DIR/openBIS-server/jetty/ mv $ROOT_DIR/*.zip $BACKUP_DIR/ + +} + +# +# Upgrades the installation from an installer tarball +# +upgrade_from_installer_tarball() +{ + +OPENBIS_INSTALL_DIR=$BASE/.. +TARBALL=$1 +INSTALLER_DIR=${TARBALL%.tar.gz} + +pushd $ROOT_DIR > /dev/null + +echo "Extracting installation tarball $TARBALL.." +tar xzf $TARBALL + +popd > /dev/null + +# set INSTALL_PATH in the console.properties +sed_params='s#^INSTALL_PATH=.*$#INSTALL_PATH='$OPENBIS_INSTALL_DIR'#' +sed -i '' "$sed_params" $INSTALLER_DIR/console.properties + +# run the installation +$INSTALLER_DIR/run-console.sh + +rm -rf $INSTALLER_DIR + +echo "Moving $TARBALL to $OPENBIS_INSTALL_DIR/backup ..." +mkdir -p $OPENBIS_INSTALL_DIR/backup +mv $TARBALL $OPENBIS_INSTALL_DIR/backup +} + +BASE=`dirname "$0"` +if [ ${BASE#/} == ${BASE} ]; then + BASE="`pwd`/${BASE}" +fi + +source $BASE/env +source $BASE/common-functions.sh + +ROOT_DIR=$BASE/../servers + +$BASE/alldown.sh + +installer_tarball="" +for installer_tarball in $ROOT_DIR/*.tar.gz; do + : # only use the loop to assign the correct value of the installer_tarball +done + +if [ -f "$installer_tarball" ]; then + upgrade_from_installer_tarball $installer_tarball +else + upgrade_from_zips +fi + + $BASE/allup.sh \ No newline at end of file