forked from FNNDSC/pman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unmake.sh
executable file
·100 lines (94 loc) · 2.5 KB
/
unmake.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
#
# NAME
#
# unmake.sh
#
# SYNPOSIS
#
# unmake.sh [-h]
# [-O <swarm|kubernetes>]
# [-S <storeBase>]
#
#
# DESC
#
# 'unmake.sh' destroys a pman development instance running on Swarm or Kubernetes.
#
# TYPICAL CASES:
#
# Destroy pman dev instance on Swarm:
#
# unmake.sh
#
# Destroy pman dev instance on Kubernetes:
#
# unmake.sh -O kubernetes
#
# ARGS
#
#
# -h
#
# Optional print usage help.
#
# -O <swarm|kubernetes>
#
# Explicitly set the orchestrator. Default is swarm.
#
# -S <storeBase>
#
# Explicitly set the STOREBASE dir to <storeBase>. This is the remote ChRIS
# filesystem where plugins get their input data and create their output data.
#
#
source ./decorate.sh
declare -i STEP=0
ORCHESTRATOR=swarm
print_usage () {
echo "Usage: ./unmake.sh [-h] [-O <swarm|kubernetes>] [-S <storeBase>]"
exit 1
}
while getopts ":hO:S:" opt; do
case $opt in
h) print_usage
;;
O) ORCHESTRATOR=$OPTARG
if ! [[ "$ORCHESTRATOR" =~ ^(swarm|kubernetes)$ ]]; then
echo "Invalid value for option -- O"
print_usage
fi
;;
S) STOREBASE=$OPTARG
;;
\?) echo "Invalid option -- $OPTARG"
print_usage
;;
:) echo "Option requires an argument -- $OPTARG"
print_usage
;;
esac
done
shift $(($OPTIND - 1))
title -d 1 "Setting global exports..."
if [ -z ${STOREBASE+x} ]; then
STOREBASE=$(pwd)/CHRIS_REMOTE_FS
fi
echo -e "ORCHESTRATOR=$ORCHESTRATOR" | ./boxes.sh
echo -e "exporting STOREBASE=$STOREBASE " | ./boxes.sh
export STOREBASE=$STOREBASE
windowBottom
title -d 1 "Destroying pman containerized dev environment on $ORCHESTRATOR"
if [[ $ORCHESTRATOR == swarm ]]; then
echo "docker stack rm pman_dev_stack" | ./boxes.sh ${LightCyan}
docker stack rm pman_dev_stack
echo "docker volume rm -f pman_dev_stack_storebase" | ./boxes.sh ${LightCyan}
sleep 15
docker volume rm -f pman_dev_stack_storebase
elif [[ $ORCHESTRATOR == kubernetes ]]; then
echo "kubectl delete -f kubernetes/pman_dev.yaml" | ./boxes.sh ${LightCyan}
kubectl delete -f kubernetes/pman_dev.yaml
fi
echo "Removing STOREBASE tree $STOREBASE" | ./boxes.sh
rm -fr $STOREBASE
windowBottom