Merge ~rodsmith/plainbox-provider-certification-server:fix-precheck-usb-test into plainbox-provider-certification-server:master

Proposed by Rod Smith
Status: Merged
Approved by: Jeff Lane 
Approved revision: abcb826b8e3d4da3d581147e046151684dda52ae
Merged at revision: 6363106e7fa3d3aef88557fd0b99519fc91ebbcd
Proposed branch: ~rodsmith/plainbox-provider-certification-server:fix-precheck-usb-test
Merge into: plainbox-provider-certification-server:master
Diff against target: 55 lines (+26/-2)
1 file modified
tools/canonical-certification-precheck (+26/-2)
Reviewer Review Type Date Requested Status
Jeff Lane  Approve
Review via email: mp+316653@code.launchpad.net

Description of the change

Fixes errant detection of "removable" disks on gulpin (and perhaps other servers) as USB drives in precheck script. (Bug #1662693.)

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

thanks

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 e933a0d..a20f873 100755
3--- a/tools/canonical-certification-precheck
4+++ b/tools/canonical-certification-precheck
5@@ -114,6 +114,22 @@ else
6 fi
7 }
8
9+# Sets $usb_disk to 1 if /dev/$1 is a USB disk, or to 0 otherwise
10+Is_USB(){
11+local disk=$1
12+usb_disk=0
13+local drive="/dev/$disk"
14+if [ -d "/sys/bus/usb/devices" ]; then
15+ path=$(readlink -f /sys/block/$disk)
16+ for usbname in $(ls /sys/bus/usb/devices); do
17+ usbpath=$(readlink -f /sys/bus/usb/devices/$usbname)
18+ if [[ "$path" == "$usbpath"* ]]; then
19+ usb_disk=1
20+ fi
21+ done
22+fi
23+}
24+
25 Hard_Disks(){
26 name="Hard Disk Filesystem Check"
27 echoname
28@@ -137,7 +153,8 @@ for disk in $(lsblk -r | grep disk | cut -f 1 -d " "); do
29 esac
30 disk_UUIDs+=($UUID)
31 fi
32- if [ $(cat "/sys/block/$disk/removable") == "0" ]; then
33+ Is_USB $disk
34+ if [ "$usb_disk" == "0" ]; then
35 local fs="$(sudo blkid -s TYPE -o value /dev/$disk* | sort | uniq | tr '\n' ' ' | sed 's/,*$//g')"
36 echo " Filesystem(s) detected on $drive: $fs"
37 if [ -z "$(echo $fs | grep -E ext2\|ext3\|ext4\|xfs\|jfs\|btrfs)" ]; then
38@@ -174,9 +191,16 @@ echoname
39 local all_ok="Y"
40 local usb2_disks=()
41 local usb3_disks=()
42+if [ ! -d "/sys/bus/usb" ]; then
43+ eval info${i}=\"No USB bus\"
44+ echo " No USB bus detected!"
45+ warn
46+ return
47+fi
48 for disk in $(lsblk -r | grep disk | cut -f 1 -d " "); do
49 local drive="/dev/$disk"
50- if [ $(cat "/sys/block/$disk/removable") == "1" ]; then
51+ Is_USB $disk
52+ if [ "$usb_disk" == 1 ]; then
53 local fs="$(sudo blkid -s TYPE -o value /dev/$disk* | sort | uniq | tr '\n' ',' | sed 's/,*$//g')"
54 echo " Filesystem(s) detected on $drive: $fs"
55 if [ "$fs" == "iso9660,vfat" ]; then

Subscribers

People subscribed via source and target branches

to all changes: