-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgradedb.sh
executable file
·33 lines (33 loc) · 1.17 KB
/
upgradedb.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
#!/bin/bash
# read .env parameters
SQL="select dbversion_number from sturwild.dbversion order by dbversion_id desc limit 1"
DBENV=.envdb
echo "" > .envdb
sed 's/ = /=/g' .env |grep -v '^#' |grep -v '\\' |
while read -r line; do
if [ ! -z "$line" ]; then
var=`echo $line| cut -d '=' -f1`
content=`echo $line | cut -d '=' -f2`
if [ $var = "database.default.hostname" ]; then
echo "DBHOST=$content" >> $DBENV
fi
if [ $var = "database.default.database" ]; then
echo "DATABASE=$content" >> $DBENV
fi
if [ $var = "database.default.username" ]; then
echo "LOGIN=$content" >> $DBENV
fi
if [ $var = "database.default.password" ]; then
echo "PASSWORD=$content" >> $DBENV
fi
if [ $var = "BASE_DIR" ]; then
echo "FOLDERINSTALL=$content" >> $DBENV
fi
fi
done
source $DBENV
ADDRESS=postgresql://"$LOGIN":"$PASSWORD"@"$DBHOST"/"$DATABASE"
VERSION=`psql $ADDRESS -c "$SQL" -t|xargs`
SCRIPT="$FOLDERINSTALL/install/upgradedb-from-$VERSION.sh"
source $SCRIPT
rm $DBENV