From 6899a71935ddc84930e2236fe220dea7669e16a9 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Sun, 6 Oct 2024 06:07:43 -0700 Subject: [PATCH] Add email notifications to admin for low disk space and nearing low disk space (which will pause spooling). --- Rocksolid_Light/rocksolid/config.inc.php | 1 + Rocksolid_Light/rslight/scripts/cron.php | 72 +++++++++++++++++-- Rocksolid_Light/rslight/scripts/spoolnews.php | 6 ++ 3 files changed, 73 insertions(+), 6 deletions(-) diff --git a/Rocksolid_Light/rocksolid/config.inc.php b/Rocksolid_Light/rocksolid/config.inc.php index 929f01f..e409c14 100644 --- a/Rocksolid_Light/rocksolid/config.inc.php +++ b/Rocksolid_Light/rocksolid/config.inc.php @@ -69,6 +69,7 @@ $logdir = $spooldir . '/log'; $debug_log = $logdir . '/debug.log'; $abuse_log = $logdir . '/abuse.log'; $auth_log = $logdir . '/auth.log'; +$mail_log = $logdir . '/mail.log'; $lockdir = $spooldir . '/lock'; $ssldir = $spooldir . '/ssl/'; $user_ban_file = $config_dir . '/banned_names.conf'; diff --git a/Rocksolid_Light/rslight/scripts/cron.php b/Rocksolid_Light/rslight/scripts/cron.php index 7e5c280..89008ef 100644 --- a/Rocksolid_Light/rslight/scripts/cron.php +++ b/Rocksolid_Light/rslight/scripts/cron.php @@ -56,9 +56,9 @@ if (isset($CONFIG['enable_nntp']) && $CONFIG['enable_nntp'] == true) { // Create paths in $config_dir/scripts path file $config_path_file = $config_dir . '/scripts/paths.inc.php'; -if(!file_exists($config_path_file)) { - file_put_contents($config_path_file, ' 86400) { $log_files = scandir($logdir); foreach ($log_files as $logfile) { - if (substr($logfile, - 4) != '.log') { + if (substr($logfile, -4) != '.log') { continue; } $logfile = $logdir . '/' . $logfile; @@ -274,4 +335,3 @@ function rotate_keys() file_put_contents($keyfile, serialize($newkeys)); touch($keyfile); } -?> diff --git a/Rocksolid_Light/rslight/scripts/spoolnews.php b/Rocksolid_Light/rslight/scripts/spoolnews.php index 0ec96cb..71499b7 100644 --- a/Rocksolid_Light/rslight/scripts/spoolnews.php +++ b/Rocksolid_Light/rslight/scripts/spoolnews.php @@ -67,6 +67,12 @@ $path = $workpath . "articles/"; if ($low_spool_disk_space) { print "Low Disk Space (less than " . $min_spool_disk_space . " available)\n"; file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Low Disk Space (less than " . $min_spool_disk_space . "Gb available for spool). Pausing spoolnews", FILE_APPEND); + + $subject = "LOW DISK SPACE ON " . $CONFIG['server_path']; + $body = "LOW DISK SPACE ON " . $CONFIG['server_path'] . "\n"; + $body .= "Space has fallen below " . $min_spool_disk_space . "GB\n"; + $body .= "Space remaining: " . round($free_spool_disk_space) . "GB\n"; + exit(); }