From 3cd1cd55e8c372a7e711000575bfca62fca711de Mon Sep 17 00:00:00 2001 From: nachoparker Date: Sun, 4 Nov 2018 17:40:25 -0700 Subject: add nc-hdd-monitor --- changelog.md | 4 +- etc/ncp-config.d/nc-hdd-monitor.sh | 88 ++++++++++++++++++++++++++++++++++++++ update.sh | 1 + 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 etc/ncp-config.d/nc-hdd-monitor.sh diff --git a/changelog.md b/changelog.md index be25162c..eb87eb91 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,7 @@ -[v0.65.0](https://github.com/nextcloud/nextcloudpi/commit/2f56f2c) (2018-11-03) add nc-test-hdd +[v0.66.0](https://github.com/nextcloud/nextcloudpi/commit/989bc39) (2018-11-04) add nc-hdd-monitor + +[v0.65.0](https://github.com/nextcloud/nextcloudpi/commit/ab65f41) (2018-11-03) add nc-test-hdd [v0.64.12](https://github.com/nextcloud/nextcloudpi/commit/5e7f3da) (2018-11-03) docker: fix provisioning on a stopped the container diff --git a/etc/ncp-config.d/nc-hdd-monitor.sh b/etc/ncp-config.d/nc-hdd-monitor.sh new file mode 100644 index 00000000..d6f2e60a --- /dev/null +++ b/etc/ncp-config.d/nc-hdd-monitor.sh @@ -0,0 +1,88 @@ +#!/bin/bash + +# Monitor HDD health automatically +# +# Copyleft 2018 by Ignacio Nunez Hernanz +# GPL licensed (see end of file) * Use at your own risk! +# +# More at https://ownyourbits.com +# + +ACTIVE_=no +NOTIFYUSER_=ncp +EMAIL_=optional@email.com + +DESCRIPTION="Monitor HDD health automatically" + +is_active() +{ + systemctl -q is-enabled smartd &>/dev/null +} + +configure() +{ + local DRIVES=($(lsblk -ln | grep "^sd[[:alpha:]].*disk" | awk '{ print $1 }')) + + [[ ${#DRIVES[@]} == 0 ]] && { + echo "no drives detected. Disabling.." + ACTIVE_=no + } + + [[ "$ACTIVE_" != yes ]] && { + systemctl disable smartd + systemctl stop smartd + echo "HDD monitor disabled" + return 0 + } + + cat > /etc/smartd.conf < /usr/local/etc/ncp-hdd-notif.sh <> /usr/local/etc/ncp-hdd-notif.sh <> /usr/local/etc/ncp-hdd-notif.sh <