ci: add shellcheck lint workflow; fix 6 violations
Lint / Shell (shellcheck) (push) Successful in 14s
Lint / Shell (shellcheck) (push) Successful in 14s
Removes unused drive_width variable (SC2034). Splits local+assign
for emmc_size, host, drive (SC2155). Uses ${var#...} instead of sed
for PCI desc parsing (SC2001). Pipes smartctl through sudo tee to fix
redirect privilege (SC2024).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+8
-8
@@ -410,9 +410,6 @@ generate_10bay_layout() {
|
||||
local hostname="$1"
|
||||
build_drive_map
|
||||
|
||||
# Fixed width for consistent box drawing (fits device names like "nvme0n1")
|
||||
local drive_width=10
|
||||
|
||||
# Box interior width = 136 (determined by 10 bay boxes: 4 + 10*13 + 2)
|
||||
# Total box width = 138 (136 interior + 2 for │ borders)
|
||||
|
||||
@@ -493,7 +490,8 @@ generate_micro_layout() {
|
||||
|
||||
# Show eMMC if present
|
||||
if [[ -n "$emmc_device" ]]; then
|
||||
local emmc_size=$(lsblk -d -n -o SIZE "/dev/$emmc_device" 2>/dev/null | xargs)
|
||||
local emmc_size
|
||||
emmc_size=$(lsblk -d -n -o SIZE "/dev/$emmc_device" 2>/dev/null | xargs)
|
||||
printf "│ ┌─────────────────────────────────────────────────────┐ │\n"
|
||||
printf "│ │ Onboard eMMC: %-10s (%s) │ │\n" "$emmc_device" "$emmc_size"
|
||||
printf "│ └─────────────────────────────────────────────────────┘ │\n"
|
||||
@@ -689,7 +687,7 @@ get_storage_controllers() {
|
||||
[[ -z "$line" ]] && continue
|
||||
pci_addr="$(echo "$line" | awk '{print $1}')"
|
||||
# Get short description (strip PCI address)
|
||||
desc="$(echo "$line" | sed 's/^[0-9a-f:.]\+ //')"
|
||||
desc="${line#*[0-9a-f:.] }"
|
||||
echo " $pci_addr: $desc"
|
||||
done
|
||||
}
|
||||
@@ -709,7 +707,8 @@ get_storage_controllers() {
|
||||
# Values: PCI path strings (for --show-pci option)
|
||||
#------------------------------------------------------------------------------
|
||||
build_drive_map() {
|
||||
local host="$(hostname | tr -cd '[:alnum:]-_.')"
|
||||
local host
|
||||
host="$(hostname | tr -cd '[:alnum:]-_.')"
|
||||
local mapping="${SERVER_MAPPINGS[$host]}"
|
||||
|
||||
# Declare global arrays directly
|
||||
@@ -728,7 +727,8 @@ build_drive_map() {
|
||||
|
||||
BAY_TO_PCI_PATH[$slot]="$path"
|
||||
if [[ -L "${DISK_BY_PATH}/$path" ]]; then
|
||||
local drive="$(readlink -f "${DISK_BY_PATH}/$path" | sed 's/.*\///')"
|
||||
local drive
|
||||
drive="$(readlink -f "${DISK_BY_PATH}/$path" | sed 's/.*\///')"
|
||||
DRIVE_MAP[$slot]="$drive"
|
||||
((mapped_count++))
|
||||
else
|
||||
@@ -1090,7 +1090,7 @@ if [[ "$SKIP_SMART" != true ]]; then
|
||||
device="${DRIVE_MAP[$bay]}"
|
||||
if [[ -n "$device" && "$device" != "EMPTY" && -b "/dev/$device" ]]; then
|
||||
# Launch background job to collect raw smartctl data
|
||||
(sudo smartctl -A -i -H "/dev/$device" > "$SMART_CACHE_DIR/${device}.raw" 2>/dev/null) &
|
||||
(sudo smartctl -A -i -H "/dev/$device" 2>/dev/null | sudo tee "$SMART_CACHE_DIR/${device}.raw" > /dev/null) &
|
||||
((job_count++))
|
||||
if ((job_count >= max_parallel_jobs)); then
|
||||
wait -n 2>/dev/null || wait # wait -n requires bash 4.3+, fall back to wait
|
||||
|
||||
Reference in New Issue
Block a user