@@ -10,16 +10,91 @@ check_status() {
1010
1111check_status
1212
13- # Add additional dependencies below as needed
13+ set -e # Exit on any error
1414
15- # Example: Installing an additional dependency (replace with actual URL)
16- # echo "Installing Example Dependency..."
17- # kubectl apply -f "https://example.com/path/to/dependency.yaml"
18- # check_status
15+ # Function to check if command succeeded
16+ check_success () {
17+ if [ $? -ne 0 ]; then
18+ echo " Error: $1 "
19+ exit 1
20+ fi
21+ }
22+
23+ # Function to check if a command exists
24+ command_exists () {
25+ command -v " $1 " > /dev/null 2>&1
26+ }
27+
28+ # Install helm if not exists
29+ if command_exists helm; then
30+ echo " helm is already installed. Version: $( helm version) "
31+ else
32+ echo " Installing helm..."
33+ curl -fsSL -o /tmp/get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
34+ check_success " Failed to download Helm installation script"
35+
36+ chmod 700 /tmp/get_helm.sh
37+ /tmp/get_helm.sh
38+ check_success " Helm installation failed"
39+ fi
40+
41+ # Determine architecture
42+ ARCH=$( uname -m)
43+ if [ " $ARCH " = " x86_64" ]; then
44+ KUBECTL_ARCH=" amd64"
45+ else
46+ KUBECTL_ARCH=" arm64"
47+ fi
48+
49+ # Install kubectl if not exists
50+ if command_exists kubectl; then
51+ echo " kubectl is already installed. Version: $( kubectl version --client) "
52+ else
53+ echo " Installing kubectl..."
54+ KUBECTL_VERSION=$( curl -L -s https://dl.k8s.io/release/stable.txt)
55+ curl -LO -sS " https://dl.k8s.io/release/${KUBECTL_VERSION} /bin/linux/${KUBECTL_ARCH} /kubectl"
56+ curl -LO -sS " https://dl.k8s.io/release/${KUBECTL_VERSION} /bin/linux/${KUBECTL_ARCH} /kubectl.sha256"
57+
58+ # Verify kubectl checksum
59+ if echo " $( cat kubectl.sha256) kubectl" | sha256sum --check; then
60+ mv kubectl /tmp
61+ chmod +x /tmp/kubectl
62+ sudo mv /tmp/kubectl /usr/local/bin
63+ check_success " Failed to install kubectl"
64+ else
65+ echo " kubectl checksum verification failed"
66+ exit 1
67+ fi
68+ fi
69+
70+ # Install eksctl if not exists
71+ if command_exists eksctl; then
72+ echo " eksctl is already installed. Version: $( eksctl version) "
73+ else
74+ echo " Installing eksctl..."
75+ SYSTEM=$( uname -s)
76+ PLATFORM=" ${SYSTEM} _${KUBECTL_ARCH} "
77+ EKSCTL_FILE=" eksctl_${PLATFORM} .tar.gz"
78+
79+ curl -sLO " https://github.com/eksctl-io/eksctl/releases/latest/download/${EKSCTL_FILE} "
80+ check_success " Failed to download eksctl"
81+
82+ # Verify eksctl checksum
83+ if curl -sL " https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_checksums.txt" | grep $PLATFORM | sha256sum --check; then
84+ tar -xzf " ./${EKSCTL_FILE} " -C /tmp
85+ rm " ./${EKSCTL_FILE} "
86+ sudo mv /tmp/eksctl /usr/local/bin
87+ check_success " Failed to install eksctl"
88+ else
89+ echo " eksctl checksum verification failed"
90+ exit 1
91+ fi
92+ fi
1993
20- # Add more dependencies here
21- # echo "Installing Another Dependency..."
22- # kubectl apply -f "https://example.com/path/to/another-dependency.yaml"
23- # check_status
94+ echo " Installation check completed successfully!"
95+ echo " Installed versions:"
96+ echo " helm: $( helm version) "
97+ echo " kubectl: $( kubectl version --client) "
98+ echo " eksctl: $( eksctl version) "
2499
25100echo " All dependencies installed successfully."
0 commit comments