From 68d7f492d0e658aded1889ab130812750576d818 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sun, 21 Apr 2024 13:55:45 +0300 Subject: [PATCH 1/2] Fix to preserve service state https://github.com/webmin/webmin/issues/2133 [build] --- updateboot.pl | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/updateboot.pl b/updateboot.pl index fa3a0a1a..09e5a76e 100755 --- a/updateboot.pl +++ b/updateboot.pl @@ -34,10 +34,26 @@ $l =~ s/(WEBMIN_[A-Z]+)/$ENV{$1}/g; } &flush_file_lines($temp); + + my $status = &backquote_logged("systemctl is-enabled ". + quotemeta($product).".service 2>&1"); + $status = &trim($status); + copy_source_dest($temp, "$systemd_root/$product.service"); - system("systemctl daemon-reload >/dev/null 2>&1"); - system("systemctl enable $product >/dev/null 2>&1"); + + if ($status eq "disabled") { + system("systemctl disable ". + quotemeta($product).".service >/dev/null 2>&1"); + } + elsif ($status eq "masked") { + system("systemctl mask ". + quotemeta($product).".service >/dev/null 2>&1"); + } + else { + system("systemctl enable ". + quotemeta($product).".service >/dev/null 2>&1"); + } } elsif (-d "/etc/init.d") { copy_source_dest("usermin-init", "/etc/init.d/$product"); From c9e2f8cb3637ad6b0d8f89c5ae9e3758686d880c Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sun, 21 Apr 2024 15:02:33 +0300 Subject: [PATCH 2/2] Fix to wait for systemd to update ; fix getting status at right time [build] --- updateboot.pl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/updateboot.pl b/updateboot.pl index 09e5a76e..f18e753c 100755 --- a/updateboot.pl +++ b/updateboot.pl @@ -15,6 +15,10 @@ if (-d "/etc/systemd" && &has_command("systemctl") && &execute_command("systemctl list-units") == 0) { + # Save status of service + my $status = &backquote_logged("systemctl is-enabled ". + quotemeta($product).".service 2>&1"); + $status = &trim($status) if ($status); # Delete all possible service files my $systemd_root = &get_systemd_root(); foreach my $p ( @@ -35,12 +39,9 @@ } &flush_file_lines($temp); - my $status = &backquote_logged("systemctl is-enabled ". - quotemeta($product).".service 2>&1"); - $status = &trim($status); - copy_source_dest($temp, "$systemd_root/$product.service"); system("systemctl daemon-reload >/dev/null 2>&1"); + sleep(3); # Wait for systemd to update configuration if ($status eq "disabled") { system("systemctl disable ".