chiark / gitweb /
shutdownd: kill /etc/nologin file before we go down
[elogind.git] / src / systemctl.c
index ca676f9da3437c2493de38e21282f8e3f6f31279..44b884800bdee69708a7acf2bf8d1a6a65543dcf 100644 (file)
@@ -216,11 +216,11 @@ static int compare_unit_info(const void *a, const void *b) {
         if (d1 && d2) {
                 int r;
 
-                if ((r = strcmp(d1, d2)) != 0)
+                if ((r = strcasecmp(d1, d2)) != 0)
                         return r;
         }
 
-        return strcmp(u->id, v->id);
+        return strcasecmp(u->id, v->id);
 }
 
 static int list_units(DBusConnection *bus, char **args, unsigned n) {
@@ -3829,7 +3829,7 @@ static int halt_help(void) {
 
 static int shutdown_help(void) {
 
-        printf("%s [OPTIONS...] [now] [WALL...]\n\n"
+        printf("%s [OPTIONS...] [TIME] [WALL...]\n\n"
                "Shut down the system.\n\n"
                "     --help      Show this help\n"
                "  -H --halt      Halt the machine\n"
@@ -4137,11 +4137,14 @@ static int parse_time_spec(const char *t, usec_t *_u) {
                         return -EINVAL;
 
                 n = now(CLOCK_REALTIME);
-                s = (time_t) n / USEC_PER_SEC;
+                s = (time_t) (n / USEC_PER_SEC);
+
+                zero(tm);
                 assert_se(localtime_r(&s, &tm));
 
                 tm.tm_hour = (int) hour;
                 tm.tm_min = (int) minute;
+                tm.tm_sec = 0;
 
                 assert_se(s = mktime(&tm));
 
@@ -4239,7 +4242,7 @@ static int shutdown_parse_argv(int argc, char *argv[]) {
                         return r;
                 }
         } else
-                arg_when = USEC_PER_MINUTE;
+                arg_when = now(CLOCK_REALTIME) + USEC_PER_MINUTE;
 
         /* We skip the time argument */
         if (argc > optind + 1)
@@ -4819,6 +4822,7 @@ static int halt_main(DBusConnection *bus) {
 
         if (arg_when > 0) {
                 char *m;
+                char date[FORMAT_TIMESTAMP_MAX];
 
                 m = strv_join(arg_wall, " ");
                 r = send_shutdownd(arg_when,
@@ -4831,8 +4835,11 @@ static int halt_main(DBusConnection *bus) {
 
                 if (r < 0)
                         log_warning("Failed to talk to shutdownd, proceeding with immediate shutdown: %s", strerror(-r));
-                else
+                else {
+                        log_info("Shutdown scheduled for %s, use 'shutdown -c' to cancel.",
+                                 format_timestamp(date, sizeof(date), arg_when));
                         return 0;
+                }
         }
 
         if (!arg_dry && !arg_immediate)
@@ -4903,6 +4910,7 @@ int main(int argc, char*argv[]) {
         dbus_error_init(&error);
 
         log_parse_environment();
+        log_open();
 
         if ((r = parse_argv(argc, argv)) < 0)
                 goto finish;