Skip to content

Commit

Permalink
reload-units: fix starting units
Browse files Browse the repository at this point in the history
  • Loading branch information
mkg20001 committed Mar 18, 2024
1 parent e3ce404 commit 8a71469
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions unify/src-script/reload-units.pl
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,28 @@ sub filter_units {
}
}
}

# Hacky extra start for unify units.
# The "reload but start" code is not working as we are not managing the targets
# The fix for this is to collect inactive units again afterwards
# and then start all that have a unify fragment path
my $inunits = busctl_call_systemd1_mgr("ListUnitsByPatterns", "asas", 0, 0)->{data}->[0];
for my $item (@{$inunits}) {
my ($unit, $description, $load_state, $active_state, $sub_state,
$following, $unit_path, $job_id, $job_type, $job_path) = @{$item};
if (!unit_is_active($unit)) {
# Figure out if we need to start the unit
if (!is_unify_unit($unit)) {
next;
}
my %unit_info = parse_unit("$newunits/$unit", "$newunits/$unit");
if (!(parse_systemd_bool(\%unit_info, "Unit", "RefuseManualStart", 0) || parse_systemd_bool(\%unit_info, "Unit", "X-OnlyManualStart", 0))) {
$units_to_start{$unit} = 1;
record_unit($start_list_file, $unit);
}
}
}

# Reload units that need it. This includes remounting changed mount
# units.
if (scalar(keys(%units_to_reload)) > 0) {
Expand All @@ -869,6 +891,8 @@ sub filter_units {
my @units_to_start_filtered = filter_units(\%units_to_start);
if (scalar(@units_to_start_filtered)) {
print STDERR "starting the following units: ", join(", ", @units_to_start_filtered), "\n";
}
if (scalar(keys(%units_to_start))) {
system("systemctl", "start", "--", sort(keys(%units_to_start))) == 0 or $res = 4;
unlink($start_list_file);
}
Expand Down

0 comments on commit 8a71469

Please sign in to comment.