-
Notifications
You must be signed in to change notification settings - Fork 15
/
onboard.tpl
153 lines (124 loc) · 3.4 KB
/
onboard.tpl
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/bash
# Script must be non-blocking or run in the background.
mkdir -p /config/cloud
cat << 'EOF' > /config/cloud/startup-script.sh
#!/bin/bash
# BIG-IPS ONBOARD SCRIPT
LOG_FILE=${onboard_log}
if [ ! -e $LOG_FILE ]
then
touch $LOG_FILE
exec &>>$LOG_FILE
else
#if file exists, exit as only want to run once
exit
fi
exec 1>$LOG_FILE 2>&1
# CHECK TO SEE NETWORK IS READY
CNT=0
while true
do
STATUS=$(curl -s -k -I example.com | grep HTTP)
if [[ $STATUS == *"200"* ]]; then
echo "Got 200! VE is Ready!"
break
elif [ $CNT -le 6 ]; then
echo "Status code: $STATUS Not done yet..."
CNT=$[$CNT+1]
else
echo "GIVE UP..."
break
fi
sleep 10
done
sleep 60
### DOWNLOAD ONBOARDING PKGS
# Could be pre-packaged or hosted internally
admin_username='${uname}'
admin_password='${upassword}'
CREDS="admin:"$admin_password
TS_URL='${TS_URL}'
TS_FN=$(basename "$TS_URL")
DO_URL='${DO_URL}'
DO_FN=$(basename "$DO_URL")
AS3_URL='${AS3_URL}'
AS3_FN=$(basename "$AS3_URL")
mkdir -p ${libs_dir}
echo -e "\n"$(date) "Download TS Pkg"
curl -L -o ${libs_dir}/$TS_FN $TS_URL
echo -e "\n"$(date) "Download Declarative Onboarding Pkg"
curl -L -o ${libs_dir}/$DO_FN $DO_URL
echo -e "\n"$(date) "Download AS3 Pkg"
curl -L -o ${libs_dir}/$AS3_FN $AS3_URL
# Copy the RPM Pkg to the file location
cp ${libs_dir}/*.rpm /var/config/rest/downloads/
# Install Telemetry Streaming Pkg
DATA="{\"operation\":\"INSTALL\",\"packageFilePath\":\"/var/config/rest/downloads/$TS_FN\"}"
echo -e "\n"$(date) "Install TS Pkg"
curl -u $CREDS -X POST http://localhost:8100/mgmt/shared/iapp/package-management-tasks -d $DATA
sleep 10
# Install Declarative Onboarding Pkg
DATA="{\"operation\":\"INSTALL\",\"packageFilePath\":\"/var/config/rest/downloads/$DO_FN\"}"
echo -e "\n"$(date) "Install DO Pkg"
curl -u $CREDS -X POST http://localhost:8100/mgmt/shared/iapp/package-management-tasks -d $DATA
sleep 10
# Install AS3 Pkg
DATA="{\"operation\":\"INSTALL\",\"packageFilePath\":\"/var/config/rest/downloads/$AS3_FN\"}"
echo -e "\n"$(date) "Install AS3 Pkg"
curl -u $CREDS -X POST http://localhost:8100/mgmt/shared/iapp/package-management-tasks -d $DATA
sleep 10
# Check DO Ready
CNT=0
while true
do
STATUS=$(curl -u $CREDS -X GET -s -k -I https://localhost/mgmt/shared/declarative-onboarding | grep HTTP)
if [[ $STATUS == *"200"* ]]; then
echo "Got 200! Declarative Onboarding is Ready!"
break
elif [ $CNT -le 6 ]; then
echo "Status code: $STATUS DO Not done yet..."
CNT=$[$CNT+1]
else
echo "GIVE UP..."
break
fi
sleep 10
done
# Check AS3 Ready
CNT=0
while true
do
STATUS=$(curl -u $CREDS -X GET -s -k -I https://localhost/mgmt/shared/appsvcs/info | grep HTTP)
if [[ $STATUS == *"200"* ]]; then
echo "Got 200! AS3 is Ready!"
break
elif [ $CNT -le 6 ]; then
echo "Status code: $STATUS AS3 Not done yet..."
CNT=$[$CNT+1]
else
echo "GIVE UP..."
break
fi
sleep 10
done
# Check TS Ready
CNT=0
while true
do
STATUS=$(curl -u $CREDS -X GET -s -k -I https://localhost/mgmt/shared/telemetry/declare | grep HTTP)
if [[ $STATUS == *"200"* ]]; then
echo "Got 200! TS is Ready!"
break
elif [ $CNT -le 6 ]; then
echo "Status code: $STATUS TS Not done yet..."
CNT=$[$CNT+1]
else
echo "GIVE UP..."
break
fi
sleep 10
done
EOF
# Now run in the background to not block startup
chmod 755 /config/cloud/startup-script.sh
nohup /config/cloud/startup-script.sh &