mirror of
https://github.com/webmin/webmin.git
synced 2025-07-21 23:40:34 +00:00
70 lines
2.1 KiB
Perl
Executable File
70 lines
2.1 KiB
Perl
Executable File
#!/usr/bin/perl
|
|
# updateboot.pl
|
|
# Called by setup.sh to update boot script
|
|
|
|
$no_acl_check++;
|
|
require './init-lib.pl';
|
|
$product = $ARGV[0];
|
|
|
|
$< == 0 || die "updateboot.pl must be run as root";
|
|
|
|
# Update boot script
|
|
if ($product) {
|
|
if ($init_mode eq "systemd") {
|
|
# Save status of service
|
|
my $status = &backquote_logged("systemctl is-enabled ".
|
|
quotemeta($product)." 2>&1");
|
|
$status = &trim($status) if ($status);
|
|
print "Current Status is $status\n";
|
|
my $status2 = &backquote_logged("systemctl is-enabled ".
|
|
quotemeta($product).".xxxx 2>&1");
|
|
print "Current Status2 is $status2\n";
|
|
# Delete all possible service files
|
|
my $systemd_root = &get_systemd_root();
|
|
foreach my $p (
|
|
"/etc/systemd/system",
|
|
"/usr/lib/systemd/system",
|
|
"/lib/systemd/system") {
|
|
unlink("$p/$product.service");
|
|
unlink("$p/$product");
|
|
}
|
|
my $temp = &transname();
|
|
my $killcmd = &has_command('kill');
|
|
$ENV{'WEBMIN_KILLCMD'} = $killcmd;
|
|
©_source_dest("$root_directory/webmin-systemd", "$temp");
|
|
my $lref = &read_file_lines($temp);
|
|
foreach my $l (@{$lref}) {
|
|
$l =~ s/(WEBMIN_[A-Z]+)/$ENV{$1}/g;
|
|
}
|
|
&flush_file_lines($temp);
|
|
|
|
copy_source_dest($temp, "$systemd_root/$product.service");
|
|
system("systemctl daemon-reload");
|
|
print "pre-test ....\n";
|
|
system("systemctl daemon-reloads");
|
|
print "pre-sleep ....\n";
|
|
sleep(3); # Wait for systemd to update configuration
|
|
print "psot-sleep ....\n";
|
|
|
|
if ($status eq "disabled") {
|
|
system("systemctl disable ".quotemeta($product));
|
|
print "Disabled $product\n";
|
|
print "Disabled run ". "systemctl disable ". quotemeta($product);
|
|
}
|
|
elsif ($status eq "masked") {
|
|
system("systemctl mask ".quotemeta($product));
|
|
print "Masked $product\n";
|
|
print "Masked run ". "systemctl mask ". quotemeta($product);
|
|
}
|
|
else {
|
|
system("systemctl enable ".quotemeta($product));
|
|
print "Enabled $product\n";
|
|
print "Enabled run ". "systemctl enable ". quotemeta($product);
|
|
}
|
|
}
|
|
elsif (-d "/etc/init.d") {
|
|
copy_source_dest("$root_directory/webmin-init", "/etc/init.d/$product");
|
|
system("chkconfig --add $product >/dev/null 2>&1");
|
|
}
|
|
}
|