marsadm: activate systemd unit only when device present

This commit is contained in:
Thomas Schoebel-Theuer 2019-02-03 18:19:16 +01:00 committed by Thomas Schoebel-Theuer
parent 51e12bf9d4
commit 0756bdc9b8

View File

@ -449,6 +449,11 @@ sub systemd_activate {
lprint "Overriding unit activate=$do_activate with $override\n" if $verbose;
$do_activate = $override;
}
my $dev = "/dev/mars/$res";
if ($do_activate && ! -b $dev) {
lprint "Device $dev not present, cannot activate systemd unit\n" if $verbose;
$do_activate = 0;
}
my $oper = $do_activate ? "start" : "stop";
my $unit_path = "$mars/resource-$res/systemd-$oper-unit";
my $unit = get_link($unit_path, 2);