Skip to content

Commit

Permalink
Add support for parsing .service.d/*.conf files.
Browse files Browse the repository at this point in the history
  • Loading branch information
adelton committed Dec 4, 2015
1 parent e50fd48 commit 4e75569
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion systemctl
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,19 @@ sub parse_file {
$op = 'Unit.Requires';
} elsif ($file =~ /\.wants$/) {
$op = 'Unit.Wants';
} elsif ($file =~ /\.service\.d$/) {
$op = '';
} else {
die "Unknown directory [$file].\n";
}
my $dh = new IO::Dir($file);
while (defined(my $de = $dh->read)) {
next if $de eq '.' or $de eq '..';
push @{$data->{$op}}, $de unless $de =~ /\.target$/;
if ($op eq '') {
parse_file("$file/$de", $data) if $de =~ /\.conf$/;
} else {
push @{$data->{$op}}, $de unless $de =~ /\.target$/;
}
}
$dh->close;
return;
Expand Down Expand Up @@ -219,6 +225,9 @@ sub parse_file {
}
}
$fh->close;
if ($file =~ /\.service$/ and -d "$file.d") {
parse_file("$file.d", $data);
}
if (defined $data->{'Service.ExecStart'} and not defined $data->{'Service.PIDFile'}) {
my ($pidfile) = grep /^\/.+\.pid$/, split /\s+/, $data->{'Service.ExecStart'};
if (defined $pidfile) {
Expand Down

0 comments on commit 4e75569

Please sign in to comment.