From 2f6d5123a5c5925145b485d65bc311b6ac8d31bc Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Sun, 7 Sep 2025 13:03:17 +0200 Subject: [PATCH] Fix disk health check system --- modules/disk-health.nix | 5 +++++ scripts/daily-smart-report.sh | 4 +--- scripts/disk-health-smartd-alert.sh | 4 +--- scripts/gotify-notify.sh | 2 -- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/disk-health.nix b/modules/disk-health.nix index 68da26b..5c56215 100644 --- a/modules/disk-health.nix +++ b/modules/disk-health.nix @@ -62,6 +62,11 @@ StandardError = "journal"; # Add timeout to prevent hanging TimeoutStartSec = "300"; # 5 minutes max + # Set PATH to include system binaries for smartctl and curl + Environment = "PATH=/run/current-system/sw/bin"; + # Allow access to block devices for SMART commands + DeviceAllow = [ "/dev/disk/by-id/* rw" "/dev/sd* rw" "/dev/nvme* rw" "char-* rw" "block-* rw" ]; + DevicePolicy = "closed"; }; }; }; diff --git a/scripts/daily-smart-report.sh b/scripts/daily-smart-report.sh index f3c955f..15094f7 100755 --- a/scripts/daily-smart-report.sh +++ b/scripts/daily-smart-report.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - # Simple daily SMART report script - plain text version # Only checks SMART attributes and sends report via Gotify @@ -110,4 +108,4 @@ main() { echo "Daily SMART report completed" } -main "$@" \ No newline at end of file +main "$@" diff --git a/scripts/disk-health-smartd-alert.sh b/scripts/disk-health-smartd-alert.sh index 78f8b3d..27fe8cd 100755 --- a/scripts/disk-health-smartd-alert.sh +++ b/scripts/disk-health-smartd-alert.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - # SMART daemon alert script for Gotify notifications # Called by smartd when SMART issues are detected # No arguments needed - uses SMARTD_DEVICE environment variable @@ -93,4 +91,4 @@ touch "$LOG_FILE" 2>/dev/null || { } # Main execution -send_smartd_alert \ No newline at end of file +send_smartd_alert diff --git a/scripts/gotify-notify.sh b/scripts/gotify-notify.sh index 2e1d9dd..2f08735 100755 --- a/scripts/gotify-notify.sh +++ b/scripts/gotify-notify.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - # Gotify notification script for disk health monitoring # Usage: gotify-notify.sh <message>