Merge ~sylvain-pineau/plainbox-provider-checkbox:fix_bin_shellcheck_errors_2 into plainbox-provider-checkbox:master
- Git
- lp:~sylvain-pineau/plainbox-provider-checkbox
- fix_bin_shellcheck_errors_2
- Merge into master
Proposed by
Sylvain Pineau
Status: | Merged |
---|---|
Approved by: | Sylvain Pineau |
Approved revision: | 91f6c7ea3cb7c1c9c3b8434ab1db311821bfe44d |
Merged at revision: | b28bcb03c4188156f85c1cf61baea6000d992876 |
Proposed branch: | ~sylvain-pineau/plainbox-provider-checkbox:fix_bin_shellcheck_errors_2 |
Merge into: | plainbox-provider-checkbox:master |
Diff against target: |
766 lines (+125/-129) 19 files modified
bin/alsa_record_playback.sh (+4/-4) bin/audio_bluetooth_loopback_test.sh (+7/-6) bin/bluetooth_transfer_stress.sh (+6/-6) bin/broadband_info.sh (+1/-1) bin/check_is_laptop.sh (+4/-4) bin/connect_wireless.sh (+17/-19) bin/cycle_vts.sh (+2/-2) bin/disk_cpu_load.sh (+10/-12) bin/disk_read_performance_test.sh (+12/-12) bin/disk_stats_test.sh (+10/-10) bin/graphics_env.sh (+6/-6) bin/led_hdd_test.sh (+5/-3) bin/light_sensor_test.sh (+4/-4) bin/maas-version-check.sh (+4/-4) bin/network_configs.sh (+4/-4) bin/network_printer_test.sh (+7/-7) bin/network_wait.sh (+4/-5) bin/optical_write_test.sh (+17/-17) requirements/container-tests-provider-checkbox (+1/-3) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Checkbox Developers | Pending | ||
Review via email: mp+387969@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/bin/alsa_record_playback.sh b/bin/alsa_record_playback.sh | |||
2 | index e86d7d1..30b2fbd 100755 | |||
3 | --- a/bin/alsa_record_playback.sh | |||
4 | +++ b/bin/alsa_record_playback.sh | |||
5 | @@ -1,7 +1,7 @@ | |||
6 | 1 | #!/bin/sh | 1 | #!/bin/sh |
7 | 2 | 2 | ||
9 | 3 | OUTPUT=`mktemp -d` | 3 | OUTPUT=$(mktemp -d) |
10 | 4 | gst_pipeline_test.py -t 5 "autoaudiosrc ! audioconvert ! level name=recordlevel interval=10000000 ! audioconvert ! wavenc ! filesink location=$OUTPUT/test.wav" | 4 | gst_pipeline_test.py -t 5 "autoaudiosrc ! audioconvert ! level name=recordlevel interval=10000000 ! audioconvert ! wavenc ! filesink location=$OUTPUT/test.wav" |
14 | 5 | aplay $OUTPUT/test.wav | 5 | aplay "$OUTPUT"/test.wav |
15 | 6 | rm $OUTPUT/test.wav | 6 | rm "$OUTPUT"/test.wav |
16 | 7 | rmdir $OUTPUT | 7 | rmdir "$OUTPUT" |
17 | diff --git a/bin/audio_bluetooth_loopback_test.sh b/bin/audio_bluetooth_loopback_test.sh | |||
18 | index 9661ec4..dac3699 100755 | |||
19 | --- a/bin/audio_bluetooth_loopback_test.sh | |||
20 | +++ b/bin/audio_bluetooth_loopback_test.sh | |||
21 | @@ -23,8 +23,8 @@ | |||
22 | 23 | # human validate that record/playback is working, human can speak into | 23 | # human validate that record/playback is working, human can speak into |
23 | 24 | # microphone and just ensure the speech can be heard instantly in the headset. | 24 | # microphone and just ensure the speech can be heard instantly in the headset. |
24 | 25 | 25 | ||
27 | 26 | [ -x "`which pactl`" ] || exit 1 | 26 | [ -x "$(command -v pactl)" ] || exit 1 |
28 | 27 | [ -x "`which pacat`" ] || exit 1 | 27 | [ -x "$(command -v pacat)" ] || exit 1 |
29 | 28 | 28 | ||
30 | 29 | SINK=$(pactl list | sed -n '/monitor/d;s/Name: \(bluez_sink\.\)/\1/p') | 29 | SINK=$(pactl list | sed -n '/monitor/d;s/Name: \(bluez_sink\.\)/\1/p') |
31 | 30 | SOURCE=$(pactl list | sed -n '/monitor/d;s/Name: \(bluez_source\.\)/\1/p') | 30 | SOURCE=$(pactl list | sed -n '/monitor/d;s/Name: \(bluez_source\.\)/\1/p') |
32 | @@ -33,6 +33,7 @@ SOURCE=$(pactl list | sed -n '/monitor/d;s/Name: \(bluez_source\.\)/\1/p') | |||
33 | 33 | if [ -n "$SINK" ] && [ -n "$SOURCE" ]; then | 33 | if [ -n "$SINK" ] && [ -n "$SOURCE" ]; then |
34 | 34 | PLAYBACK_LOG=$(mktemp --tmpdir audio_bluetooth_loopback.XXXXX) | 34 | PLAYBACK_LOG=$(mktemp --tmpdir audio_bluetooth_loopback.XXXXX) |
35 | 35 | RECORD_LOG=$(mktemp --tmpdir audio_bluetooth_loopback.XXXXX) | 35 | RECORD_LOG=$(mktemp --tmpdir audio_bluetooth_loopback.XXXXX) |
36 | 36 | # shellcheck disable=SC2064 | ||
37 | 36 | trap "rm $PLAYBACK_LOG $RECORD_LOG" EXIT | 37 | trap "rm $PLAYBACK_LOG $RECORD_LOG" EXIT |
38 | 37 | # ensure we exit with failure if parec fails, and not with pacat | 38 | # ensure we exit with failure if parec fails, and not with pacat |
39 | 38 | # --playback's error code | 39 | # --playback's error code |
40 | @@ -43,14 +44,14 @@ if [ -n "$SINK" ] && [ -n "$SOURCE" ]; then | |||
41 | 43 | # time out after 6 seconds, forcibly kill after 8 seconds if pacat didn't | 44 | # time out after 6 seconds, forcibly kill after 8 seconds if pacat didn't |
42 | 44 | # respond | 45 | # respond |
43 | 45 | echo "Recording and playing back, please speak into bluetooth microphone" | 46 | echo "Recording and playing back, please speak into bluetooth microphone" |
46 | 46 | timeout -k 8 6 pacat $LATENCY --record -v -d $SOURCE 2>$RECORD_LOG | \ | 47 | timeout -k 8 6 pacat $LATENCY --record -v -d "$SOURCE" 2>"$RECORD_LOG" | \ |
47 | 47 | pacat $LATENCY --playback -v -d $SINK 2>$PLAYBACK_LOG | 48 | pacat $LATENCY --playback -v -d "$SINK" 2>"$PLAYBACK_LOG" |
48 | 48 | 49 | ||
49 | 49 | echo "RECORD LOG" | 50 | echo "RECORD LOG" |
51 | 50 | cat $RECORD_LOG | 51 | cat "$RECORD_LOG" |
52 | 51 | echo "" | 52 | echo "" |
53 | 52 | echo "PLAYBACK LOG" | 53 | echo "PLAYBACK LOG" |
55 | 53 | cat $PLAYBACK_LOG | 54 | cat "$PLAYBACK_LOG" |
56 | 54 | else | 55 | else |
57 | 55 | echo "No bluetooth audio device found" | 56 | echo "No bluetooth audio device found" |
58 | 56 | exit 1 | 57 | exit 1 |
59 | diff --git a/bin/bluetooth_transfer_stress.sh b/bin/bluetooth_transfer_stress.sh | |||
60 | index 36e4de7..1b86dd1 100755 | |||
61 | --- a/bin/bluetooth_transfer_stress.sh | |||
62 | +++ b/bin/bluetooth_transfer_stress.sh | |||
63 | @@ -31,18 +31,18 @@ DESTINATION=$(mktemp --tmpdir bluetooth-stress.XXXXXX) | |||
64 | 31 | REMOTE=$RANDOM | 31 | REMOTE=$RANDOM |
65 | 32 | SIZEKB=10240 | 32 | SIZEKB=10240 |
66 | 33 | echo "Creating ${SIZEKB}KB file to test transfer" | 33 | echo "Creating ${SIZEKB}KB file to test transfer" |
69 | 34 | dd if=/dev/urandom of=$ORIGIN count=$SIZEKB bs=1024 | 34 | dd if=/dev/urandom of="$ORIGIN" count=$SIZEKB bs=1024 |
70 | 35 | ORIGIN_SUM=$(sha256sum $ORIGIN | cut -f 1 -d ' ') | 35 | ORIGIN_SUM=$(sha256sum "$ORIGIN" | cut -f 1 -d ' ') |
71 | 36 | set -o pipefail | 36 | set -o pipefail |
72 | 37 | echo "Sending file using Bluetooth" | 37 | echo "Sending file using Bluetooth" |
74 | 38 | time obexftp -v -b $BTDEVADDR -o $REMOTE --put $ORIGIN 2>&1 | ansi_parser.py | 38 | time obexftp -v -b "$BTDEVADDR" -o $REMOTE --put "$ORIGIN" 2>&1 | ansi_parser.py |
75 | 39 | sleep 5 | 39 | sleep 5 |
76 | 40 | echo "Receiving file using Bluetooth" | 40 | echo "Receiving file using Bluetooth" |
78 | 41 | time obexftp -v -b $BTDEVADDR -o $DESTINATION --get $REMOTE 2>&1 | ansi_parser.py | 41 | time obexftp -v -b "$BTDEVADDR" -o "$DESTINATION" --get $REMOTE 2>&1 | ansi_parser.py |
79 | 42 | # Now checksum destination and compare | 42 | # Now checksum destination and compare |
81 | 43 | DESTINATION_SUM=$(sha256sum $DESTINATION | cut -f 1 -d ' ') | 43 | DESTINATION_SUM=$(sha256sum "$DESTINATION" | cut -f 1 -d ' ') |
82 | 44 | # Clean up before reporting | 44 | # Clean up before reporting |
84 | 45 | rm $ORIGIN $DESTINATION | 45 | rm "$ORIGIN" "$DESTINATION" |
85 | 46 | if [ "$ORIGIN_SUM" = "$DESTINATION_SUM" ]; then | 46 | if [ "$ORIGIN_SUM" = "$DESTINATION_SUM" ]; then |
86 | 47 | echo "Checksums match, file transfer succeeded" | 47 | echo "Checksums match, file transfer succeeded" |
87 | 48 | exit 0 | 48 | exit 0 |
88 | diff --git a/bin/broadband_info.sh b/bin/broadband_info.sh | |||
89 | index aec2ccb..01ec7dc 100755 | |||
90 | --- a/bin/broadband_info.sh | |||
91 | +++ b/bin/broadband_info.sh | |||
92 | @@ -2,5 +2,5 @@ | |||
93 | 2 | 2 | ||
94 | 3 | for i in $(mmcli --simple-status -L | \ | 3 | for i in $(mmcli --simple-status -L | \ |
95 | 4 | awk '/freedesktop\/ModemManager1\/Modem/ {print $1;}'); do | 4 | awk '/freedesktop\/ModemManager1\/Modem/ {print $1;}'); do |
97 | 5 | mmcli -m $i | 5 | mmcli -m "$i" |
98 | 6 | done | 6 | done |
99 | diff --git a/bin/check_is_laptop.sh b/bin/check_is_laptop.sh | |||
100 | index 5820a37..b197441 100755 | |||
101 | --- a/bin/check_is_laptop.sh | |||
102 | +++ b/bin/check_is_laptop.sh | |||
103 | @@ -2,15 +2,15 @@ | |||
104 | 2 | 2 | ||
105 | 3 | # Establish the system type based on DMI info | 3 | # Establish the system type based on DMI info |
106 | 4 | TYPE=$(dmidecode -t 3 | awk '/Type:/ { print $2 }') | 4 | TYPE=$(dmidecode -t 3 | awk '/Type:/ { print $2 }') |
108 | 5 | echo "Type: " $TYPE | 5 | echo "Type: " "$TYPE" |
109 | 6 | 6 | ||
110 | 7 | BATTERY="NO" | 7 | BATTERY="NO" |
112 | 8 | for device in `find /sys -name "type"` | 8 | while IFS= read -r -d '' device |
113 | 9 | do | 9 | do |
115 | 10 | if [ "$(cat $device)" == "Battery" ]; then | 10 | if [ "$(cat "$device")" == "Battery" ]; then |
116 | 11 | BATTERY="YES" | 11 | BATTERY="YES" |
117 | 12 | fi | 12 | fi |
119 | 13 | done | 13 | done < <(find /sys -name "type" -print0) |
120 | 14 | 14 | ||
121 | 15 | echo "Battery: " $BATTERY | 15 | echo "Battery: " $BATTERY |
122 | 16 | 16 | ||
123 | diff --git a/bin/connect_wireless.sh b/bin/connect_wireless.sh | |||
124 | index e39f52c..fc696b2 100755 | |||
125 | --- a/bin/connect_wireless.sh | |||
126 | +++ b/bin/connect_wireless.sh | |||
127 | @@ -2,8 +2,7 @@ | |||
128 | 2 | 2 | ||
129 | 3 | # Check nmcli version | 3 | # Check nmcli version |
130 | 4 | NMCLI_GTE_0_9_10=0 | 4 | NMCLI_GTE_0_9_10=0 |
133 | 5 | nmcli general 2>&1 >/dev/null | 5 | if nmcli general > /dev/null 2>&1; then |
132 | 6 | if [ $? -eq 0 ]; then | ||
134 | 7 | NMCLI_GTE_0_9_10=1 | 6 | NMCLI_GTE_0_9_10=1 |
135 | 8 | fi | 7 | fi |
136 | 9 | 8 | ||
137 | @@ -11,25 +10,23 @@ fi | |||
138 | 11 | conn='' | 10 | conn='' |
139 | 12 | 11 | ||
140 | 13 | if [ $NMCLI_GTE_0_9_10 -eq 0 ]; then | 12 | if [ $NMCLI_GTE_0_9_10 -eq 0 ]; then |
145 | 14 | active_connection=$(nmcli -f SSID,ACTIVE dev wifi list | grep yes) | 13 | if active_connection=$(nmcli -f SSID,ACTIVE dev wifi list | grep yes); then |
146 | 15 | if [ $? -eq 0 ]; then | 14 | ap=$(echo "$active_connection" | awk -F\' '{print $2}') |
147 | 16 | ap=$(echo $active_connection | awk -F\' '{print $2}') | 15 | conn=$(nmcli -t -f UUID,TYPE,NAME con list | grep wireless | grep -e "$ap$" | head -n 1 | awk -F: '{print $1}') |
144 | 17 | conn=$(nmcli -t -f UUID,TYPE,NAME con list | grep wireless | grep -e "$ap$" | head -n 1 | awk -F\: '{print $1}') | ||
148 | 18 | else | 16 | else |
150 | 19 | conn=$(nmcli -t -f UUID,TYPE con list | grep wireless | head -n 1 | awk -F\: '{print $1}') | 17 | conn=$(nmcli -t -f UUID,TYPE con list | grep wireless | head -n 1 | awk -F: '{print $1}') |
151 | 20 | fi | 18 | fi |
152 | 21 | else | 19 | else |
157 | 22 | active_connection=$(nmcli -f SSID,ACTIVE dev wifi | grep yes) | 20 | if active_connection=$(nmcli -f SSID,ACTIVE dev wifi | grep yes); then |
158 | 23 | if [ $? -eq 0 ]; then | 21 | ap=$(echo "$active_connection" | awk '{print $1}') |
159 | 24 | ap=$(echo $active_connection | awk '{print $1}') | 22 | conn=$(nmcli -t -f UUID,TYPE,NAME con show | grep wireless | grep -e "$ap$" | head -n 1 | awk -F: '{print $1}') |
156 | 25 | conn=$(nmcli -t -f UUID,TYPE,NAME con show | grep wireless | grep -e "$ap$" | head -n 1 | awk -F\: '{print $1}') | ||
160 | 26 | else | 23 | else |
162 | 27 | conn=$(nmcli -t -f UUID,TYPE con show | grep wireless | head -n 1 | awk -F\: '{print $1}') | 24 | conn=$(nmcli -t -f UUID,TYPE con show | grep wireless | head -n 1 | awk -F: '{print $1}') |
163 | 28 | fi | 25 | fi |
164 | 29 | fi | 26 | fi |
165 | 30 | 27 | ||
166 | 31 | #Strip trailing/leading whitespace | 28 | #Strip trailing/leading whitespace |
168 | 32 | conn=$(echo $conn |sed 's/^[ \t]*//;s/[ \t]*$//') | 29 | conn=$(echo "$conn" |sed 's/^[ \t]*//;s/[ \t]*$//') |
169 | 33 | 30 | ||
170 | 34 | # Find out if wireless is enabled | 31 | # Find out if wireless is enabled |
171 | 35 | if [ $NMCLI_GTE_0_9_10 -eq 0 ]; then | 32 | if [ $NMCLI_GTE_0_9_10 -eq 0 ]; then |
172 | @@ -37,6 +34,7 @@ if [ $NMCLI_GTE_0_9_10 -eq 0 ]; then | |||
173 | 37 | else | 34 | else |
174 | 38 | nmcli radio wifi | grep -q 'enabled' | 35 | nmcli radio wifi | grep -q 'enabled' |
175 | 39 | fi | 36 | fi |
176 | 37 | # shellcheck disable=SC2181 | ||
177 | 40 | if [ $? -ne 0 ] | 38 | if [ $? -ne 0 ] |
178 | 41 | then | 39 | then |
179 | 42 | # Find out why | 40 | # Find out why |
180 | @@ -45,21 +43,21 @@ then | |||
181 | 45 | then | 43 | then |
182 | 46 | blkmessage='Your wireless may be hardware blocked. You may need | 44 | blkmessage='Your wireless may be hardware blocked. You may need |
183 | 47 | to use your wireless key/switch to re-enable it.' | 45 | to use your wireless key/switch to re-enable it.' |
185 | 48 | echo $blkmessage | 46 | echo "$blkmessage" |
186 | 49 | fi | 47 | fi |
187 | 50 | fi | 48 | fi |
188 | 51 | 49 | ||
189 | 52 | # Check if there's a connection already (wireless or otherwise) | 50 | # Check if there's a connection already (wireless or otherwise) |
192 | 53 | nmcli dev status | grep -q '\<connected\>' | 51 | |
193 | 54 | if [ $? -eq 0 ] | 52 | if nmcli dev status | grep -q '\<connected\>'; |
194 | 55 | then | 53 | then |
195 | 56 | # Disconnect, pause for a short time | 54 | # Disconnect, pause for a short time |
197 | 57 | for iface in `(nmcli -f GENERAL dev list 2>/dev/null || nmcli -f GENERAL dev show) | grep 'GENERAL.DEVICE' | awk '{print $2}'` | 55 | for iface in $( (nmcli -f GENERAL dev list 2>/dev/null || nmcli -f GENERAL dev show) | grep 'GENERAL.DEVICE' | awk '{print $2}') |
198 | 58 | do | 56 | do |
199 | 59 | if [ $NMCLI_GTE_0_9_10 -eq 0 ]; then | 57 | if [ $NMCLI_GTE_0_9_10 -eq 0 ]; then |
201 | 60 | nmcli dev disconnect iface $iface | 58 | nmcli dev disconnect iface "$iface" |
202 | 61 | else | 59 | else |
204 | 62 | nmcli dev disconnect $iface | 60 | nmcli dev disconnect "$iface" |
205 | 63 | fi | 61 | fi |
206 | 64 | done | 62 | done |
207 | 65 | sleep 2 | 63 | sleep 2 |
208 | diff --git a/bin/cycle_vts.sh b/bin/cycle_vts.sh | |||
209 | index c5e1677..a42f8c1 100755 | |||
210 | --- a/bin/cycle_vts.sh | |||
211 | +++ b/bin/cycle_vts.sh | |||
212 | @@ -4,7 +4,7 @@ set -o errexit | |||
213 | 4 | 4 | ||
214 | 5 | # NB: This script must be run with root privileges in order to have any effect! | 5 | # NB: This script must be run with root privileges in order to have any effect! |
215 | 6 | 6 | ||
217 | 7 | CURRENT_VT=`/bin/fgconsole` | 7 | CURRENT_VT=$(/bin/fgconsole) |
218 | 8 | 8 | ||
219 | 9 | if [ "$CURRENT_VT" == "" ] | 9 | if [ "$CURRENT_VT" == "" ] |
220 | 10 | then | 10 | then |
221 | @@ -24,7 +24,7 @@ chvt "$CURRENT_VT" | |||
222 | 24 | sleep 2 | 24 | sleep 2 |
223 | 25 | 25 | ||
224 | 26 | # make sure we switched back | 26 | # make sure we switched back |
226 | 27 | END_VT=`/bin/fgconsole` | 27 | END_VT=$(/bin/fgconsole) |
227 | 28 | if [ "$END_VT" -ne "$CURRENT_VT" ] | 28 | if [ "$END_VT" -ne "$CURRENT_VT" ] |
228 | 29 | then | 29 | then |
229 | 30 | echo "didn't get back to the original VT" >&2 | 30 | echo "didn't get back to the original VT" >&2 |
230 | diff --git a/bin/disk_cpu_load.sh b/bin/disk_cpu_load.sh | |||
231 | index adad55f..a4c45cb 100755 | |||
232 | --- a/bin/disk_cpu_load.sh | |||
233 | +++ b/bin/disk_cpu_load.sh | |||
234 | @@ -44,7 +44,6 @@ set -e | |||
235 | 44 | 44 | ||
236 | 45 | get_params() { | 45 | get_params() { |
237 | 46 | disk_device="/dev/sda" | 46 | disk_device="/dev/sda" |
238 | 47 | short_device="sda" | ||
239 | 48 | verbose=0 | 47 | verbose=0 |
240 | 49 | max_load=30 | 48 | max_load=30 |
241 | 50 | xfer=4096 | 49 | xfer=4096 |
242 | @@ -59,9 +58,8 @@ get_params() { | |||
243 | 59 | --verbose) verbose=1 | 58 | --verbose) verbose=1 |
244 | 60 | ;; | 59 | ;; |
245 | 61 | *) disk_device="/dev/$1" | 60 | *) disk_device="/dev/$1" |
249 | 62 | disk_device=`echo $disk_device | sed "s/\/dev\/\/dev/\/dev/g"` | 61 | disk_device=$(echo "$disk_device" | sed "s/\/dev\/\/dev/\/dev/g") |
250 | 63 | short_device=$(echo $disk_device | sed "s/\/dev//g") | 62 | if [ ! -b "$disk_device" ] ; then |
248 | 64 | if [ ! -b $disk_device ] ; then | ||
251 | 65 | echo "Unknown block device \"$disk_device\"" | 63 | echo "Unknown block device \"$disk_device\"" |
252 | 66 | echo "Usage: $0 [ --max-load <load> ] [ --xfer <mebibytes> ]" | 64 | echo "Usage: $0 [ --max-load <load> ] [ --xfer <mebibytes> ]" |
253 | 67 | echo " [ device-file ]" | 65 | echo " [ device-file ]" |
254 | @@ -82,8 +80,8 @@ get_params() { | |||
255 | 82 | sum_array() { | 80 | sum_array() { |
256 | 83 | local array=("${@}") | 81 | local array=("${@}") |
257 | 84 | total=0 | 82 | total=0 |
260 | 85 | for i in ${array[@]}; do | 83 | for i in "${array[@]}"; do |
261 | 86 | let total+=$i | 84 | (( total+=i )) |
262 | 87 | done | 85 | done |
263 | 88 | } # sum_array() | 86 | } # sum_array() |
264 | 89 | 87 | ||
265 | @@ -98,10 +96,10 @@ sum_array() { | |||
266 | 98 | compute_cpu_load() { | 96 | compute_cpu_load() { |
267 | 99 | local start_use | 97 | local start_use |
268 | 100 | local end_use | 98 | local end_use |
271 | 101 | IFS=' ' read -r -a start_use <<< $1 | 99 | IFS=' ' read -r -a start_use <<< "$1" |
272 | 102 | IFS=' ' read -r -a end_use <<< $2 | 100 | IFS=' ' read -r -a end_use <<< "$2" |
273 | 103 | local diff_idle | 101 | local diff_idle |
275 | 104 | let diff_idle=${end_use[3]}-${start_use[3]} | 102 | (( diff_idle=end_use[3]-start_use[3] )) |
276 | 105 | 103 | ||
277 | 106 | sum_array "${start_use[@]}" | 104 | sum_array "${start_use[@]}" |
278 | 107 | local start_total=$total | 105 | local start_total=$total |
279 | @@ -110,8 +108,8 @@ compute_cpu_load() { | |||
280 | 110 | 108 | ||
281 | 111 | local diff_total | 109 | local diff_total |
282 | 112 | local diff_used | 110 | local diff_used |
285 | 113 | let diff_total=${end_total}-${start_total} | 111 | (( diff_total=end_total-start_total )) |
286 | 114 | let diff_used=$diff_total-$diff_idle | 112 | (( diff_used=diff_total-diff_idle )) |
287 | 115 | 113 | ||
288 | 116 | if [ "$verbose" == "1" ] ; then | 114 | if [ "$verbose" == "1" ] ; then |
289 | 117 | echo "Start CPU time = $start_total" | 115 | echo "Start CPU time = $start_total" |
290 | @@ -136,7 +134,7 @@ get_params "$@" | |||
291 | 136 | retval=0 | 134 | retval=0 |
292 | 137 | echo "Testing CPU load when reading $xfer MiB from $disk_device" | 135 | echo "Testing CPU load when reading $xfer MiB from $disk_device" |
293 | 138 | echo "Maximum acceptable CPU load is $max_load" | 136 | echo "Maximum acceptable CPU load is $max_load" |
295 | 139 | blockdev --flushbufs $disk_device | 137 | blockdev --flushbufs "$disk_device" |
296 | 140 | start_load="$(grep "cpu " /proc/stat | tr -s " " | cut -d " " -f 2-)" | 138 | start_load="$(grep "cpu " /proc/stat | tr -s " " | cut -d " " -f 2-)" |
297 | 141 | if [ "$verbose" == "1" ] ; then | 139 | if [ "$verbose" == "1" ] ; then |
298 | 142 | echo "Beginning disk read...." | 140 | echo "Beginning disk read...." |
299 | diff --git a/bin/disk_read_performance_test.sh b/bin/disk_read_performance_test.sh | |||
300 | index 7734543..28d0860 100755 | |||
301 | --- a/bin/disk_read_performance_test.sh | |||
302 | +++ b/bin/disk_read_performance_test.sh | |||
303 | @@ -6,17 +6,17 @@ | |||
304 | 6 | #Default to a lower bound of 15 MB/s | 6 | #Default to a lower bound of 15 MB/s |
305 | 7 | DEFAULT_BUF_READ=${DISK_READ_PERF:-15} | 7 | DEFAULT_BUF_READ=${DISK_READ_PERF:-15} |
306 | 8 | 8 | ||
308 | 9 | for disk in $@; do | 9 | for disk in "$@"; do |
309 | 10 | 10 | ||
310 | 11 | echo "Beginning $0 test for $disk" | 11 | echo "Beginning $0 test for $disk" |
311 | 12 | echo "---------------------------------------------------" | 12 | echo "---------------------------------------------------" |
312 | 13 | 13 | ||
315 | 14 | disk_type=`udevadm info --name /dev/$disk --query property | grep "ID_BUS" | awk '{gsub(/ID_BUS=/," ")}{printf $1}'` | 14 | disk_type=$(udevadm info --name /dev/"$disk" --query property | grep "ID_BUS" | awk '{gsub(/ID_BUS=/," ")}{printf $1}') |
316 | 15 | dev_path=`udevadm info --name /dev/$disk --query property | grep "DEVPATH" | awk '{gsub(/DEVPATH=/," ")}{printf $1}'` | 15 | dev_path=$(udevadm info --name /dev/"$disk" --query property | grep "DEVPATH" | awk '{gsub(/DEVPATH=/," ")}{printf $1}') |
317 | 16 | # /sys/block/$disk/queue/rotational was added with Linux 2.6.29. If file is | 16 | # /sys/block/$disk/queue/rotational was added with Linux 2.6.29. If file is |
318 | 17 | # not present, test below will fail & disk will be considered an HDD, not | 17 | # not present, test below will fail & disk will be considered an HDD, not |
319 | 18 | # an SSD. | 18 | # an SSD. |
321 | 19 | rotational=`cat /sys/block/$disk/queue/rotational` | 19 | rotational=$(cat /sys/block/"$disk"/queue/rotational) |
322 | 20 | if [[ $dev_path =~ dm ]]; then | 20 | if [[ $dev_path =~ dm ]]; then |
323 | 21 | disk_type="devmapper" | 21 | disk_type="devmapper" |
324 | 22 | fi | 22 | fi |
325 | @@ -47,10 +47,10 @@ for disk in $@; do | |||
326 | 47 | MIN_BUF_READ=7 | 47 | MIN_BUF_READ=7 |
327 | 48 | 48 | ||
328 | 49 | # Increase MIN_BUF_READ if a USB3 device is plugged in a USB3 hub port | 49 | # Increase MIN_BUF_READ if a USB3 device is plugged in a USB3 hub port |
333 | 50 | if [[ $dev_path =~ ((.*usb[0-9]+).*\/)[0-9]-[0-9\.:\-]+\/.* ]]; then | 50 | if [[ $dev_path =~ ((.*usb[0-9]+).*\/)[0-9]-[0-9\.:-]+/.* ]]; then |
334 | 51 | device_version=`cat '/sys/'${BASH_REMATCH[1]}'/version'` | 51 | device_version=$(cat '/sys/'"${BASH_REMATCH[1]}"'/version') |
335 | 52 | hub_port_version=`cat '/sys/'${BASH_REMATCH[2]}'/version'` | 52 | hub_port_version=$(cat '/sys/'"${BASH_REMATCH[2]}"'/version') |
336 | 53 | if [ $(echo "$device_version >= 3.00"|bc -l) -eq 1 -a $(echo "$hub_port_version >= 3.00"|bc -l) -eq 1 ]; then | 53 | if [ "$(echo "$device_version >= 3.00"|bc -l)" -eq 1 ] && [ "$(echo "$hub_port_version >= 3.00"|bc -l)" -eq 1 ]; then |
337 | 54 | MIN_BUF_READ=80 | 54 | MIN_BUF_READ=80 |
338 | 55 | fi | 55 | fi |
339 | 56 | fi | 56 | fi |
340 | @@ -73,8 +73,8 @@ for disk in $@; do | |||
341 | 73 | echo "Beginning hdparm timing runs" | 73 | echo "Beginning hdparm timing runs" |
342 | 74 | echo "---------------------------------------------------" | 74 | echo "---------------------------------------------------" |
343 | 75 | 75 | ||
346 | 76 | for iteration in `seq 1 10`; do | 76 | for iteration in $(seq 1 10); do |
347 | 77 | speed=`hdparm -t /dev/$disk 2>/dev/null | grep "Timing buffered disk reads" | awk -F"=" '{print $2}' | awk '{print $1}'` | 77 | speed=$(hdparm -t /dev/"$disk" 2>/dev/null | grep "Timing buffered disk reads" | awk -F"=" '{print $2}' | awk '{print $1}') |
348 | 78 | echo "INFO: Iteration $iteration: Detected speed is $speed MB/sec" | 78 | echo "INFO: Iteration $iteration: Detected speed is $speed MB/sec" |
349 | 79 | 79 | ||
350 | 80 | if [ -z "$speed" ]; then | 80 | if [ -z "$speed" ]; then |
351 | @@ -83,7 +83,7 @@ for disk in $@; do | |||
352 | 83 | fi | 83 | fi |
353 | 84 | 84 | ||
354 | 85 | speed=${speed/.*} | 85 | speed=${speed/.*} |
356 | 86 | if [ $speed -gt $max_speed ]; then | 86 | if [ "$speed" -gt $max_speed ]; then |
357 | 87 | max_speed=$speed | 87 | max_speed=$speed |
358 | 88 | fi | 88 | fi |
359 | 89 | done | 89 | done |
360 | @@ -91,7 +91,7 @@ for disk in $@; do | |||
361 | 91 | echo "---------------------------------------------------" | 91 | echo "---------------------------------------------------" |
362 | 92 | echo "" | 92 | echo "" |
363 | 93 | result=0 | 93 | result=0 |
365 | 94 | if [ $max_speed -gt $MIN_BUF_READ ]; then | 94 | if [ "$max_speed" -gt "$MIN_BUF_READ" ]; then |
366 | 95 | echo "PASS: $disk Max Speed of $max_speed MB/sec is faster than Minimum Buffer Read Speed of $MIN_BUF_READ MB/sec" | 95 | echo "PASS: $disk Max Speed of $max_speed MB/sec is faster than Minimum Buffer Read Speed of $MIN_BUF_READ MB/sec" |
367 | 96 | else | 96 | else |
368 | 97 | echo "FAIL: $disk Max Speed of $max_speed MB/sec is slower than Minimum Buffer Read Speed of $MIN_BUF_READ MB/sec" | 97 | echo "FAIL: $disk Max Speed of $max_speed MB/sec is slower than Minimum Buffer Read Speed of $MIN_BUF_READ MB/sec" |
369 | diff --git a/bin/disk_stats_test.sh b/bin/disk_stats_test.sh | |||
370 | index 60b48f5..41ef626 100755 | |||
371 | --- a/bin/disk_stats_test.sh | |||
372 | +++ b/bin/disk_stats_test.sh | |||
373 | @@ -16,7 +16,7 @@ check_return_code() { | |||
374 | 16 | shift | 16 | shift |
375 | 17 | shift | 17 | shift |
376 | 18 | for item in "$@"; do | 18 | for item in "$@"; do |
378 | 19 | echo "output: "$item | 19 | echo "output: ""$item" |
379 | 20 | done | 20 | done |
380 | 21 | fi | 21 | fi |
381 | 22 | fi | 22 | fi |
382 | @@ -29,19 +29,19 @@ fi | |||
383 | 29 | nvdimm="pmem" | 29 | nvdimm="pmem" |
384 | 30 | if [ -z "${DISK##*$nvdimm*}" ];then | 30 | if [ -z "${DISK##*$nvdimm*}" ];then |
385 | 31 | echo "Disk $DISK appears to be an NVDIMM, skipping" | 31 | echo "Disk $DISK appears to be an NVDIMM, skipping" |
387 | 32 | exit $STATUS | 32 | exit "$STATUS" |
388 | 33 | fi | 33 | fi |
389 | 34 | 34 | ||
390 | 35 | #Check /proc/partitions, exit with fail if disk isn't found | 35 | #Check /proc/partitions, exit with fail if disk isn't found |
392 | 36 | grep -w -q $DISK /proc/partitions | 36 | grep -w -q "$DISK" /proc/partitions |
393 | 37 | check_return_code $? "Disk $DISK not found in /proc/partitions" | 37 | check_return_code $? "Disk $DISK not found in /proc/partitions" |
394 | 38 | 38 | ||
395 | 39 | #Next, check /proc/diskstats | 39 | #Next, check /proc/diskstats |
397 | 40 | grep -w -q -m 1 $DISK /proc/diskstats | 40 | grep -w -q -m 1 "$DISK" /proc/diskstats |
398 | 41 | check_return_code $? "Disk $DISK not found in /proc/diskstats" | 41 | check_return_code $? "Disk $DISK not found in /proc/diskstats" |
399 | 42 | 42 | ||
400 | 43 | #Verify the disk shows up in /sys/block/ | 43 | #Verify the disk shows up in /sys/block/ |
402 | 44 | ls /sys/block | grep -w -q $DISK | 44 | ls /sys/block/*"$DISK"* > /dev/null 2>&1 |
403 | 45 | check_return_code $? "Disk $DISK not found in /sys/block" | 45 | check_return_code $? "Disk $DISK not found in /sys/block" |
404 | 46 | 46 | ||
405 | 47 | #Verify there are stats in /sys/block/$DISK/stat | 47 | #Verify there are stats in /sys/block/$DISK/stat |
406 | @@ -49,8 +49,8 @@ check_return_code $? "Disk $DISK not found in /sys/block" | |||
407 | 49 | check_return_code $? "stat is either empty or nonexistant in /sys/block/$DISK/" | 49 | check_return_code $? "stat is either empty or nonexistant in /sys/block/$DISK/" |
408 | 50 | 50 | ||
409 | 51 | #Get some baseline stats for use later | 51 | #Get some baseline stats for use later |
412 | 52 | PROC_STAT_BEGIN=`grep -w -m 1 $DISK /proc/diskstats` | 52 | PROC_STAT_BEGIN=$(grep -w -m 1 "$DISK" /proc/diskstats) |
413 | 53 | SYS_STAT_BEGIN=`cat /sys/block/$DISK/stat` | 53 | SYS_STAT_BEGIN=$(cat /sys/block/"$DISK"/stat) |
414 | 54 | 54 | ||
415 | 55 | #Generate some disk activity using hdparm -t | 55 | #Generate some disk activity using hdparm -t |
416 | 56 | hdparm -t "/dev/$DISK" 2&> /dev/null | 56 | hdparm -t "/dev/$DISK" 2&> /dev/null |
417 | @@ -59,8 +59,8 @@ hdparm -t "/dev/$DISK" 2&> /dev/null | |||
418 | 59 | sleep 5 | 59 | sleep 5 |
419 | 60 | 60 | ||
420 | 61 | #Make sure the stats have changed: | 61 | #Make sure the stats have changed: |
423 | 62 | PROC_STAT_END=`grep -w -m 1 $DISK /proc/diskstats` | 62 | PROC_STAT_END=$(grep -w -m 1 "$DISK" /proc/diskstats) |
424 | 63 | SYS_STAT_END=`cat /sys/block/$DISK/stat` | 63 | SYS_STAT_END=$(cat /sys/block/"$DISK"/stat) |
425 | 64 | 64 | ||
426 | 65 | [[ "$PROC_STAT_BEGIN" != "$PROC_STAT_END" ]] | 65 | [[ "$PROC_STAT_BEGIN" != "$PROC_STAT_END" ]] |
427 | 66 | check_return_code $? "Stats in /proc/diskstats did not change" \ | 66 | check_return_code $? "Stats in /proc/diskstats did not change" \ |
428 | @@ -73,4 +73,4 @@ if [[ $STATUS -eq 0 ]]; then | |||
429 | 73 | echo "PASS: Finished testing stats for $DISK" | 73 | echo "PASS: Finished testing stats for $DISK" |
430 | 74 | fi | 74 | fi |
431 | 75 | 75 | ||
433 | 76 | exit $STATUS | 76 | exit "$STATUS" |
434 | diff --git a/bin/graphics_env.sh b/bin/graphics_env.sh | |||
435 | index 5160ae6..b3ee60b 100755 | |||
436 | --- a/bin/graphics_env.sh | |||
437 | +++ b/bin/graphics_env.sh | |||
438 | @@ -12,15 +12,15 @@ INDEX=$2 | |||
439 | 12 | # We only want to set the DRI_PRIME env variable on systems with more than | 12 | # We only want to set the DRI_PRIME env variable on systems with more than |
440 | 13 | # 1 GPU running the amdgpu/radeon drivers. | 13 | # 1 GPU running the amdgpu/radeon drivers. |
441 | 14 | if [[ $DRIVER == "amdgpu" || $DRIVER == "radeon" ]]; then | 14 | if [[ $DRIVER == "amdgpu" || $DRIVER == "radeon" ]]; then |
445 | 15 | NB_GPU=`udev_resource.py -l VIDEO | grep -oP -m1 '\d+'` | 15 | NB_GPU=$(udev_resource.py -l VIDEO | grep -oP -m1 '\d+') |
446 | 16 | if [ $NB_GPU -gt 1 ]; then | 16 | if [[ $NB_GPU -gt 1 ]]; then |
447 | 17 | if [ $INDEX -gt 1 ]; then | 17 | if [[ $INDEX -gt 1 ]]; then |
448 | 18 | # See https://wiki.archlinux.org/index.php/PRIME | 18 | # See https://wiki.archlinux.org/index.php/PRIME |
449 | 19 | echo "Setting up PRIME GPU offloading for AMD discrete GPU" | 19 | echo "Setting up PRIME GPU offloading for AMD discrete GPU" |
450 | 20 | if ! cat /var/log/Xorg.0.log ~/.local/share/xorg/Xorg.0.log 2>&1 | grep -q DRI3; then | 20 | if ! cat /var/log/Xorg.0.log ~/.local/share/xorg/Xorg.0.log 2>&1 | grep -q DRI3; then |
454 | 21 | PROVIDER_ID=`xrandr --listproviders | grep "Sink Output" | awk {'print $4'} | tail -1` | 21 | PROVIDER_ID=$(xrandr --listproviders | grep "Sink Output" | awk '{print $4}' | tail -1) |
455 | 22 | SINK_ID=`xrandr --listproviders | grep "Source Output" | awk {'print $4'} | tail -1` | 22 | SINK_ID=$(xrandr --listproviders | grep "Source Output" | awk '{print $4}' | tail -1) |
456 | 23 | xrandr --setprovideroffloadsink ${PROVIDER_ID} ${SINK_ID} | 23 | xrandr --setprovideroffloadsink "${PROVIDER_ID}" "${SINK_ID}" |
457 | 24 | fi | 24 | fi |
458 | 25 | export DRI_PRIME=1 | 25 | export DRI_PRIME=1 |
459 | 26 | else | 26 | else |
460 | diff --git a/bin/led_hdd_test.sh b/bin/led_hdd_test.sh | |||
461 | index eac6ae2..f3f9808 100755 | |||
462 | --- a/bin/led_hdd_test.sh | |||
463 | +++ b/bin/led_hdd_test.sh | |||
464 | @@ -1,20 +1,22 @@ | |||
465 | 1 | #!/bin/bash | 1 | #!/bin/bash |
466 | 2 | 2 | ||
467 | 3 | TIMEOUT=3 | 3 | TIMEOUT=3 |
469 | 4 | TEMPFILE=`mktemp` | 4 | TEMPFILE=$(mktemp) |
470 | 5 | 5 | ||
471 | 6 | # shellcheck disable=SC2064 | ||
472 | 6 | trap "rm $TEMPFILE" EXIT | 7 | trap "rm $TEMPFILE" EXIT |
473 | 7 | 8 | ||
474 | 9 | # shellcheck disable=SC2034 | ||
475 | 8 | for i in $(seq $TIMEOUT); do | 10 | for i in $(seq $TIMEOUT); do |
476 | 9 | #launch background writer | 11 | #launch background writer |
478 | 10 | dd if=/dev/urandom of=$TEMPFILE bs=1024 oflag=direct & | 12 | dd if=/dev/urandom of="$TEMPFILE" bs=1024 oflag=direct & |
479 | 11 | WRITE_PID=$! | 13 | WRITE_PID=$! |
480 | 12 | echo "Writing..." | 14 | echo "Writing..." |
481 | 13 | sleep 1 | 15 | sleep 1 |
482 | 14 | kill $WRITE_PID | 16 | kill $WRITE_PID |
483 | 15 | sync | 17 | sync |
484 | 16 | echo "Reading..." | 18 | echo "Reading..." |
486 | 17 | dd if=$TEMPFILE of=/dev/null bs=1024 iflag=direct | 19 | dd if="$TEMPFILE" of=/dev/null bs=1024 iflag=direct |
487 | 18 | done | 20 | done |
488 | 19 | 21 | ||
489 | 20 | echo "OK, now exiting" | 22 | echo "OK, now exiting" |
490 | diff --git a/bin/light_sensor_test.sh b/bin/light_sensor_test.sh | |||
491 | index f413396..cb8fbe9 100755 | |||
492 | --- a/bin/light_sensor_test.sh | |||
493 | +++ b/bin/light_sensor_test.sh | |||
494 | @@ -20,18 +20,18 @@ echo -e "\e[92mwaiting for sensor to be covered......\e[0m" | |||
495 | 20 | sleep 3 | 20 | sleep 3 |
496 | 21 | 21 | ||
497 | 22 | #Output and print light sensor events 5 sec to light_sensor_test.log | 22 | #Output and print light sensor events 5 sec to light_sensor_test.log |
499 | 23 | timeout 5 monitor-sensor | tee $PLAINBOX_SESSION_SHARE/light_sensor_test.log & | 23 | timeout 5 monitor-sensor | tee "$PLAINBOX_SESSION_SHARE"/light_sensor_test.log & |
500 | 24 | 24 | ||
501 | 25 | 25 | ||
502 | 26 | #Print backlight value for 5 sec on the screen | 26 | #Print backlight value for 5 sec on the screen |
503 | 27 | for i in {1..10} | 27 | for i in {1..10} |
504 | 28 | do | 28 | do |
506 | 29 | echo "Current Backlight Percentage is:" $(gdbus call --session --dest org.gnome.SettingsDaemon.Power --object-path /org/gnome/SettingsDaemon/Power --method org.freedesktop.DBus.Properties.Get org.gnome.SettingsDaemon.Power.Screen Brightness)| tr -d '()<>,' | 29 | echo "Current Backlight Percentage is:" "$(gdbus call --session --dest org.gnome.SettingsDaemon.Power --object-path /org/gnome/SettingsDaemon/Power --method org.freedesktop.DBus.Properties.Get org.gnome.SettingsDaemon.Power.Screen Brightness)"| tr -d '()<>,' |
507 | 30 | sleep 0.5 | 30 | sleep 0.5 |
508 | 31 | done | 31 | done |
509 | 32 | 32 | ||
510 | 33 | # Fail when the user didn't wave their hand and no events have been collected. | 33 | # Fail when the user didn't wave their hand and no events have been collected. |
512 | 34 | if [[ $(cat $PLAINBOX_SESSION_SHARE/light_sensor_test.log | grep "Light changed" | wc -l) -lt 5 ]]; then | 34 | if [[ $(grep -c "Light changed" "$PLAINBOX_SESSION_SHARE"/light_sensor_test.log) -lt 5 ]]; then |
513 | 35 | echo -e "\e[91mFAIL: Not enough data to be collect, Please rerun the test case and wave your hand around Light Sensor.\e[0m" | 35 | echo -e "\e[91mFAIL: Not enough data to be collect, Please rerun the test case and wave your hand around Light Sensor.\e[0m" |
514 | 36 | exit 1 | 36 | exit 1 |
515 | 37 | fi | 37 | fi |
516 | @@ -40,7 +40,7 @@ fi | |||
517 | 40 | #Print 5 values of the Light sensor value form log file | 40 | #Print 5 values of the Light sensor value form log file |
518 | 41 | for i in {1..5} | 41 | for i in {1..5} |
519 | 42 | do | 42 | do |
521 | 43 | echo "Ambient light sensor value " $i: `grep 'Light' $PLAINBOX_SESSION_SHARE/light_sensor_test.log | awk '{print $3}' | sed -n "$i"p` | 43 | echo "Ambient light sensor value " $i: "$(grep 'Light' "$PLAINBOX_SESSION_SHARE"/light_sensor_test.log | awk '{print $3}' | sed -n "$i"p)" |
522 | 44 | done | 44 | done |
523 | 45 | exit 0 | 45 | exit 0 |
524 | 46 | 46 | ||
525 | diff --git a/bin/maas-version-check.sh b/bin/maas-version-check.sh | |||
526 | index 678088a..6856354 100755 | |||
527 | --- a/bin/maas-version-check.sh | |||
528 | +++ b/bin/maas-version-check.sh | |||
529 | @@ -22,13 +22,13 @@ MIN_VERSION="2.0" | |||
530 | 22 | 22 | ||
531 | 23 | # Is the file there? | 23 | # Is the file there? |
532 | 24 | if [ -s $MAAS_FILE ]; then | 24 | if [ -s $MAAS_FILE ]; then |
535 | 25 | maas_version=`cat $MAAS_FILE` | 25 | maas_version=$(cat $MAAS_FILE) |
536 | 26 | echo $maas_version | 26 | echo "$maas_version" |
537 | 27 | else | 27 | else |
538 | 28 | echo "ERROR: This system does not appear to have been installed by MAAS" | 28 | echo "ERROR: This system does not appear to have been installed by MAAS" |
540 | 29 | echo "ERROR: " $(ls -l $MAAS_FILE 2>&1) | 29 | echo "ERROR: " "$(ls -l $MAAS_FILE 2>&1)" |
541 | 30 | exit 1 | 30 | exit 1 |
542 | 31 | fi | 31 | fi |
543 | 32 | 32 | ||
544 | 33 | #is the version appropriate | 33 | #is the version appropriate |
546 | 34 | exit `dpkg --compare-versions $maas_version "ge" $MIN_VERSION` | 34 | exit "$(dpkg --compare-versions "$maas_version" "ge" $MIN_VERSION)" |
547 | diff --git a/bin/network_configs.sh b/bin/network_configs.sh | |||
548 | index b2fcc99..4fd354b 100755 | |||
549 | --- a/bin/network_configs.sh | |||
550 | +++ b/bin/network_configs.sh | |||
551 | @@ -1,13 +1,13 @@ | |||
552 | 1 | #!/bin/bash | 1 | #!/bin/bash |
553 | 2 | 2 | ||
555 | 3 | if `grep -q "replaced by netplan" /etc/network/interfaces`; then | 3 | if grep -q "replaced by netplan" /etc/network/interfaces; then |
556 | 4 | # Get our configs from netplan | 4 | # Get our configs from netplan |
557 | 5 | for directory in "etc" "run" "lib"; do | 5 | for directory in "etc" "run" "lib"; do |
559 | 6 | for configfile in `find /$directory/netplan -type f -name *.yaml`; do | 6 | while IFS= read -r -d '' configfile; do |
560 | 7 | echo "Config File $configfile:" | 7 | echo "Config File $configfile:" |
562 | 8 | cat $configfile | 8 | cat "$configfile" |
563 | 9 | echo "" | 9 | echo "" |
565 | 10 | done | 10 | done < <(find /$directory/netplan -type f -name "*.yaml" -print0) |
566 | 11 | done | 11 | done |
567 | 12 | else | 12 | else |
568 | 13 | # get configs from Network Manager instead | 13 | # get configs from Network Manager instead |
569 | diff --git a/bin/network_printer_test.sh b/bin/network_printer_test.sh | |||
570 | index 19d98d2..2633b6c 100755 | |||
571 | --- a/bin/network_printer_test.sh | |||
572 | +++ b/bin/network_printer_test.sh | |||
573 | @@ -19,7 +19,7 @@ while [ $# -gt 0 ] | |||
574 | 19 | do | 19 | do |
575 | 20 | case "$1" in | 20 | case "$1" in |
576 | 21 | -p) | 21 | -p) |
578 | 22 | if echo ${2} | grep -q -c '^-'; then | 22 | if echo "${2}" | grep -q -c '^-'; then |
579 | 23 | usage | 23 | usage |
580 | 24 | exit 1 | 24 | exit 1 |
581 | 25 | fi | 25 | fi |
582 | @@ -27,7 +27,7 @@ do | |||
583 | 27 | shift | 27 | shift |
584 | 28 | ;; | 28 | ;; |
585 | 29 | -s) | 29 | -s) |
587 | 30 | if echo ${2} | grep -q -c '^-'; then | 30 | if echo "${2}" | grep -q -c '^-'; then |
588 | 31 | usage | 31 | usage |
589 | 32 | exit 1 | 32 | exit 1 |
590 | 33 | fi | 33 | fi |
591 | @@ -42,16 +42,16 @@ do | |||
592 | 42 | shift | 42 | shift |
593 | 43 | done | 43 | done |
594 | 44 | 44 | ||
596 | 45 | if [ -z $server ]; then | 45 | if [ -z "$server" ]; then |
597 | 46 | echo "Nothing to do with no server defined. (See $0 --usage)" | 46 | echo "Nothing to do with no server defined. (See $0 --usage)" |
598 | 47 | exit 0 | 47 | exit 0 |
599 | 48 | fi | 48 | fi |
600 | 49 | 49 | ||
601 | 50 | printer=${printer:-PDF} | 50 | printer=${printer:-PDF} |
602 | 51 | 51 | ||
606 | 52 | lpadmin -E -v ipp://${server}/printers/${printer} | 52 | lpadmin -E -v ipp://"${server}"/printers/"${printer}" |
607 | 53 | cupsenable ${printer} | 53 | cupsenable "${printer}" |
608 | 54 | cupsaccept ${printer} | 54 | cupsaccept "${printer}" |
609 | 55 | 55 | ||
611 | 56 | lsb_release -a | lp -t "lsb_release" -d ${printer} | 56 | lsb_release -a | lp -t "lsb_release" -d "${printer}" |
612 | 57 | 57 | ||
613 | diff --git a/bin/network_wait.sh b/bin/network_wait.sh | |||
614 | index f0637d0..16d474c 100755 | |||
615 | --- a/bin/network_wait.sh | |||
616 | +++ b/bin/network_wait.sh | |||
617 | @@ -2,8 +2,7 @@ | |||
618 | 2 | 2 | ||
619 | 3 | x=1 | 3 | x=1 |
620 | 4 | while true; do | 4 | while true; do |
623 | 5 | state=$(/usr/bin/nmcli -t -f STATE nm 2>/dev/null) | 5 | if ! state=$(/usr/bin/nmcli -t -f STATE nm 2>/dev/null); then |
622 | 6 | if [[ $? != 0 ]]; then | ||
624 | 7 | state=$(/usr/bin/nmcli -t -f STATE general 2>/dev/null) | 6 | state=$(/usr/bin/nmcli -t -f STATE general 2>/dev/null) |
625 | 8 | rc=$? | 7 | rc=$? |
626 | 9 | if [[ $rc != 0 ]]; then | 8 | if [[ $rc != 0 ]]; then |
627 | @@ -11,13 +10,13 @@ while true; do | |||
628 | 11 | fi | 10 | fi |
629 | 12 | fi | 11 | fi |
630 | 13 | if [ "$state" = "connected" ]; then | 12 | if [ "$state" = "connected" ]; then |
632 | 14 | echo $state | 13 | echo "$state" |
633 | 15 | exit 0 | 14 | exit 0 |
634 | 16 | fi | 15 | fi |
635 | 17 | 16 | ||
637 | 18 | x=$(($x + 1)) | 17 | x=$((x + 1)) |
638 | 19 | if [ $x -gt 12 ]; then | 18 | if [ $x -gt 12 ]; then |
640 | 20 | echo $state | 19 | echo "$state" |
641 | 21 | exit 1 | 20 | exit 1 |
642 | 22 | fi | 21 | fi |
643 | 23 | 22 | ||
644 | diff --git a/bin/optical_write_test.sh b/bin/optical_write_test.sh | |||
645 | index b127667..ca1dc79 100755 | |||
646 | --- a/bin/optical_write_test.sh | |||
647 | +++ b/bin/optical_write_test.sh | |||
648 | @@ -11,7 +11,7 @@ create_working_dirs(){ | |||
649 | 11 | # First, create the temp dir and cd there | 11 | # First, create the temp dir and cd there |
650 | 12 | echo "Creating Temp directory and moving there ..." | 12 | echo "Creating Temp directory and moving there ..." |
651 | 13 | mkdir -p $TEMP_DIR || return 1 | 13 | mkdir -p $TEMP_DIR || return 1 |
653 | 14 | cd $TEMP_DIR | 14 | cd $TEMP_DIR || return 1 |
654 | 15 | echo "Now working in $PWD ..." | 15 | echo "Now working in $PWD ..." |
655 | 16 | } | 16 | } |
656 | 17 | 17 | ||
657 | @@ -26,18 +26,18 @@ generate_md5(){ | |||
658 | 26 | # Generate the md5sum | 26 | # Generate the md5sum |
659 | 27 | echo "Generating md5sums of sample files ..." | 27 | echo "Generating md5sums of sample files ..." |
660 | 28 | CUR_DIR=$PWD | 28 | CUR_DIR=$PWD |
663 | 29 | cd $SAMPLE_FILE | 29 | cd $SAMPLE_FILE || return 1 |
664 | 30 | md5sum * > $TEMP_DIR/$MD5SUM_FILE | 30 | md5sum -- * > $TEMP_DIR/$MD5SUM_FILE |
665 | 31 | # Check the sums for paranoia sake | 31 | # Check the sums for paranoia sake |
666 | 32 | check_md5 $TEMP_DIR/$MD5SUM_FILE | 32 | check_md5 $TEMP_DIR/$MD5SUM_FILE |
667 | 33 | rt=$? | 33 | rt=$? |
669 | 34 | cd $CUR_DIR | 34 | cd "$CUR_DIR" || exit 1 |
670 | 35 | return $rt | 35 | return $rt |
671 | 36 | } | 36 | } |
672 | 37 | 37 | ||
673 | 38 | check_md5(){ | 38 | check_md5(){ |
674 | 39 | echo "Checking md5sums ..." | 39 | echo "Checking md5sums ..." |
676 | 40 | md5sum -c $1 | 40 | md5sum -c "$1" |
677 | 41 | return $? | 41 | return $? |
678 | 42 | } | 42 | } |
679 | 43 | 43 | ||
680 | @@ -55,10 +55,10 @@ burn_iso(){ | |||
681 | 55 | echo "Beginning image burn ..." | 55 | echo "Beginning image burn ..." |
682 | 56 | if [ "$OPTICAL_TYPE" == 'cd' ] | 56 | if [ "$OPTICAL_TYPE" == 'cd' ] |
683 | 57 | then | 57 | then |
685 | 58 | wodim -eject dev=$OPTICAL_DRIVE $ISO_NAME | 58 | wodim -eject dev="$OPTICAL_DRIVE" $ISO_NAME |
686 | 59 | elif [ "$OPTICAL_TYPE" == 'dvd' ] || [ "$OPTICAL_TYPE" == 'bd' ] | 59 | elif [ "$OPTICAL_TYPE" == 'dvd' ] || [ "$OPTICAL_TYPE" == 'bd' ] |
687 | 60 | then | 60 | then |
689 | 61 | growisofs -dvd-compat -Z $OPTICAL_DRIVE=$ISO_NAME | 61 | growisofs -dvd-compat -Z "$OPTICAL_DRIVE=$ISO_NAME" |
690 | 62 | else | 62 | else |
691 | 63 | echo "Invalid type specified '$OPTICAL_TYPE'" | 63 | echo "Invalid type specified '$OPTICAL_TYPE'" |
692 | 64 | exit 1 | 64 | exit 1 |
693 | @@ -76,9 +76,9 @@ check_disk(){ | |||
694 | 76 | echo "Waiting up to 5 minutes for drive to be mounted ..." | 76 | echo "Waiting up to 5 minutes for drive to be mounted ..." |
695 | 77 | while true; do | 77 | while true; do |
696 | 78 | sleep $INTERVAL | 78 | sleep $INTERVAL |
698 | 79 | SLEEP_COUNT=`expr $SLEEP_COUNT + $INTERVAL` | 79 | SLEEP_COUNT=$((SLEEP_COUNT + INTERVAL)) |
699 | 80 | 80 | ||
701 | 81 | mount $OPTICAL_DRIVE 2>&1 |egrep -q "already mounted" | 81 | mount "$OPTICAL_DRIVE" 2>&1 | grep -E -q "already mounted" |
702 | 82 | rt=$? | 82 | rt=$? |
703 | 83 | if [ $rt -eq 0 ]; then | 83 | if [ $rt -eq 0 ]; then |
704 | 84 | echo "Drive appears to be mounted now" | 84 | echo "Drive appears to be mounted now" |
705 | @@ -96,8 +96,8 @@ check_disk(){ | |||
706 | 96 | 96 | ||
707 | 97 | echo "Deleting original data files ..." | 97 | echo "Deleting original data files ..." |
708 | 98 | rm -rf $SAMPLE_FILE | 98 | rm -rf $SAMPLE_FILE |
711 | 99 | if [ -n "$(mount | grep $OPTICAL_DRIVE)" ]; then | 99 | if mount | grep -q "$OPTICAL_DRIVE"; then |
712 | 100 | MOUNT_PT=$(mount | grep $OPTICAL_DRIVE | awk '{print $3}') | 100 | MOUNT_PT=$(mount | grep "$OPTICAL_DRIVE" | awk '{print $3}') |
713 | 101 | echo "Disk is mounted to $MOUNT_PT" | 101 | echo "Disk is mounted to $MOUNT_PT" |
714 | 102 | else | 102 | else |
715 | 103 | echo "Attempting best effort to mount $OPTICAL_DRIVE on my own" | 103 | echo "Attempting best effort to mount $OPTICAL_DRIVE on my own" |
716 | @@ -105,7 +105,7 @@ check_disk(){ | |||
717 | 105 | echo "Creating temp mount point: $MOUNT_PT ..." | 105 | echo "Creating temp mount point: $MOUNT_PT ..." |
718 | 106 | mkdir $MOUNT_PT | 106 | mkdir $MOUNT_PT |
719 | 107 | echo "Mounting disk to mount point ..." | 107 | echo "Mounting disk to mount point ..." |
721 | 108 | mount $OPTICAL_DRIVE $MOUNT_PT | 108 | mount "$OPTICAL_DRIVE" $MOUNT_PT |
722 | 109 | rt=$? | 109 | rt=$? |
723 | 110 | if [ $rt -ne 0 ]; then | 110 | if [ $rt -ne 0 ]; then |
724 | 111 | echo "ERROR: Unable to re-mount $OPTICAL_DRIVE!" >&2 | 111 | echo "ERROR: Unable to re-mount $OPTICAL_DRIVE!" >&2 |
725 | @@ -120,24 +120,24 @@ check_disk(){ | |||
726 | 120 | 120 | ||
727 | 121 | cleanup(){ | 121 | cleanup(){ |
728 | 122 | echo "Moving back to original location" | 122 | echo "Moving back to original location" |
730 | 123 | cd $START_DIR | 123 | cd "$START_DIR" || exit 1 |
731 | 124 | echo "Now residing in $PWD" | 124 | echo "Now residing in $PWD" |
732 | 125 | echo "Cleaning up ..." | 125 | echo "Cleaning up ..." |
733 | 126 | umount "$MOUNT_PT" | 126 | umount "$MOUNT_PT" |
734 | 127 | rm -fr $TEMP_DIR | 127 | rm -fr $TEMP_DIR |
735 | 128 | echo "Ejecting spent media ..." | 128 | echo "Ejecting spent media ..." |
737 | 129 | eject $OPTICAL_DRIVE | 129 | eject "$OPTICAL_DRIVE" |
738 | 130 | } | 130 | } |
739 | 131 | 131 | ||
740 | 132 | failed(){ | 132 | failed(){ |
742 | 133 | echo $1 | 133 | echo "$1" |
743 | 134 | echo "Attempting to clean up ..." | 134 | echo "Attempting to clean up ..." |
744 | 135 | cleanup | 135 | cleanup |
745 | 136 | exit 1 | 136 | exit 1 |
746 | 137 | } | 137 | } |
747 | 138 | 138 | ||
750 | 139 | if [ -e $1 ]; then | 139 | if [ -e "$1" ]; then |
751 | 140 | OPTICAL_DRIVE=$(readlink -f $1) | 140 | OPTICAL_DRIVE=$(readlink -f "$1") |
752 | 141 | else | 141 | else |
753 | 142 | OPTICAL_DRIVE='/dev/sr0' | 142 | OPTICAL_DRIVE='/dev/sr0' |
754 | 143 | fi | 143 | fi |
755 | diff --git a/requirements/container-tests-provider-checkbox b/requirements/container-tests-provider-checkbox | |||
756 | index 7aca1bc..7f8a0ba 100755 | |||
757 | --- a/requirements/container-tests-provider-checkbox | |||
758 | +++ b/requirements/container-tests-provider-checkbox | |||
759 | @@ -17,6 +17,4 @@ git clone git://git.launchpad.net/plainbox-provider-resource $TMPDIR/plainbox-pr | |||
760 | 17 | python3 $TMPDIR/plainbox-provider-resource/manage.py develop --force | 17 | python3 $TMPDIR/plainbox-provider-resource/manage.py develop --force |
761 | 18 | 18 | ||
762 | 19 | ./manage.py validate | 19 | ./manage.py validate |
766 | 20 | ./manage.py test -u | 20 | ./manage.py test |
764 | 21 | ./manage.py test -f | ||
765 | 22 | ./manage.py test -i |