@@ -13,9 +13,59 @@ kubectl config current-context || {
13
13
}
14
14
echo " "
15
15
16
+ OS=" "
17
+ ARCH=" "
18
+ DOWNLOAD_URL=" "
19
+ DOWNLOAD_DIR=" "
20
+ TEMP_DIRS=()
21
+ ONESSL=" "
22
+
16
23
# http://redsymbol.net/articles/bash-exit-traps/
17
24
function cleanup() {
18
- rm -rf $ONESSL ca.crt ca.key server.crt server.key
25
+ rm -rf ca.crt ca.key server.crt server.key
26
+ # remove temporary directories
27
+ for dir in " ${TEMP_DIRS[@]} " ; do
28
+ rm -rf " ${dir} "
29
+ done
30
+ }
31
+
32
+ # detect operating system
33
+ # ref: https://raw.githubusercontent.com/helm/helm/master/scripts/get
34
+ function detectOS() {
35
+ OS=$( echo ` uname` | tr ' [:upper:]' ' [:lower:]' )
36
+
37
+ case " $OS " in
38
+ # Minimalist GNU for Windows
39
+ cygwin* | mingw* | msys* ) OS=' windows' ;;
40
+ esac
41
+ }
42
+
43
+ # detect machine architecture
44
+ function detectArch() {
45
+ ARCH=$( uname -m)
46
+ case $ARCH in
47
+ armv7* ) ARCH=" arm" ;;
48
+ aarch64) ARCH=" arm64" ;;
49
+ x86) ARCH=" 386" ;;
50
+ x86_64) ARCH=" amd64" ;;
51
+ i686) ARCH=" 386" ;;
52
+ i386) ARCH=" 386" ;;
53
+ esac
54
+ }
55
+
56
+ detectOS
57
+ detectArch
58
+
59
+ # download file pointed by DOWNLOAD_URL variable
60
+ # store download file to the directory pointed by DOWNLOAD_DIR variable
61
+ # you have to sent the output file name as argument. i.e. downloadFile myfile.tar.gz
62
+ function downloadFile() {
63
+ if curl --output /dev/null --silent --head --fail " $DOWNLOAD_URL " ; then
64
+ curl -fsSL ${DOWNLOAD_URL} -o $DOWNLOAD_DIR /$1
65
+ else
66
+ echo " File does not exist"
67
+ exit 1
68
+ fi
19
69
}
20
70
21
71
export APPSCODE_ENV=${APPSCODE_ENV:- prod}
@@ -35,37 +85,26 @@ onessl_found() {
35
85
return 1
36
86
}
37
87
88
+ # download onessl if it does not exist
38
89
onessl_found || {
39
90
echo " Downloading onessl ..."
40
- if [[ " $( uname -m) " == " aarch64" ]]; then
41
- curl -fsSL -o onessl https://github.com/kubepack/onessl/releases/download/0.10.0/onessl-linux-arm64
42
- chmod +x onessl
43
- export ONESSL=./onessl
44
- else
45
- # ref: https://stackoverflow.com/a/27776822/244009
46
- case " $( uname -s) " in
47
- Darwin)
48
- curl -fsSL -o onessl https://github.com/kubepack/onessl/releases/download/0.10.0/onessl-darwin-amd64
49
- chmod +x onessl
50
- export ONESSL=./onessl
51
- ;;
52
-
53
- Linux)
54
- curl -fsSL -o onessl https://github.com/kubepack/onessl/releases/download/0.10.0/onessl-linux-amd64
55
- chmod +x onessl
56
- export ONESSL=./onessl
57
- ;;
58
-
59
- CYGWIN* | MINGW* | MSYS* )
60
- curl -fsSL -o onessl.exe https://github.com/kubepack/onessl/releases/download/0.10.0/onessl-windows-amd64.exe
61
- chmod +x onessl.exe
62
- export ONESSL=./onessl.exe
63
- ;;
64
- * )
65
- echo ' other OS'
66
- ;;
67
- esac
68
- fi
91
+
92
+ ARTIFACT=" https://github.com/kubepack/onessl/releases/download/0.12.0"
93
+ ONESSL_BIN=onessl-${OS} -${ARCH}
94
+ case " $OS " in
95
+ cygwin* | mingw* | msys* )
96
+ ONESSL_BIN=${ONESSL_BIN} .exe
97
+ ;;
98
+ esac
99
+
100
+ DOWNLOAD_URL=${ARTIFACT} /${ONESSL_BIN}
101
+ DOWNLOAD_DIR=" $( mktemp -dt onessl-XXXXXX) "
102
+ TEMP_DIRS+=($DOWNLOAD_DIR ) # store DOWNLOAD_DIR to cleanup later
103
+
104
+ downloadFile $ONESSL_BIN # downloaded file name will be saved as the value of ONESSL_BIN variable
105
+
106
+ export ONESSL=${DOWNLOAD_DIR} /${ONESSL_BIN}
107
+ chmod +x $ONESSL
69
108
}
70
109
71
110
# ref: https://stackoverflow.com/a/7069755/244009
@@ -311,6 +350,10 @@ if [ "$STASH_UNINSTALL" -eq 1 ]; then
311
350
kubectl delete secret stash-apiserver-cert --namespace $PROMETHEUS_NAMESPACE || true
312
351
# delete psp resources
313
352
kubectl delete psp stash-operator-psp stash-backup-job stash-backupsession-cron stash-restore-job || true
353
+ # delete default functions
354
+ kubectl delete functions.stash.appscode.com update-status pvc-backup pvc-restore || true
355
+ # delete default tasks
356
+ kubectl delete tasks.stash.appscode.com pvc-backup pvc-restore || true
314
357
315
358
echo " waiting for stash operator pod to stop running"
316
359
for (( ; ; )) ; do
0 commit comments