]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: add a way to explicitly request client-side unit installing
authorLennart Poettering <lennart@poettering.net>
Thu, 8 Oct 2015 14:15:38 +0000 (16:15 +0200)
committerLennart Poettering <lennart@poettering.net>
Sat, 31 Oct 2015 18:09:20 +0000 (19:09 +0100)
This adds support for a new environment variable
SYSTEMCTL_INSTALL_CLIENT_SIDE, that ensures that systemctl executes
install operations client-side instead of passing them to PID1. This is
useful in debugging situations, but even beyond that. However, we don't
want to make it official API, hence let's just make it an undocumented
environment variable.

Similar, add a second variable, SYSTEMCTL_SKIP_SYSV which allows
skipping the SysV chkconfig fall-back if set. This is useful for similar
reasons, and exposed as undocumented as environment variable for similar
reasons, too.

src/basic/env-util.c
src/basic/env-util.h
src/systemctl/systemctl.c

index 94cb25169839d8ef39c554d50ee007f11a7845e2..9ddac5d6a1c39e967c576d6cd0de6356c5375879 100644 (file)
@@ -25,6 +25,7 @@
 #include "alloc-util.h"
 #include "def.h"
 #include "env-util.h"
+#include "parse-util.h"
 #include "string-util.h"
 #include "strv.h"
 #include "utf8.h"
@@ -594,3 +595,13 @@ char **replace_env_argv(char **argv, char **env) {
         ret[k] = NULL;
         return ret;
 }
+
+int getenv_bool(const char *p) {
+        const char *e;
+
+        e = getenv(p);
+        if (!e)
+                return -ENXIO;
+
+        return parse_boolean(e);
+}
index 803aa61cad7def354ea11335cf6ba50094ebddcb..6485dade1857e16ed0f1e214b7a39ba8d0a0cbad 100644 (file)
@@ -47,3 +47,5 @@ char **strv_env_unset_many(char **l, ...) _sentinel_;
 
 char *strv_env_get_n(char **l, const char *name, size_t k) _pure_;
 char *strv_env_get(char **x, const char *n) _pure_;
+
+int getenv_bool(const char *p);
index f5efa1a064f9d147e3551047be6650766a1746bd..da816e6d0e2d193155a51dad820b4ec16edc33ed 100644 (file)
@@ -296,6 +296,10 @@ static bool install_client_side(void) {
         if (arg_scope == UNIT_FILE_GLOBAL)
                 return true;
 
+        /* Unsupported environment variable, mostly for debugging purposes */
+        if (getenv_bool("SYSTEMCTL_INSTALL_CLIENT_SIDE") > 0)
+                return true;
+
         return false;
 }
 
@@ -5317,6 +5321,9 @@ static int enable_sysv_units(const char *verb, char **args) {
         if (arg_scope != UNIT_FILE_SYSTEM)
                 return 0;
 
+        if (getenv_bool("SYSTEMCTL_SKIP_SYSV") > 0)
+                return 0;
+
         if (!STR_IN_SET(verb,
                         "enable",
                         "disable",