summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@debian.org>2013-07-23 23:51:22 +0200
committerMichael Stapelberg <michael@stapelberg.de>2013-07-23 23:51:22 +0200
commite107c24e918ec09abf4e43653806d9fd6bfb8d05 (patch)
tree3b52813f37455550d32fb9ebd28879e57f815218 /script
parent64b84f13250557ee077ccb83932cb7a244e7acd4 (diff)
downloadinit-system-helpers-e107c24e918ec09abf4e43653806d9fd6bfb8d05.tar.gz
deb-systemd-helper: implement debian-installed command
Diffstat (limited to 'script')
-rwxr-xr-xscript/deb-systemd-helper21
1 files changed, 19 insertions, 2 deletions
diff --git a/script/deb-systemd-helper b/script/deb-systemd-helper
index 5d8466b..d655174 100755
--- a/script/deb-systemd-helper
+++ b/script/deb-systemd-helper
@@ -35,7 +35,7 @@ deb-systemd-helper - subset of systemctl for machines not running systemd
=head1 SYNOPSIS
-B<deb-systemd-helper> enable|disable|is-enabled|was-enabled|reenable S<I<unit file> ...>
+B<deb-systemd-helper> enable|disable|is-enabled|was-enabled|debian-installed|reenable S<I<unit file> ...>
=head1 DESCRIPTION
@@ -51,6 +51,9 @@ The "was-enabled" action is not present in systemctl, but is required in Debian
so that we can figure out whether a service was enabled before we installed an
updated service file. See http://bugs.debian.org/717603 for details.
+The "debian-installed" action is also not present in systemctl. It returns 0 if
+the state file of at least one of the given units is present.
+
B<deb-systemd-helper> is intended to be used from maintscripts to enable
systemd unit files. It is specifically NOT intended to be used interactively by
users. Instead, users should run systemd and use systemctl, or not bother about
@@ -232,6 +235,12 @@ sub was_enabled {
return 1;
}
+sub debian_installed {
+ my ($service_path) = @_;
+ my $statefile = "$state_dir/" . basename($service_path) . '.dsh-also';
+ return -f $statefile;
+}
+
sub remove_links {
my ($service_path) = @_;
@@ -322,7 +331,11 @@ if (!$ENV{DPKG_MAINTSCRIPT_PACKAGE}) {
debug "is purge = " . (is_purge() ? "yes" : "no");
-my $rc = $action eq 'is-enabled' ? 1 : 0;
+my $rc = 0;
+if ($action eq 'is-enabled' ||
+ $action eq 'debian-installed') {
+ $rc = 1;
+}
for my $scriptname (@ARGV) {
my $service_path = find_unit($scriptname);
@@ -349,6 +362,10 @@ for my $scriptname (@ARGV) {
$rc = 0 if $enabled;
}
+ if ($action eq 'debian-installed') {
+ $rc = 0 if debian_installed($service_path);
+ }
+
if ($action eq 'reenable') {
remove_links($service_path);
make_systemd_links($scriptname, $service_path, $action, undef);