-
Notifications
You must be signed in to change notification settings - Fork 12
/
fipsenable.sh
35 lines (29 loc) · 985 Bytes
/
fipsenable.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
#!/bin/bash
PRO_STATUS="/var/tmp/pro-status.yaml"
pro_status(){
pro status --format yaml > $PRO_STATUS
PRO_ATTACH=$(awk '/machine_id/{print $NF}' $PRO_STATUS)
SRV_STATUS=$(grep -A2 -B5 "^..name:.$1" $PRO_STATUS | awk '/status:/{print $NF}')
}
annotation(){
echo $SRV_STATUS > /var/lib/landscape/client/annotations.d/$1
echo "'pro status' reports $1 is $SRV_STATUS"
chown landscape:landscape /var/lib/landscape/client/annotations.d/$1
}
pro_service(){
pro_status $1
if [[ $PRO_ATTACH == 'null' ]]; then
SRV_STATUS="unavailable"
annotation $1
echo "'pro status' reports this machine is not attached to an Ubuntu Pro subscription."
exit 1
elif [[ ! $SRV_STATUS =~ $2 ]]; then
pro $2 $1 --assume-yes
pro_status $1
fi
annotation $1
echo "This change requires a reboot to fully $2 FIPS on this machine."
if [[ -s $PRO_STATUS ]]; then rm $PRO_STATUS; fi
if [[ ! $SRV_STATUS =~ $2 ]]; then exit 2; fi
}
pro_service fips-updates enable