chiark / gitweb /
systemctl: delete REBOOT_PARAM_FILE if no parameter is specified
[elogind.git] / src / systemctl / systemctl.c
index 1b381f7a90680d6a661fcff02c2916601b4b5e7c..1717c1929ee15396f32ad039c04236bd38fbd2ce 100644 (file)
@@ -6018,13 +6018,10 @@ static int halt_parse_argv(int argc, char *argv[]) {
                 }
         }
 
-        if (arg_action == ACTION_REBOOT && argc == optind + 1) {
-                r = write_string_file(REBOOT_PARAM_FILE, argv[optind]);
-                if (r < 0) {
-                        log_error("Failed to write reboot param to "
-                                  REBOOT_PARAM_FILE": %s", strerror(-r));
+        if (arg_action == ACTION_REBOOT && (argc == optind || argc == optind + 1)) {
+                r = update_reboot_param_file(argc == optind + 1 ? argv[optind] : NULL);
+                if (r < 0)
                         return r;
-                }
         } else if (optind < argc) {
                 log_error("Too many arguments.");
                 return -EINVAL;