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");