-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmariadb.sh
executable file
·69 lines (57 loc) · 1.52 KB
/
mariadb.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
#!/bin/bash
provider=$1
cat << EOF > answers.conf
[general]
provider = $provider
[mariadb-atomicapp]
db_user = username
db_pass = password
db_name = dbname
EOF
ret=0
echo "Running projectatomic/mariadb-centos7-atomicapp"
atomicapp run --destination=./ projectatomic/mariadb-centos7-atomicapp
res=$?
if [ $res -gt $ret ]; then
ret=$res
fi
if [ $ret -eq 0 ]; then
host="0.0.0.0"
if [ "$provider" = "kubernetes" ]; then
total=0
kubectl get pods | egrep -q "^mariadb\s+1/1\s+Running\s+"
while [ $? -ne 0 -a $total -lt 120 ]; do
sleep 2
total=$((total+2))
kubectl get pods | egrep -q "^mariadb\s+1/1\s+Running\s+"
done
echo "Checking kubernetes pod"
kubectl get pods
host=`kubectl get service mariadb | egrep '^mariadb' | awk '{print $4}'`
fi
echo "Checking databases"
times=0
mysql --host $host --user=username --password=password --execute="show databases;" --connect-timeout=5
ret=$?
while [ $ret -ne 0 -a $times -lt 25 ]; do
sleep 3
times=$((times+1))
mysql --host $host --user=username --password=password --execute="show databases;" --connect-timeout=5
ret=$?
done
res=$?
if [ $res -gt $ret ]; then
ret=$res
fi
fi
echo "Stopping projectatomic/mariadb-centos7-atomicapp"
atomicapp stop ./
res=$?
if [ $res -gt $ret ]; then
ret=$res
fi
if [ "$provider" = "docker" ]; then
docker stop mariadb-atomicapp-app
docker rm mariadb-atomicapp-app
fi
exit $ret