From 93ddcac90d8891290ac33395f5b0aac953e34279 Mon Sep 17 00:00:00 2001 From: Arturs Sosins Date: Tue, 9 Aug 2022 13:45:26 +0300 Subject: [PATCH] [upgrade] empty upgrade script to mark versions --- bin/upgrade/22.08/upgrade.sh | 13 +++++++++ bin/upgrade/22.08/upgrade_db.sh | 44 +++++++++++++++++++++++++++++ bin/upgrade/22.08/upgrade_fs.sh | 49 +++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 bin/upgrade/22.08/upgrade.sh create mode 100644 bin/upgrade/22.08/upgrade_db.sh create mode 100644 bin/upgrade/22.08/upgrade_fs.sh diff --git a/bin/upgrade/22.08/upgrade.sh b/bin/upgrade/22.08/upgrade.sh new file mode 100644 index 00000000000..54565dd038e --- /dev/null +++ b/bin/upgrade/22.08/upgrade.sh @@ -0,0 +1,13 @@ +#!/bin/bash +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +DATE=$(date +%Y-%m-%d:%H:%M:%S) +VERSION="$(basename "${DIR}")" + +countly stop +if [ -f "$DIR/upgrade_fs.sh" ]; then + bash "$DIR/upgrade_fs.sh" combined 2>&1 | tee -a "$DIR/../../../log/countly-upgrade-fs-$VERSION-$DATE.log" +fi +if [ -f "$DIR/upgrade_db.sh" ]; then + bash "$DIR/upgrade_db.sh" combined 2>&1 | tee -a "$DIR/../../../log/countly-upgrade-db-$VERSION-$DATE.log" +fi +countly upgrade diff --git a/bin/upgrade/22.08/upgrade_db.sh b/bin/upgrade/22.08/upgrade_db.sh new file mode 100644 index 00000000000..54f290ef7a3 --- /dev/null +++ b/bin/upgrade/22.08/upgrade_db.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +VER="22.08" + +CONTINUE="$(countly check before upgrade db "$VER")" + +if [ "$CONTINUE" != "1" ] && [ "$1" != "combined" ] +then + echo "Database is already up to date with $VER" + read -r -p "Are you sure you want to run this script? [y/N] " response + if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]] + then + CONTINUE=1 + fi +fi + +if [ "$CONTINUE" == "1" ] +then + echo "Running database modifications" + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )" + + if [ "$1" != "combined" ]; then + #upgrade plugins + nodejs "$DIR/scripts/install_plugins.js" + fi + + #add indexes + nodejs "$DIR/scripts/add_indexes.js" + + if [ "$1" != "combined" ]; then + countly upgrade; + fi + + #call after check + countly check after upgrade db "$VER" +elif [ "$CONTINUE" == "0" ] +then + echo "Database is already upgraded to $VER" +elif [ "$CONTINUE" == "-1" ] +then + echo "Database is upgraded to higher version" +else + echo "Unknown ugprade state: $CONTINUE" +fi diff --git a/bin/upgrade/22.08/upgrade_fs.sh b/bin/upgrade/22.08/upgrade_fs.sh new file mode 100644 index 00000000000..046ee8150f0 --- /dev/null +++ b/bin/upgrade/22.08/upgrade_fs.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +echo "Running filesystem modifications" + +VER="22.08" + +CONTINUE="$(countly check before upgrade fs "$VER")" + +if [ "$CONTINUE" != "1" ] && [ "$1" != "combined" ] +then + echo "Filesystem is already up to date with $VER" + read -r -p "Are you sure you want to run this script? [y/N] " response + if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]] + then + CONTINUE=1 + fi +fi + +if [ "$CONTINUE" == "1" ] +then + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )" + + #enable command line + bash "$DIR/scripts/detect.init.sh" + + #upgrade plugins + nodejs "$DIR/scripts/install_plugins.js" + + #get web sdk + countly update sdk-web + + #install dependencies, process files and restart countly + if [ "$1" != "combined" ]; then + countly upgrade; + else + countly task dist-all; + fi + + #call after check + countly check after upgrade fs "$VER" +elif [ "$CONTINUE" == "0" ] +then + echo "Filesystem is already upgraded to $VER" +elif [ "$CONTINUE" == "-1" ] +then + echo "Filesystem is upgraded to higher version" +else + echo "Unknown ugprade state: $CONTINUE" +fi \ No newline at end of file