This repository has been archived by the owner on Feb 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmigrate.sh
executable file
·107 lines (85 loc) · 3.27 KB
/
migrate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
echo " ______ __
/ \ | \
| ######\ ____| ## ______
| ##__| ## / ## | \
| ## ##| ####### \######\\
| ########| ## | ## / ##
| ## | ##| ##__| ##| #######
| ## | ## \## ## \## ##
\## \## \####### \#######
---------------------------------
MIGRATION ASSISTANT
---------------------------------
"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
bold=$(tput bold)
normal=$(tput sgr0)
CUR_DIR=$SCRIPT_DIR/../
APP_CONF_FILE=$CUR_DIR/conf/application.conf
if [ ! -f $APP_CONF_FILE ];
then
echo -e "\n>>> Something is wrong. This script was not run from an Ada installation dir.\n"
exit 1
fi
APP_VERSION_LINE=$(grep -F "app.version" $APP_CONF_FILE)
APP_VERSION=${APP_VERSION_LINE#*= }
echo -e "Current Ada version is ${bold}$APP_VERSION${normal}.\n"
if [[ $APP_VERSION < "0.7.0" ]];
then
echo -e ">>> This script can be used only for Ada versions 0.7.0 and above.\n"
exit 1
fi
PREV_DIR_CORRECT=""
while [[ $PREV_DIR_CORRECT != "y" && $PREV_DIR_CORRECT != "Y" ]];
do
# PREV_DIR="USER INPUT"
read -p "Enter the (root) dir of your previous Ada installation: " PREV_DIR
if [ -d $PREV_DIR ];
then
PREV_APP_CONF_FILE=$PREV_DIR/conf/application.conf
if [ -f $PREV_APP_CONF_FILE ];
then
PREV_APP_VERSION_LINE=$(grep -F "app.version" $PREV_APP_CONF_FILE)
PREV_APP_VERSION=${PREV_APP_VERSION_LINE#*= }
echo -e "\n>>> Found the app version ${bold}$PREV_APP_VERSION${normal} in the dir '$PREV_DIR'.\n"
if [[ $APP_VERSION > $PREV_APP_VERSION ]];
then
# PREV_DIR_CORRECT="USER INPUT"
read -p "Is it correct [y/n]? " PREV_DIR_CORRECT
else
echo -e ">>> Cannot continue. Your (current) version must be newer than the source one.\n"
fi
else
echo -e "\n>>> Cannot find an application config. The dir '$PREV_DIR' does not seem to belong to an Ada instalation.\n"
fi
else
echo -e "\n>>> The dir '$PREV_DIR' does not exist.\n"
fi
done
# Configuration files
echo -e "\n>>> Copying configuration files...\n"
cp $PREV_DIR/conf/custom.conf $CUR_DIR/conf/custom.conf
cp $PREV_DIR/bin/set_env.sh $CUR_DIR/bin/set_env.sh
PREV_TEMP_LINE=$(grep -F "ADA_TEMP=" $PREV_DIR/bin/runme)
PREV_MEM_LINE=$(grep -F "ADA_MEM=" $PREV_DIR/bin/runme)
sed "s|ADA_TEMP=.*|${PREV_TEMP_LINE}|g" $CUR_DIR/bin/runme > $CUR_DIR/bin/runme_x
sed "s|ADA_MEM=.*|${PREV_MEM_LINE}|g" $CUR_DIR/bin/runme_x > $CUR_DIR/bin/runme
rm $CUR_DIR/bin/runme_x
# Copy extra folders, e.g. dataImports, and images
cd $PREV_DIR
echo -e ">>> Searching for extra sub dirs to copy..."
for i in $(ls -d */);
do
SUB_DIR=${i%%/};
if [[ $SUB_DIR != "bin" && $SUB_DIR != "conf" && $SUB_DIR != "lib" && $SUB_DIR != "share" ]];
then
echo -e "\nCopying '$SUB_DIR'..."
cp -r $PREV_DIR/$SUB_DIR $CUR_DIR/$SUB_DIR
fi
done
# Mongo
echo -e "\n>>> ${bold}Warning: DB migration has to be done manually. Please execute all the db-update scripts from > $PREV_APP_VERSION to $APP_VERSION${normal}.\n"
echo -e ">>> Ada migration has been successfully finished!\n"
echo "---------------------------------"
echo -e "\n[[EnJoY Ada Discovery Analytics. Visit us at https://ada-discovery.org. Bye]]\n"