5
codename=$(/usr/bin/lsb_release -s -c)
6
arch=$(dpkg --print-architecture)
7
debinst="sudo debconf-apt-progress -- aptitude -y install"
27
steps="Ubuntu_Version Arch EFI_Mode CCS_Version SID_Check Installed_Ram Virtualization_Support NICs_enabled IPERF Network_Subnets KVM_Image_Check"
30
while getopts "i" opt; do
37
echo -e "\n\e[1;33m============\e[m \e[1;34m$name\e[m \e[1;33m============\e[m"
41
name="Check architecture"
43
echo -e "Architecture: $arch"
44
eval info${i}=\"$arch\"
45
if [ $arch = i386 ] ; then
53
# Display version of canonical-certification-server package installed
55
name="canonical-certification-server version"
57
ccs=$(apt-cache policy canonical-certification-server|grep Installed|awk '{print $2}')
58
eval info${i}=\"$ccs\"
60
if [[ $ccs = *none* ]] ; then
61
echo -e " canonical-certification-server might not be installed.\n Would you like to install it now? [Y/n]"
63
if [[ $a == "Y" || $a == "y" || -z $a ]]; then
64
echo " Installing canonical-certification-server..."
65
sudo apt-add-repository -y ppa:hardware-certification/public 1>/dev/null
66
sudo apt-get -q update 1>/dev/null
67
sudo apt-get -q install -y maas-cert-server 1>/dev/null
69
elif [[ $a == "N" || $a == "n" ]]; then
74
echo " canonical-certification-server: $ccs"
79
# Secure ID is set in /etc/xdg/canonical-certification.conf (?)
81
name="Secure ID Check"
83
#if [ -n $secureid ];then
84
if grep "^secure_id =" /etc/xdg/canonical-certification.conf ; then
85
secureid=$(grep "^secure_id =" /etc/xdg/canonical-certification.conf|awk '{print $3}')
86
echo " secure_id is configured as $secureid"
87
eval info${i}=\"$secureid\"
90
echo -e " secure_id is not configured.\n Would you like to configure it now? [Y/n]"
92
if [[ $a == "Y" || $a == "y" || -z $a ]]; then
93
read -e -p "Type the secure_id of your SUT: " sid
94
sudo sed -i "s/#secure_id =.*/secure_id = $sid/g" /etc/xdg/canonical-certification.conf
96
elif [[ $a == "N" || $a == "n" ]]; then
97
eval info${i}=\"Not Set\"
103
# Check local availability of KVM image & possibly download from MAAS server if it’s available there, rather than have Checkbox pull from Internet, which tends to be slow
105
name="KVM Image Check"
107
kvmurl="http://cloud-images.ubuntu.com/$codename/current/$codename-server-cloudimg-$arch-disk1.img"
108
if grep "^KVM_IMAGE =" /etc/xdg/canonical-certification.conf >/dev/null; then
109
kvmurl=$(grep ^KVM_IMAGE /etc/xdg/canonical-certification.conf|awk '{print $3}')
110
if curl --output /dev/null --silent --head --fail "$kvmurl"; then
111
echo -e " We can get our image from $kvmurl.\n Continuing to use this image"
113
elif [ -f $kvmurl ] ; then
114
echo " Local image $kvmurl exists."
117
echo " We cannot access $kvmurl."
122
if curl --output /dev/null --silent --head --fail "$kvmurl"; then
123
echo -e " We can get our image from $kvmurl.\n Continuing to use this image"
126
echo -e " Cannot access $kvmurl.\n Checking local image configuration."
127
echo -e " KVM_IMAGE is not configured.\n Would you like to configure it now? [Y/n]"
129
if [[ $a == "Y" || $a == "y" || -z $a ]]; then
130
read -e -p "Type the path of your KVM Image: " kvm
131
sudo sed -i "s,#KVM_IMAGE =.*,KVM_IMAGE = $kvm,g" /etc/xdg/canonical-certification.conf
132
kvmurl=$(grep ^KVM_IMAGE /etc/xdg/canonical-certification.conf|awk '{print $3}')
133
if curl --output /dev/null --silent --head --fail "$kvmurl" || [ -f $kvmurl ]; then
134
echo " We can get our image from $kvmurl. Continuing to use this image"
139
elif [[ $a == "N" || $a == "n" ]]; then
146
#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)
148
name="Ubuntu Version"
150
release=$(/usr/bin/lsb_release -s -d)
151
eval info${i}=\"$release\"
152
if [[ $release == *LTS* ]] ; then
153
echo " $release is an LTS version of Ubuntu"
156
echo " $release is a non-LTS version of Ubuntu"
162
# All NICs are on the same network segment, to flag cabling, switch, or configuration errors (??)
164
name="Netork Subnets"
166
check_bcast=$(for nic in `cat /proc/net/dev|grep ":"|awk -F: '{print $1}'|egrep -v "lo|lxcbr|bridge"`
168
ip addr show dev $nic | grep "inet "|awk '{print $4}'
170
for nic in `cat /proc/net/dev|grep ":"|awk -F: '{print $1}'|egrep -v "lo|usb"`
172
echo " $nic - $(ip addr show dev $nic | grep "inet "|awk '{print $2, $4}')"
175
if [ $check_bcast = 1 ]; then
177
echo " All interfaces seem to be on the same subnet"
179
echo " One or more interfaces are on separate subnets"
185
# iperf and iperf3 are available on server specified in /etc/xdg/canonical-certification.conf (NOTE: iperf (2) will eventually become irrelevant)
189
if [ $(grep ^TEST_TARGET_IPERF /etc/xdg/canonical-certification.conf|wc -l) = 1 ];then
190
echo " IPERF is configured"
192
elif [ $(grep ^TEST_TARGET_IPERF /etc/xdg/canonical-certification.conf|wc -l) = 0 ];then
193
echo -e " TEST_TARGET_IPERF is not configured.\n Would you like to configure it now? [Y/n]"
195
if [[ $a == "Y" || $a == "y" || -z $a ]]; then
196
read -e -p "Type the IP Address of the Iperf server: " ip
197
sudo sed -i "s/#TEST_TARGET_IPERF = .*/TEST_TARGET_IPERF = $ip/g" /etc/xdg/canonical-certification.conf
199
elif [[ $a == "N" || $a == "n" ]]; then
205
for iperfserver in $(grep ^TEST_TARGET_IPERF /etc/xdg/canonical-certification.conf | cut -d = -f 2 | sed s/,/\\n/g)
207
echo " Testing $iperfserver"
209
nc -z $iperfserver 5001
211
echo " Iperf server found on port 5001 on $iperfserver"
215
iperf3 -c $iperfserver -n 1 &> /dev/null
217
echo " Iperf3 server found on port 5201 on $iperfserver"
221
if [ $iperffound = 0 ]; then
222
echo " No Iperf (2) or iperf3 server found on $iperfserver"
225
if [[ $iperf2found == 0 ]]; then
226
echo " No iperf (2) server found"
229
if [[ $iperf3found == 0 ]]; then
230
echo " No iperf3 server found"
235
# All NICs are enabled
237
name="All NICs enabled"
239
for nic in `cat /proc/net/dev|grep ":"|awk -F: '{print $1}'|grep -v lo`
241
state=$(cat /sys/class/net/$nic/operstate)
242
if [ $state = "up" ]; then
243
echo " Interface $nic is $state"
245
elif [ $state = "down" ]; then
246
echo " Interface $nic is $state"
250
if [ "$nicfail" = "1" ]; then
255
#### Installed RAM (STG says 4GiB minimum) ###
257
name="Check Installed Ram"
259
mem=$(cat /proc/meminfo |grep MemTotal|awk '{print $2}')
260
eval info${i}="$mem "
261
if [ $mem -lt 4096000 ] ; then
262
echo " $mem is less than 4G"
265
echo " $mem is greater than 4G"
270
#CPU virtualization support (VMX/SVM)
271
Virtualization_Support(){
272
name="Virtualization Support"
274
cat /proc/cpuinfo |egrep "vmx|svm" >/dev/null
276
echo " System has virtualization support"
279
echo " System does not have virtualization support"
284
#EFI-mode installation (redundant with Checkbox test for same, but maybe good to warn about this issue before running Checkbox)
286
name="EFI-mode installation"
288
if [ -d /sys/firmware/efi ]; then
289
efi='This is an EFI Mode installation'
291
eval info${i}=\"$efi\"
293
elif [ ! -d /sys/firmware/efi ]; then
294
efi='This is not an EFI Mode installation'
296
eval info${i}=\"$efi\"
305
eval "status=\$check${i}"
306
if [[ $status == "y" ]] || [[ "$yes" == "1" ]]; then
309
echo -e "\e[1;31mskipping\e[m \e[1;34m$i\e[m"
315
echo -e "\n\e[1;33m============\e[m \e[1;34mReport\e[m \e[1;33m============\e[m\n"
318
eval "status=\$pass${i}"
319
if [ $status = "1" ];then
321
printf "%0.1s" "-"{1..20}
322
printf "\e[1;32m Passed\e[m\n"
323
elif [ $status = "0" ];then
325
printf "%0.1s" "-"{1..20}
326
printf "\e[1;31m Failed\e[m\n"
327
elif [ $status = "2" ];then
328
eval "detail=\$info${i}"
330
printf "%0.1s" "-"{1..20}
331
printf "\e[1;33m $detail\e[m\n"
332
elif [ $status = "3" ];then
333
eval "detail=\$info${i}"
335
printf "%0.1s" "-"{1..20}
336
printf "\e[1;37m $detail\e[m\n"