-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-app.sh
24 lines (20 loc) · 1015 Bytes
/
deploy-app.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
#!/usr/bin/bash
PROJECT="review-troubleshoot"
# Identify the mysql pod
if [ $(oc get pods -l deploymentconfig=mysql -n ${PROJECT} -o name | wc -l) -eq 1 ]
then
# mysql application was created as a deploymentconfig
MYPOD=$(oc get pods -l deploymentconfig=mysql -n ${PROJECT} -o template --template '{{range .items}}{{.metadata.name}}{{end}}')
elif [ $(oc get pods -l deployment=mysql -n ${PROJECT} -o name | wc -l) -eq 1 ]
then
# mysql application was created as a deployment
MYPOD=$(oc get pods -l deployment=mysql -n ${PROJECT} -o template --template '{{range .items}}{{.metadata.name}}{{end}}')
fi
# Check if the "defaultdb" database already exists
if ! oc exec ${MYPOD} -n ${PROJECT} -- /usr/bin/mysql -u root -e 'show databases;' | grep -q defaultdb
then
echo "Creating famous-quotes database"
oc exec ${MYPOD} -n ${PROJECT} -- /usr/bin/mysql -u root -e 'CREATE DATABASE defaultdb'
fi
echo "Deploying famous-quotes application"
oc apply -f /home/student/DO280/labs/${PROJECT}/famous-quotes.yaml