-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path77-accept-kali-plan.example
31 lines (25 loc) · 1.46 KB
/
77-accept-kali-plan.example
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
#!/usr/bin/with-contenv bash
source /terraform/az_login
source /terraform/proxy.env
echo "`date`: Attemping to accept kali license agreement" | tee -a /terraform/logs/az.log
if [[ -z $az_available || $az_available != "true" ]]; then
echo "`date`: Azure login failed previously. Aborting script." | tee -a /terraform/logs/az.log
exit 1
fi
echo "`date`: az vm image terms show --plan kali --offer kali-linux --publisher kali-linux --query 'accepted'" >>/terraform/logs/az.log
prev_accepted=$(az vm image terms show --plan kali --offer kali-linux --publisher kali-linux --query 'accepted' 2>> /terraform/logs/az.log)
if [ $? -ne 0 ]; then
echo "`date`: Unable to query kali license acceptance status." | tee -a /terraform/logs/az.log
exit 1
fi
if [ "$prev_accepted" = "true" ]; then
echo "`date`: Previously accepted the kali license agreement." | tee -a /terraform/logs/az.log
exit 0
fi
echo "`date`: az vm image terms accept --plan kali --offer kali-linux --publisher kali-linux --query 'accepted'" >>/terraform/logs/az.log 2>&1
accepted=$(az vm image terms accept --plan kali --offer kali-linux --publisher kali-linux --query 'accepted' 2>> /terraform/logs/az.log)
if [ "$accepted" = "true" ]; then
echo "`date`: Successfully accepted the kali lincense agreement" | tee -a /terraform/logs/az.log
else
echo "`date`: Unable to accept the kali license agreement. Please check the log at /terraform/logs/az.log to figure out what went wrong." | tee -a /terraform/logs/az.log
fi