Skip to content

Commit

Permalink
POSIX-compliant version
Browse files Browse the repository at this point in the history
  • Loading branch information
Spearfoot authored Mar 21, 2017
1 parent 953ed09 commit cbdd6c9
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions set_hdd_erc.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/sh

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

Expand All @@ -21,26 +21,21 @@ writesetting=70
# 3. A smartctl-based function:
get_smart_drives()
{
local gs_smartdrives
local gs_drives
local gs_drive
local gs_smart_flag

gs_drives=$(/usr/local/sbin/smartctl --scan | grep "dev" | awk '{print $1}' | sed -e 's/\/dev\///')
gs_drives=$(/usr/local/sbin/smartctl --scan | grep "dev" | awk '{print $1}' | sed -e 's/\/dev\///' | tr '\n' ' ')

gs_smartdrives=""

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

eval "$1=\$gs_smartdrives"
}

declare drives
drives=""
get_smart_drives drives

# end of method 3.
Expand Down

0 comments on commit cbdd6c9

Please sign in to comment.