Merge ~leftyfb/plainbox-provider-certification-server:1661099-check-section-headers into plainbox-provider-certification-server:master

Proposed by Mike Rushton
Status: Merged
Approved by: Jeff Lane 
Approved revision: b95d666f65842022d4a16deb7f696b19d0208a6a
Merged at revision: 4a20a8f9f8feb9971495a54060e29f76db96b121
Proposed branch: ~leftyfb/plainbox-provider-certification-server:1661099-check-section-headers
Merge into: plainbox-provider-certification-server:master
Diff against target: 147 lines (+51/-12)
1 file modified
tools/canonical-certification-precheck (+51/-12)
Reviewer Review Type Date Requested Status
Jeff Lane  Approve
Review via email: mp+318271@code.launchpad.net

Description of the change

Added XDG config check and cleaned up some code

To post a comment you must log in.
Revision history for this message
Jeff Lane  (bladernr) wrote :

glad you got the push to finally work :D

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tools/canonical-certification-precheck b/tools/canonical-certification-precheck
2index a20f873..80e7a97 100755
3--- a/tools/canonical-certification-precheck
4+++ b/tools/canonical-certification-precheck
5@@ -21,8 +21,7 @@ info(){
6
7
8
9-steps="Ubuntu_Version Arch EFI_Mode CCS_Version SID_Check Installed_Ram Virtualization_Support NICs_enabled IPERF Network_Subnets Hard_Disks USB_Disks KVM_Image_Check"
10-yes=1
11+steps="Ubuntu_Version Arch EFI_Mode CCS_Version SID_Check Installed_Ram Virtualization_Support NICs_enabled IPERF Network_Subnets Hard_Disks USB_Disks KVM_Image_Check XDG_Check"
12
13 while getopts "i" opt; do
14 case $opt in
15@@ -34,6 +33,7 @@ echoname(){
16 echo -e "\n\e[1;33m============\e[m \e[1;34m$name\e[m \e[1;33m============\e[m"
17 }
18
19+# Check architecture
20 Arch(){
21 name="Check architecture"
22 echoname
23@@ -46,6 +46,48 @@ Arch(){
24 fi
25 }
26
27+# Check for valid section headers in xdg config file
28+XDG_Check(){
29+ name="XDG Config file Check"
30+ echoname
31+ failstatus=0
32+ prevstatus=0
33+ for section in common transport:c3 environment
34+ do grep ^'\['$section'\]' /etc/xdg/canonical-certification.conf >/dev/null 2>&1
35+ exitstatus=$?
36+ printf "%15s" " [$section] "
37+ printf "%0.1s" " "{1..5}
38+ if [ $exitstatus = "0" ] ; then
39+ printf "\e[1;32m OK\e[m\n"
40+ failstatus=1
41+ else
42+ printf "\e[1;31m Not found\e[m\n"
43+ if [ $section = "common" ] ; then
44+ failstatus=3
45+ else
46+ failstatus=2
47+ if [ $prevstatus = $failstatus ] ; then
48+ output="[$section],[$prevsection]"
49+ else
50+ output=[$section]
51+ fi
52+ eval info${i}=\"\$output\ missing\"
53+ prevsection=$section
54+ fi
55+ fi
56+ if [ $prevstatus -gt $failstatus ] ; then
57+ failstatus=$prevstatus
58+ fi
59+ prevstatus=$failstatus
60+ done
61+ if [ $failstatus = 3 ] ; then
62+ fail
63+ elif [ $failstatus = 2 ] ; then
64+ warn
65+ else
66+ pass
67+ fi
68+}
69
70 # Display version of canonical-certification-server package installed
71 CCS_Version(){
72@@ -84,11 +126,10 @@ configure_SID(){
73 fi
74 }
75
76-
77+# Check for Secure ID config
78 SID_Check(){
79 name="Secure ID Check"
80 echoname
81-#if [ -n $secureid ];then
82 if grep "^secure_id =" /etc/xdg/canonical-certification.conf >/dev/null ; then
83 secureid=$(grep "^secure_id =" /etc/xdg/canonical-certification.conf|awk '{print $3}')
84 echo " Secure ID is configured as '$secureid'."
85@@ -130,6 +171,7 @@ if [ -d "/sys/bus/usb/devices" ]; then
86 fi
87 }
88
89+# Check for valid filesystem
90 Hard_Disks(){
91 name="Hard Disk Filesystem Check"
92 echoname
93@@ -185,6 +227,7 @@ else
94 fi
95 }
96
97+# Check for USB storage devices
98 USB_Disks(){
99 name="USB Disks Check"
100 echoname
101@@ -327,7 +370,7 @@ if curl --output /dev/null --silent --head -fail "$kvmurl"; then
102 fi
103 }
104
105-#Correct Ubuntu version installed (could be tricky to determine, so maybe too much effort -- or maybe just display the Ubuntu version and, if the script is interactive, ask the user to verify that it’s what was intended)
106+# Correct Ubuntu version installed (could be tricky to determine, so maybe too much effort -- or maybe just display the Ubuntu version and, if the script is interactive, ask the user to verify that it’s what was intended)
107 Ubuntu_Version(){
108 name="Ubuntu Version"
109 echoname
110@@ -451,7 +494,7 @@ case "$worst_status" in
111 esac
112 }
113
114-#### Installed RAM (STG says 4GiB minimum) ###
115+# Installed RAM (STG says 4GiB minimum)
116 Installed_Ram(){
117 name="Check Installed Ram"
118 echoname
119@@ -466,7 +509,7 @@ else
120 fi
121 }
122
123-#CPU virtualization support (VMX/SVM)
124+# CPU virtualization support (VMX/SVM)
125 Virtualization_Support(){
126 name="Virtualization Support"
127 echoname
128@@ -480,7 +523,7 @@ else
129 fi
130 }
131
132-#EFI-mode installation (redundant with Checkbox test for same, but maybe good to warn about this issue before running Checkbox)
133+# EFI-mode installation (redundant with Checkbox test for same, but maybe good to warn about this issue before running Checkbox)
134 EFI_Mode(){
135 name="EFI-mode installation"
136 echoname
137@@ -502,11 +545,7 @@ runchoices() {
138 for i in $steps
139 do
140 eval "status=\$check${i}"
141- if [[ $status == "y" ]] || [[ "$yes" == "1" ]]; then
142 "$i"
143- else
144- echo -e "\e[1;31mskipping\e[m \e[1;34m$i\e[m"
145- fi
146 done
147 }
148

Subscribers

People subscribed via source and target branches