forked from webkul/qloapps_docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
37 lines (30 loc) · 1.05 KB
/
update.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
#!/bin/bash
set -u
##set user password
user=qloapps
echo -e "$USER_PASSWORD\n$USER_PASSWORD" | passwd $user
echo "User qloapps password updated"
##set mysql password
sleep 4
database_connectivity_check=no
var=1
while [ "$database_connectivity_check" != "mysql" ]; do
/etc/init.d/mysql start
sleep 2
database_connectivity_check=`mysqlshow --user=root | grep -o mysql`
if [ $var -ge 4 ]; then
exit 1
fi
var=$((var+1))
done
database_availability_check=`mysqlshow --user=root | grep -ow "$MYSQL_DATABASE"`
if [ "$database_availability_check" == "$MYSQL_DATABASE" ]; then
exit 1
else
mysqladmin -u root password $MYSQL_ROOT_PASSWORD
mysql -u root -p$MYSQL_ROOT_PASSWORD -e "grant all on *.* to 'root'@'%' identified by '$MYSQL_ROOT_PASSWORD';"
mysql -u root -p$MYSQL_ROOT_PASSWORD -e "create database $MYSQL_DATABASE;"
mysql -u root -p$MYSQL_ROOT_PASSWORD -e "grant all on $MYSQL_DATABASE.* to 'root'@'%' identified by '$MYSQL_ROOT_PASSWORD';"
supervisorctl stop update_credentials && supervisorctl remove update_credentials
echo "Database $MYSQL_DATABASE created"
fi