From 6fb9c9b9063698824c9b1d0dec1a87a087b8db16 Mon Sep 17 00:00:00 2001 From: nachoparker Date: Mon, 14 Jan 2019 19:06:59 -0700 Subject: nc-hdd-test: try to detect device type if auto doesnt work --- bin/ncp/SYSTEM/nc-hdd-monitor.sh | 9 ++++++++- bin/ncp/SYSTEM/nc-hdd-test.sh | 17 ++++++++++++----- changelog.md | 6 ++++-- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/bin/ncp/SYSTEM/nc-hdd-monitor.sh b/bin/ncp/SYSTEM/nc-hdd-monitor.sh index 562074a4..e88efa3b 100644 --- a/bin/ncp/SYSTEM/nc-hdd-monitor.sh +++ b/bin/ncp/SYSTEM/nc-hdd-monitor.sh @@ -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" diff --git a/bin/ncp/SYSTEM/nc-hdd-test.sh b/bin/ncp/SYSTEM/nc-hdd-test.sh index b9d8330f..ced4a597 100644 --- a/bin/ncp/SYSTEM/nc-hdd-test.sh +++ b/bin/ncp/SYSTEM/nc-hdd-test.sh @@ -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 } diff --git a/changelog.md b/changelog.md index af5fa352..ba00783c 100644 --- a/changelog.md +++ b/changelog.md @@ -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 -- cgit v1.2.3