-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.sh
executable file
·75 lines (65 loc) · 2.48 KB
/
main.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
#!/bin/bash
PROJECT_NAME="velero"
VELERO_INSTALL_DIR="/usr/local/bin"
VELERO_VERSION=""
set -euo pipefail
target="./main.yml"
rm "$target"
echo "# Derived from config" >>"$target"
#Downloading version specific manifests
downloadVersionSpecificYamlFilesForMinio() {
# Remove old yamls
rm -rf manifests/*
wget -nc -P ./manifests/common https://raw.githubusercontent.com/heptio/velero/${VELERO_VERSION}/examples/common/00-prereqs.yaml
wget -nc -P ./manifests/minio https://raw.githubusercontent.com/heptio/velero/${VELERO_VERSION}/examples/minio/00-minio-deployment.yaml
wget -nc -P ./manifests/minio https://raw.githubusercontent.com/heptio/velero/${VELERO_VERSION}/examples/minio/05-backupstoragelocation.yaml
wget -nc -P ./manifests/minio https://raw.githubusercontent.com/heptio/velero/${VELERO_VERSION}/examples/minio/20-deployment.yaml
while true; do
read -p "Install restic yaml Y(y)/N(n)?" yn
case $yn in
[Yy]*)
wget -nc -P ./manifests/minio https://raw.githubusercontent.com/heptio/velero/${VELERO_VERSION}/examples/minio/30-restic-daemonset.yaml
break
;;
[Nn]*)
break
;;
*) echo "Please answer yes or no." ;;
esac
done
}
# checkVeleroInstalledVersion checks which version of velero is installed and
# if it needs to be changed.
checkVeleroInstalledVersion() {
if [ -x "${VELERO_INSTALL_DIR}/${PROJECT_NAME}" ]; then
local version=$(velero version | grep 'Version' | cut -d':' -f2 | sed -e 's/^[ \t]*//')
VELERO_VERSION=$version
echo "Velero client ${version} found, proceeding with velero installation."
return 0
else
echo "Velero client not found in $VELERO_INSTALL_DIR Please check if it's installed"
echo "Installation steps can be found below. Re-run the install addon command again after velero client installation."
echo "
Get the latest release corresponding to your OS and system architecture and copy the link address
wget https://<link-copied-from-releases-page>
tar -xvzf <downloaded-from-above-step>.tar.gz
sudo mv velero /usr/local/bin/
$ velero help "
return 1
fi
}
# Copy Velero manifests into main.yml
copyManifestsToMainYaml() {
echo "Installing Velero .."
for file in $(find ./manifests -type f -name "*.yaml" | sort); do
echo "add " $file
cat "$file" >>"$target"
echo " " >>"$target"
echo "---" >>"$target"
done
}
# Velero minio Installation
if checkVeleroInstalledVersion; then
downloadVersionSpecificYamlFilesForMinio
copyManifestsToMainYaml
fi