[LON-CAPA-cvs] cvs: doc /install/linux install.pl
raeburn
raeburn at source.lon-capa.org
Tue Nov 26 17:08:36 EST 2024
raeburn Tue Nov 26 22:08:36 2024 EDT
Modified files:
/doc/install/linux install.pl
Log:
- Support Fedora 40 and 41.
If /etc/systemd/httpd.service.d//override.conf already exists, change
what needs to be changed and preserve the rest.
Index: doc/install/linux/install.pl
diff -u doc/install/linux/install.pl:1.95 doc/install/linux/install.pl:1.96
--- doc/install/linux/install.pl:1.95 Mon Aug 5 13:36:59 2024
+++ doc/install/linux/install.pl Tue Nov 26 22:08:36 2024
@@ -78,7 +78,7 @@
&mt('Stopping execution.')."\n";
exit;
} else {
- print LOG '$Id: install.pl,v 1.95 2024/08/05 13:36:59 raeburn Exp $'."\n";
+ print LOG '$Id: install.pl,v 1.96 2024/11/26 22:08:36 raeburn Exp $'."\n";
}
#
@@ -2979,46 +2979,87 @@
if (-d '/etc/systemd/system/'.$service.'.d') {
if (-e '/etc/systemd/system/'.$service.'.d/override.conf') {
if (open(my $fh,'<','/etc/systemd/system/'.$service.'.d/override.conf')) {
- my ($inservice,$addservice,$protectoff,$linenum,$change, at lines);
+ my ($category,$addservice,$protectoff,$linenum,$change,
+ %lines, at move, at nocat, at ordered);
+ $linenum = 0;
while (my $entry = <$fh>) {
$linenum ++;
chomp($entry);
- if ($entry eq '[Service]') {
- if (!$protectoff) {
- $inservice = $linenum;
- push(@lines,$entry);
+ if ($entry =~ /^\s*\[([^\]]+)\]\s*$/) {
+ $category = $1;
+ if ($category =~ /^Service$/i) {
+ push(@ordered,'Service');
} else {
- $addservice = 1;
- next;
+ push(@ordered,$category);
}
- }
- if ($entry =~ /^ProtectHome\s*=\s*([\w-]+)\s*$/) {
+ } elsif ($entry =~ /^ProtectHome\s*=\s*([\w-]+)\s*$/) {
my $value = $1;
- if ($protectoff) {
- next;
- if (lc($value) eq 'no') {
- $protectoff = $linenum;
- push(@lines,$entry);
+ next if ($protectoff);
+ if (lc($value) eq 'no') {
+ if ($category =~ /^Service$/i) {
+ push(@{$lines{'Service'}},$entry);
} else {
- if ($protectoff) {
- next;
- } else {
- push(@lines,'ProtectHome=no');
- $protectoff = $linenum;
- $change = $linenum;
- }
+ push(@move,$entry);
+ $change = $linenum;
+ }
+ } else {
+ if ($category =~ /^Service$/i) {
+ push(@{$lines{'Service'}},'ProtectHome=no');
+ } else {
+ push(@move,'ProtectHome=no');
}
+ $change = $linenum;
+ }
+ $protectoff = $linenum;
+ } else {
+ next if ($entry =~ /^\s*$/);
+ if ($category =~ /^Service$/i) {
+ push(@{$lines{'Service'}},$entry);
+ } elsif ($category ne '') {
+ push(@{$lines{$category}},$entry);
+ } else {
+ push(@nocat,$entry);
}
}
}
close($fh);
+ unless (grep(/^Service$/, at ordered)) {
+ $addservice = 1;
+ unshift(@ordered,'Service');
+ }
+ if (!$protectoff) {
+ push(@{$lines{'Service'}},'ProtectHome=no');
+ }
if ($addservice || $change || !$protectoff) {
if (open(my $fh,'>','/etc/systemd/system/'.$service.'.d/override.conf')) {
- if ($addservice) {
- print $fh "[Service]\n";
+ if (@ordered) {
+ foreach my $category (@ordered) {
+ print $fh "[$category]\n";
+ if (ref($lines{$category}) eq 'ARRAY') {
+ foreach my $item (@{$lines{$category}}) {
+ print $fh "$item\n";
+ }
+ }
+ if ($category eq 'Service') {
+ if (@move) {
+ foreach my $item (@move) {
+ if ($item =~ /^ProtectHome\s*=\s*no\s*$/i) {
+ unless (grep/^ProtectHome\s*=\s*no\s*$/i,@{$lines{$category}}) {
+ print $fh "$item\n";
+ }
+ } else {
+ print $fh "$item\n";
+ }
+ }
+ }
+ }
+ print $fh "\n";
+ }
}
- foreach my $entry (@lines) {
- print $fh "$entry\n";
+ if (@nocat) {
+ foreach my $item (@nocat) {
+ print $fh "$item\n";
+ }
}
close($fh);
print_and_log('Updated /etc/systemd/system/'.$service.'.d/override.conf');
More information about the LON-CAPA-cvs
mailing list