Skip to content

Commit cbdd6c9

Browse files
authored
POSIX-compliant version
1 parent 953ed09 commit cbdd6c9

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

set_hdd_erc.sh

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env bash
1+
#!/bin/sh
22

33
# https://www.smartmontools.org/wiki/FAQ#WhatiserrorrecoverycontrolERCandwhyitisimportanttoenableitfortheSATAdisksinRAID
44

@@ -21,26 +21,21 @@ writesetting=70
2121
# 3. A smartctl-based function:
2222
get_smart_drives()
2323
{
24-
local gs_smartdrives
25-
local gs_drives
26-
local gs_drive
27-
local gs_smart_flag
28-
29-
gs_drives=$(/usr/local/sbin/smartctl --scan | grep "dev" | awk '{print $1}' | sed -e 's/\/dev\///')
24+
gs_drives=$(/usr/local/sbin/smartctl --scan | grep "dev" | awk '{print $1}' | sed -e 's/\/dev\///' | tr '\n' ' ')
3025

3126
gs_smartdrives=""
3227

3328
for gs_drive in $gs_drives; do
3429
gs_smart_flag=$(/usr/local/sbin/smartctl -i /dev/"$gs_drive" | grep "SMART support is: Enabled" | awk '{print $4}')
35-
if [ "$gs_smart_flag" == "Enabled" ]; then
30+
if [ "$gs_smart_flag" = "Enabled" ]; then
3631
gs_smartdrives=$gs_smartdrives" "${gs_drive}
3732
fi
3833
done
3934

4035
eval "$1=\$gs_smartdrives"
4136
}
4237

43-
declare drives
38+
drives=""
4439
get_smart_drives drives
4540

4641
# end of method 3.

0 commit comments

Comments
 (0)