From 68d7f492d0e658aded1889ab130812750576d818 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sun, 21 Apr 2024 13:55:45 +0300 Subject: [PATCH] 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");