-
Notifications
You must be signed in to change notification settings - Fork 28
/
delete-deployment.sh
executable file
·61 lines (53 loc) · 1.41 KB
/
delete-deployment.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
#!/bin/bash
RED='\033[0;31m' # Error color
YELLOW='\033[0;33m' # Warning color
NC='\033[0m' # No Color
set -u
DIR="."
GetPathToCurrentlyExecutingScript () {
# Absolute path of this script, e.g. /opt/corda/node/foo.sh
set +e
ABS_PATH=$(readlink -f "$0" 2>&1)
if [ "$?" -ne "0" ]; then
echo "Using macOS alternative to readlink -f command..."
# Unfortunate MacOs issue with readlink functionality, see https://github.com/corda/corda-kubernetes-deployment/issues/4
TARGET_FILE=$0
cd $(dirname $TARGET_FILE)
TARGET_FILE=$(basename $TARGET_FILE)
ITERATIONS=0
# Iterate down a (possible) chain of symlinks
while [ -L "$TARGET_FILE" ]
do
TARGET_FILE=$(readlink $TARGET_FILE)
cd $(dirname $TARGET_FILE)
TARGET_FILE=$(basename $TARGET_FILE)
ITERATIONS=$((ITERATIONS + 1))
if [ "$ITERATIONS" -gt 1000 ]; then
echo "symlink loop. Critical exit."
exit 1
fi
done
# Compute the canonicalized name by finding the physical path
# for the directory we're in and appending the target file.
PHYS_DIR=$(pwd -P)
ABS_PATH=$PHYS_DIR/$TARGET_FILE
fi
# Absolute path of the directory this script is in, thus /opt/corda/node/
DIR=$(dirname "$ABS_PATH")
}
GetPathToCurrentlyExecutingScript
set -eu
checkStatus () {
status=$1
if [ $status -eq 0 ]
then
echo "."
else
echo -e "${RED}ERROR${NC}"
echo "The previous step failed"
exit 1
fi
return 0
}
$DIR/helm/delete-all.sh
checkStatus $?