From 6be3e8fabf37fde739ab3c5c6bd78f7510e7c417 Mon Sep 17 00:00:00 2001 From: shuki Date: Thu, 5 Mar 2026 18:06:54 +0200 Subject: [PATCH] Show System Backup type in logs page Add [TYPE:SYSBACKUP] marker to sysbackup log output. The logs page detects this in the first 5 lines and displays "System" badge instead of "Backup". Co-Authored-By: Claude Opus 4.6 --- bin/gniza | 1 + whm/gniza-whm/logs.cgi | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/bin/gniza b/bin/gniza index 5a88aad..b5564c2 100755 --- a/bin/gniza +++ b/bin/gniza @@ -1373,6 +1373,7 @@ cmd_sysbackup() { load_config "$config_file" validate_config || die "Invalid configuration" init_logging + log_info "[TYPE:SYSBACKUP] System backup started" local dry_run=false has_flag dry-run "$@" && dry_run=true diff --git a/whm/gniza-whm/logs.cgi b/whm/gniza-whm/logs.cgi index 7aa7b94..0fa0c54 100755 --- a/whm/gniza-whm/logs.cgi +++ b/whm/gniza-whm/logs.cgi @@ -61,7 +61,7 @@ sub show_list { name => $entry, size => $stat[7] // 0, mtime => $stat[9] // 0, - type => ($entry =~ /^cron-/) ? 'Cron' : 'Backup', + type => ($entry =~ /^cron-/) ? 'Cron' : _detect_log_type($path), status => $status, }; } @@ -96,7 +96,9 @@ sub show_list { for my $f (@page_files) { my $esc_name = GnizaWHM::UI::esc($f->{name}); - my $badge = $f->{type} eq 'Cron' ? 'badge-neutral' : 'badge-info'; + my $badge = $f->{type} eq 'Cron' ? 'badge-neutral' + : $f->{type} eq 'System' ? 'badge-warning' + : 'badge-info'; my $date = _format_time($f->{mtime}); my $size = _human_size($f->{size}); my $href = 'logs.cgi?file=' . _uri_escape($f->{name}); @@ -321,6 +323,21 @@ sub _valid_log_filename { return 0; } +sub _detect_log_type { + my ($path) = @_; + if (open my $fh, '<', $path) { + while (my $line = <$fh>) { + if ($line =~ /\[TYPE:SYSBACKUP\]/) { + close $fh; + return 'System'; + } + last if $. > 5; + } + close $fh; + } + return 'Backup'; +} + sub _detect_log_status { my ($path) = @_; return 'Success' unless -f $path;