-
Notifications
You must be signed in to change notification settings - Fork 0
/
installsh.go
110 lines (93 loc) · 3.47 KB
/
installsh.go
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
101
102
103
104
105
106
107
108
109
110
package webhook
var installsh = `
#!/bin/sh
set -x
CURL_LOG="-v"
# Function to download the system agent binary with retries
download_agent_binary() {
RETRY_COUNT=10
DOWNLOAD_SUCCESS=false
while [ $RETRY_COUNT -gt 0 ] && [ "$DOWNLOAD_SUCCESS" = false ]; do
echo "Download attempt $((4 - $RETRY_COUNT)): Rancher System Agent binary"
curl --connect-timeout 60 --max-time 300 --write-out "%{http_code}\n" ${CURL_CAFLAG} -v -fL "${CATTLE_SERVER}/assets/rancher-system-agent-amd64" -o "${CATTLE_AGENT_BIN_PREFIX}/bin/rancher-system-agent"
if [ $? -eq 0 ] && [ -s "${CATTLE_AGENT_BIN_PREFIX}/bin/rancher-system-agent" ]; then
DOWNLOAD_SUCCESS=true
echo "Rancher System Agent binary downloaded successfully."
else
echo "Failed to download Rancher System Agent binary. Retrying..."
RETRY_COUNT=$((RETRY_COUNT - 1))
sleep 10
fi
done
if [ "$DOWNLOAD_SUCCESS" = false ]; then
echo "Failed to download Rancher System Agent binary after multiple attempts. Exiting."
exit 1
fi
}
download_certificates() {
RETRY_COUNT=10
DOWNLOAD_SUCCESS=false
CERT_FILE="$1"
while [ $RETRY_COUNT -gt 0 ] && [ "$DOWNLOAD_SUCCESS" = false ]; do
echo "Download attempt $((4 - $RETRY_COUNT)): Certificates"
curl --connect-timeout 60 --max-time 60 --write-out "%{http_code}\n" --insecure ${CURL_LOG} -fL "${CATTLE_SERVER}/cacerts" -o "${CERT_FILE}"