Skip to content

Commit b8e8629

Browse files
committed
Preparing upgrade scripts
1 parent e3f1c05 commit b8e8629

6 files changed

+111
-0
lines changed
File renamed without changes.
File renamed without changes.

bin/upgrade/24.10/upgrade.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3+
DATE=$(date +%Y-%m-%d:%H:%M:%S)
4+
VERSION="$(basename "${DIR}")"
5+
6+
countly stop
7+
if [ -f "$DIR/upgrade_fs.sh" ]; then
8+
bash "$DIR/upgrade_fs.sh" combined 2>&1 | tee -a "$DIR/../../../log/countly-upgrade-fs-$VERSION-$DATE.log"
9+
fi
10+
if [ -f "$DIR/upgrade_db.sh" ]; then
11+
bash "$DIR/upgrade_db.sh" combined 2>&1 | tee -a "$DIR/../../../log/countly-upgrade-db-$VERSION-$DATE.log"
12+
fi
13+
countly upgrade

bin/upgrade/24.10/upgrade_db.sh

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
VER="24.10"
4+
5+
CONTINUE="$(countly check before upgrade db "$VER")"
6+
7+
if [ "$CONTINUE" != "1" ] && [ "$1" != "combined" ]
8+
then
9+
echo "Database is already up to date with $VER"
10+
read -r -p "Are you sure you want to run this script? [y/N] " response
11+
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
12+
then
13+
CONTINUE=1
14+
fi
15+
fi
16+
17+
if [ "$CONTINUE" == "1" ]
18+
then
19+
echo "Running database modifications"
20+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
21+
SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
22+
23+
if [ "$1" != "combined" ]; then
24+
#upgrade plugins
25+
nodejs "$DIR/scripts/install_plugins.js"
26+
fi
27+
28+
#add indexes
29+
nodejs "$DIR/scripts/add_indexes.js"
30+
31+
#run upgrade scripts
32+
nodejs "$SCRIPTS/scripts/merge_events_collections.js"
33+
34+
35+
if [ "$1" != "combined" ]; then
36+
countly upgrade;
37+
fi
38+
39+
#call after check
40+
countly check after upgrade db "$VER"
41+
elif [ "$CONTINUE" == "0" ]
42+
then
43+
echo "Database is already upgraded to $VER"
44+
elif [ "$CONTINUE" == "-1" ]
45+
then
46+
echo "Database is upgraded to higher version"
47+
else
48+
echo "Unknown ugprade state: $CONTINUE"
49+
fi

bin/upgrade/24.10/upgrade_fs.sh

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
echo "Running filesystem modifications"
4+
5+
VER="24.10"
6+
7+
CONTINUE="$(countly check before upgrade fs "$VER")"
8+
9+
if [ "$CONTINUE" != "1" ] && [ "$1" != "combined" ]
10+
then
11+
echo "Filesystem is already up to date with $VER"
12+
read -r -p "Are you sure you want to run this script? [y/N] " response
13+
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
14+
then
15+
CONTINUE=1
16+
fi
17+
fi
18+
19+
if [ "$CONTINUE" == "1" ]
20+
then
21+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
22+
23+
#enable command line
24+
bash "$DIR/scripts/detect.init.sh"
25+
26+
#upgrade plugins
27+
nodejs "$DIR/scripts/install_plugins.js"
28+
29+
#get web sdk
30+
countly update sdk-web
31+
32+
33+
if [ "$1" != "combined" ]; then
34+
countly upgrade;
35+
else
36+
countly task dist-all;
37+
fi
38+
39+
#call after check
40+
countly check after upgrade fs "$VER"
41+
elif [ "$CONTINUE" == "0" ]
42+
then
43+
echo "Filesystem is already upgraded to $VER"
44+
elif [ "$CONTINUE" == "-1" ]
45+
then
46+
echo "Filesystem is upgraded to higher version"
47+
else
48+
echo "Unknown ugprade state: $CONTINUE"
49+
fi

0 commit comments

Comments
 (0)