chiark / gitweb /
job: introduce new job result code 'skipped' to use when pre conditions of job did...
[elogind.git] / src / systemctl.c
index b733b47c84420eb90d0b1a12ff42a260723f040d..f5a87fc701c254bf2f9e613a76f386a3195f3bcc 100644 (file)
@@ -1249,7 +1249,7 @@ static int wait_for_jobs(DBusConnection *bus, Set *s) {
                         log_error("Job canceled.");
                 else if (streq(d.result, "dependency"))
                         log_error("A dependency job failed. See system logs for details.");
-                else if (!streq(d.result, "done"))
+                else if (!streq(d.result, "done") && !streq(d.result, "skipped"))
                         log_error("Job failed. See system logs and 'systemctl status' for details.");
         }
 
@@ -1257,7 +1257,7 @@ static int wait_for_jobs(DBusConnection *bus, Set *s) {
                 r = -ETIME;
         else if (streq_ptr(d.result, "canceled"))
                 r = -ECANCELED;
-        else if (!streq_ptr(d.result, "done"))
+        else if (!streq_ptr(d.result, "done") && !streq_ptr(d.result, "skipped"))
                 r = -EIO;
         else
                 r = 0;
@@ -1417,11 +1417,15 @@ static int start_unit(DBusConnection *bus, char **args, unsigned n) {
                         streq(args[0], "stop")                  ? "StopUnit" :
                         streq(args[0], "reload")                ? "ReloadUnit" :
                         streq(args[0], "restart")               ? "RestartUnit" :
+
                         streq(args[0], "try-restart")           ||
                         streq(args[0], "condrestart")           ? "TryRestartUnit" :
+
                         streq(args[0], "reload-or-restart")     ? "ReloadOrRestartUnit" :
+
                         streq(args[0], "reload-or-try-restart") ||
                         streq(args[0], "condreload") ||
+
                         streq(args[0], "force-reload")          ? "ReloadOrTryRestartUnit" :
                                                                   "StartUnit";
 
@@ -4087,10 +4091,15 @@ static int install_info_apply(const char *verb, LookupPaths *paths, InstallInfo
                                         return r;
 
                                 if (status.si_code == CLD_EXITED) {
-                                        if (status.si_status == 0 && (streq(verb, "enable") || streq(verb, "disable")))
+
+                                        if (streq(verb, "is-enabled"))
+                                                return status.si_status == 0 ? 1 : 0;
+
+                                        if (status.si_status == 0)
                                                 n_symlinks ++;
 
                                         return status.si_status == 0 ? 0 : -EINVAL;
+
                                 } else
                                         return -EPROTO;
                         }
@@ -4193,6 +4202,8 @@ static int enable_unit(DBusConnection *bus, char **args, unsigned n) {
                         goto finish;
                 }
 
+        r = 0;
+
         while ((i = hashmap_first(will_install))) {
                 int q;