chiark / gitweb /
systemctl: support force-reload and condrestart as aliases for reload-or-try-restart
[elogind.git] / src / systemctl.c
index d78294b6d8da2d064e5b4d0823981c6a2bc4d556..667aeaeb9642cd4ee40891c745d96f522681b46c 100644 (file)
@@ -47,7 +47,7 @@
 #include "list.h"
 
 static const char *arg_type = NULL;
-static const char *arg_property = NULL;
+static char **arg_property = NULL;
 static bool arg_all = false;
 static bool arg_fail = false;
 static bool arg_session = false;
@@ -1087,7 +1087,9 @@ static int start_unit(DBusConnection *bus, char **args, unsigned n) {
                         streq(args[0], "restart")               ? "RestartUnit" :
                         streq(args[0], "try-restart")           ? "TryRestartUnit" :
                         streq(args[0], "reload-or-restart")     ? "ReloadOrRestartUnit" :
-                        streq(args[0], "reload-or-try-restart") ? "ReloadOrTryRestartUnit" :
+                        streq(args[0], "reload-or-try-restart") ||
+                        streq(args[0], "force-reload")          ||
+                        streq(args[0], "condrestart")           ? "ReloadOrTryRestartUnit" :
                                                                   "StartUnit";
 
                 mode =
@@ -1702,7 +1704,7 @@ static int print_property(const char *name, DBusMessageIter *iter) {
         /* This is a low-level property printer, see
          * print_status_info() for the nicer output */
 
-        if (arg_property && !streq(name, arg_property))
+        if (arg_property && !strv_find(arg_property, name))
                 return 0;
 
         switch (dbus_message_iter_get_arg_type(iter)) {
@@ -3089,14 +3091,21 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
                         arg_type = optarg;
                         break;
 
-                case 'p':
-                        arg_property = optarg;
+                case 'p': {
+                        char **l;
+
+                        if (!(l = strv_append(arg_property, optarg)))
+                                return -ENOMEM;
+
+                        strv_free(arg_property);
+                        arg_property = l;
 
                         /* If the user asked for a particular
                          * property, show it to him, even if it is
                          * empty. */
                         arg_all = true;
                         break;
+                }
 
                 case 'a':
                         arg_all = true;
@@ -3653,6 +3662,8 @@ static int systemctl_main(DBusConnection *bus, int argc, char *argv[]) {
                 { "try-restart",       MORE,  2, start_unit      },
                 { "reload-or-restart", MORE,  2, start_unit      },
                 { "reload-or-try-restart", MORE, 2, start_unit   },
+                { "force-reload",      MORE,  2, start_unit      }, /* For compatibility with SysV */
+                { "condrestart",       MORE,  2, start_unit      }, /* For compatibility with RH */
                 { "isolate",           EQUAL, 2, start_unit      },
                 { "check",             MORE,  2, check_unit      },
                 { "show",              MORE,  1, show            },
@@ -3927,5 +3938,7 @@ finish:
 
         dbus_shutdown();
 
+        strv_free(arg_property);
+
         return retval;
 }