Control: tags -1 + patch Am 27.03.2016 um 22:57 schrieb Branko Majic: > Sorry for the super-late reply on this one. I haven't dug into it any > further at the moment. I'm afraid I might have wiped-out the patches I > had in the meantime (it was still a very dirty hack), but will need to > check it.
Attached is a patch for v215 which adds support for is-enabled for SysV init scripts. It uses the same heuristics/logic as systemd-sysv-install. Feedback welcome. I'd appreciate it if you could test the patch. Michael -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?
From 74a55eee2e4fdc15d4b7857e2f2454dd00730fc0 Mon Sep 17 00:00:00 2001
From: Michael Biebl <michael@debian>
Date: Wed, 15 Feb 2017 10:03:37 +0100
Subject: [PATCH] Support is-enabled for SysV init scripts
As update-rc.d does not provide is-enabled, we implement it ourselves in
systemctl. It uses the same logic as in systemd-sysv-install, see
commit b5aa768d8108b294c1187a0728f5b13c033b3d47
Closes: #809405
---
src/systemctl/systemctl.c | 38 ++++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index c67b86d..efce97f 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -4998,9 +4998,8 @@ static int enable_sysv_units(const char *verb, char **args) {
return 0;
if (!streq(verb, "enable") &&
- !streq(verb, "disable"))
- // update-rc.d currently does not provide is-enabled
- //!streq(verb, "is-enabled"))
+ !streq(verb, "disable") &&
+ !streq(verb, "is-enabled"))
return 0;
/* Processes all SysV units, and reshuffles the array so that
@@ -5045,6 +5044,12 @@ static int enable_sysv_units(const char *verb, char **args) {
break;
}
+ /* If we have both a native unit and a SysV script,
+ * enable/disable them both (below); for is-enabled,
+ * prefer the native unit */
+ if (found_native && streq(verb, "is-enabled"))
+ continue;
+
if (!isempty(arg_root))
asprintf(&p, "%s/" SYSTEM_SYSVINIT_PATH "/%s", arg_root, name);
else
@@ -5065,6 +5070,21 @@ static int enable_sysv_units(const char *verb, char **args) {
args[f] = (char*) "";
}
+ if (streq(verb, "is-enabled")) {
+ _cleanup_free_ char *g = NULL;
+ asprintf(&g, "%s%s", "/etc/rc[S5].d/S??", basename(p));
+ if (glob_exists(g)) {
+ if (!arg_quiet)
+ puts("enabled");
+ r = 1;
+ continue;
+ } else {
+ if (!arg_quiet)
+ puts("disabled");
+ continue;
+ }
+ }
+
log_info("Synchronizing state for %s with sysvinit using update-rc.d...", name);
if (!isempty(arg_root) && !streq(arg_root, "/")) {
@@ -5149,17 +5169,7 @@ static int enable_sysv_units(const char *verb, char **args) {
}
if (status.si_code == CLD_EXITED) {
- if (streq(verb, "is-enabled")) {
- if (status.si_status == 0) {
- if (!arg_quiet)
- puts("enabled");
- r = 1;
- } else {
- if (!arg_quiet)
- puts("disabled");
- }
-
- } else if (status.si_status != 0) {
+ if (status.si_status != 0) {
r = -EINVAL;
goto finish;
}
--
2.11.0
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Pkg-systemd-maintainers mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-systemd-maintainers
