Skip to content

Commit

Permalink
nc-hdd-test: try to detect device type if auto doesnt work
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Jan 15, 2019
1 parent 9b1ecbb commit 6fb9c9b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
9 changes: 8 additions & 1 deletion bin/ncp/SYSTEM/nc-hdd-monitor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ sudo -u www-data php /var/www/nextcloud/occ notification:generate \
EOF
chmod +x /usr/local/etc/ncp-hdd-notif.sh

for dr in "${DRIVES[@]}"; do smartctl --smart=on /dev/${dr} | sed 1,2d; done
for dr in "${DRIVES[@]}"; do
local type=""
smartctl -d test /dev/${dr} &>/dev/null || {
smartctl -d sat -i /dev/${dr} &>/dev/null && type="-d sat"
}
smartctl $type --smart=on /dev/${dr} | sed 1,2d;
done

update-rc.d smartd enable
service smartd start
echo "HDD monitor enabled"
Expand Down
17 changes: 12 additions & 5 deletions bin/ncp/SYSTEM/nc-hdd-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,25 @@ configure()
}

for dr in "${DRIVES[@]}"; do

local type=""
smartctl -d test /dev/${dr} &>/dev/null || {
smartctl -d sat -i /dev/${dr} &>/dev/null || { echo "couldnt detect device type"; return 1; }
type="-d sat"
}

smartctl --smart=on /dev/${dr} | sed 1,2d
if [[ "$SHORTTEST" == yes ]]; then
echo "* Starting test on $dr. Check results later"
smartctl -X "/dev/$dr" &>/dev/null
smartctl -t short "/dev/$dr" | sed 1,2d
smartctl $type -X "/dev/$dr" &>/dev/null
smartctl $type -t short "/dev/$dr" | sed 1,2d
elif [[ "$LONGTEST" == yes ]]; then
echo "* Starting test on $dr. Check results later"
smartctl -X "/dev/$dr" &>/dev/null
smartctl -t long "/dev/$dr" | sed 1,2d
smartctl $type -X "/dev/$dr" &>/dev/null
smartctl $type -t long "/dev/$dr" | sed 1,2d
else
echo "* Stats for $dr"
smartctl -a "/dev/$dr" | sed 1,2d
smartctl $type -a "/dev/$dr" | sed 1,2d
fi
done
}
Expand Down
6 changes: 4 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

[v1.3.4](https://github.com/nextcloud/nextcloudpi/commit/63e0561) (2019-01-14) nc-info: fix automount reporting
[v1.3.5](https://github.com/nextcloud/nextcloudpi/commit/7697a4d) (2019-01-14) nc-hdd-test: try to detect device type if auto doesnt work

[v1.3.3](https://github.com/nextcloud/nextcloudpi/commit/389ed0c) (2019-01-14) nc-ramlog: adapt to armbian
[v1.3.4](https://github.com/nextcloud/nextcloudpi/commit/9b1ecbb) (2019-01-14) nc-info: fix automount reporting

[v1.3.3 ](https://github.com/nextcloud/nextcloudpi/commit/389ed0c) (2019-01-14) nc-ramlog: adapt to armbian

[v1.3.2 ](https://github.com/nextcloud/nextcloudpi/commit/be9a546) (2019-01-14) nc-automount: fix description

Expand Down

0 comments on commit 6fb9c9b

Please sign in to comment.