[PATCH] Add support for systemd >= 214 to update-rc.d
Jon Severinsson
jon at severinsson.net
Sat Jul 5 00:03:55 BST 2014
---
debian/changelog | 6 ++++++
debian/src/sysv-rc/sbin/update-rc.d | 17 +++++++++--------
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index f3ab9e72..de54364d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+sysvinit (2.88dsf-55.3) experimental; urgency=medium
+
+ * Add support for systemd >= 214 to update-rc.d
+
+ -- Jon Severinsson <jon at severinsson.net> Fri, 04 Jun 2014 22:00:00 +0200
+
sysvinit (2.88dsf-55.2) experimental; urgency=medium
* Fix a formatting error in mountnfs which turned a tab character into
diff --git a/debian/src/sysv-rc/sbin/update-rc.d b/debian/src/sysv-rc/sbin/update-rc.d
index fdd1485b..1301d2e7 100755
--- a/debian/src/sysv-rc/sbin/update-rc.d
+++ b/debian/src/sysv-rc/sbin/update-rc.d
@@ -68,31 +68,32 @@ sub make_path {
sub make_systemd_links {
my ($scriptname, $action) = @_;
+ my $unit = "$scriptname";
+ $unit =~ s/(\.sh)?$/.service/;
+
# In addition to the insserv call we also enable/disable the service
# for systemd by creating the appropriate symlink in case there is a
# native systemd service. We need to do this on our own instead of
# using systemctl because systemd might not even be installed yet.
my $service_path;
- if (-f "/etc/systemd/system/$scriptname.service") {
- $service_path = "/etc/systemd/system/$scriptname.service";
- } elsif (-f "/lib/systemd/system/$scriptname.service") {
- $service_path = "/lib/systemd/system/$scriptname.service";
+ if (-f "/etc/systemd/system/$unit") {
+ $service_path = "/etc/systemd/system/$unit";
+ } elsif (-f "/lib/systemd/system/$unit") {
+ $service_path = "/lib/systemd/system/$unit";
}
if (defined($service_path)) {
- my $changed_sth;
open my $fh, '<', $service_path or error("unable to read $service_path");
while (<$fh>) {
chomp;
if (/^\s*WantedBy=(.+)$/i) {
my $wants_dir = "/etc/systemd/system/$1.wants";
- my $service_link = "$wants_dir/$scriptname.service";
+ my $service_link = "$wants_dir/$unit";
if ("enable" eq $action) {
make_path($wants_dir);
symlink($service_path, $service_link);
} else {
unlink($service_link) if -e $service_link;
}
- $changed_sth = 1;
}
}
close($fh);
@@ -100,7 +101,7 @@ sub make_systemd_links {
# If we changed anything and this machine is running systemd, tell
# systemd to reload so that it will immediately pick up our
# changes.
- if ($changed_sth && -d "/run/systemd/system") {
+ if (-d "/run/systemd/system") {
system("systemctl", "daemon-reload");
}
}
--
2.0.0
More information about the Pkg-systemd-maintainers
mailing list