forked from robipozzi/windfire-restaurants-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathundeploy.sh
More file actions
executable file
·84 lines (78 loc) · 2.33 KB
/
undeploy.sh
File metadata and controls
executable file
·84 lines (78 loc) · 2.33 KB
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
source ./setenv.sh
# ##### Variable section - START
SCRIPT=undeploy.sh
PLATFORM_OPTION=$1
DEPLOY_FUNCTION=
# ##### Variable section - END
# ***** Function section - START
undeployFromRaspberry()
{
## Undeploy Windfire Restaurants backend component from remote Raspberry box
echo ${cyn}Undeploy Windfire Restaurants backend component from Raspberry Pi ...${end}
export ANSIBLE_CONFIG=$PWD/deployment/raspberry/ansible.cfg
ansible-playbook deployment/raspberry/remove.yaml
echo ${cyn}Done${end}
echo
}
undeployFromAWS()
{
## Undeploy Windfire Restaurants backend component from AWS
echo ${cyn}Undeploy Windfire Restaurants backend component from AWS ...${end}
ANSIBLE_CONFIG_FILE=ansible-aws.cfg
echo ${cyn}Invoking ansible-config.sh to dynamically create configuration files for Ansible ...${end}
deployment/aws/ansible-config.sh $ANSIBLE_CONFIG_FILE
export ANSIBLE_CONFIG=$PWD/deployment/aws/$ANSIBLE_CONFIG_FILE
echo
ansible-playbook -i deployment/aws/windfire.aws_ec2.yaml deployment/aws/remove.yaml
echo ${cyn}Done${end}
echo
}
undeployFromOpenShift()
{
## Undeploy Windfire Restaurants backend component from Red Hat OpenShift
echo ${cyn}Undeploy Windfire Restaurants backend component from Red Hat OpenShift ...${end}
deployment/openshift/oc-undeploy.sh
echo ${cyn}Done${end}
echo
}
undeploy()
{
if [ -z $PLATFORM_OPTION ]; then
printSelectPlatform
fi
$DEPLOY_FUNCTION
}
printSelectPlatform()
{
echo ${grn}Select deployment platform : ${end}
echo "${grn}1. Raspberry${end}"
echo "${grn}2. AWS${end}"
echo "${grn}3. OpenShift${end}"
read PLATFORM_OPTION
setUnDeployFunction
}
setUnDeployFunction()
{
case $PLATFORM_OPTION in
1) DEPLOY_FUNCTION="undeployFromRaspberry"
;;
2) DEPLOY_FUNCTION="undeployFromAWS"
;;
3) DEPLOY_FUNCTION="undeployFromOpenShift"
;;
*) printf "\n${red}No valid option selected${end}\n"
printSelectPlatform
;;
esac
}
# ***** Function section - END
# ##############################################
# #################### MAIN ####################
# ##############################################
# ************ START evaluate args ************"
if [ "$1" != "" ]; then
setUnDeployFunction
fi
# ************** END evaluate args **************"
RUN_FUNCTION=undeploy
$RUN_FUNCTION