static bool arg_value = false;
static bool arg_show_types = false;
static bool arg_ignore_inhibitors = false;
-static bool arg_dry = false;
+static bool arg_dry_run = false;
static bool arg_quiet = false;
static bool arg_full = false;
static bool arg_recursive = false;
/* Open the password agent as a child process if necessary */
+ if (arg_dry_run)
+ return;
+
if (!arg_ask_password)
return;
return log_error_errno(r, "Failed to add match for PropertiesChanged signal: %m");
}
- log_debug("Calling manager for %s on %s, %s", method, name, mode);
+ log_debug("%s manager for %s on %s, %s",
+ arg_dry_run ? "Would call" : "Calling",
+ method, name, mode);
+ if (arg_dry_run)
+ return 0;
r = sd_bus_call_method(
bus,
sd_bus *bus;
int r;
+ if (arg_dry_run)
+ return 0;
+
r = acquire_bus(BUS_MANAGER, &bus);
if (r < 0)
return r;
" --kill-who=WHO Who to send signal to\n"
" -s --signal=SIGNAL Which signal to send\n"
" --now Start or stop unit in addition to enabling or disabling it\n"
+ " --dry-run Only print what would be done\n"
" -q --quiet Suppress output\n"
" --wait For (re)start, wait until service stopped again\n"
" --no-block Do not wait until operation finished\n"
ARG_REVERSE,
ARG_AFTER,
ARG_BEFORE,
+ ARG_DRY_RUN,
ARG_SHOW_TYPES,
ARG_IRREVERSIBLE,
ARG_IGNORE_DEPENDENCIES,
{ "no-legend", no_argument, NULL, ARG_NO_LEGEND },
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
{ "no-wall", no_argument, NULL, ARG_NO_WALL },
+ { "dry-run", no_argument, NULL, ARG_DRY_RUN },
{ "quiet", no_argument, NULL, 'q' },
{ "root", required_argument, NULL, ARG_ROOT },
{ "force", no_argument, NULL, ARG_FORCE },
break;
+ case ARG_DRY_RUN:
+ arg_dry_run = true;
+ break;
+
case 'q':
arg_quiet = true;
break;
break;
case 'w':
- arg_dry = true;
+ arg_dry_run = true;
break;
case 'd':
break;
case 'k':
- arg_dry = true;
+ arg_dry_run = true;
break;
case ARG_NO_WALL:
/* The kernel will automaticall flush ATA disks and suchlike
* on reboot(), but the file systems need to be synce'd
* explicitly in advance. */
- if (!arg_no_sync)
+ if (!arg_no_sync && !arg_dry_run)
(void) sync();
- /* Make sure C-A-D is handled by the kernel from this point
- * on... */
- (void) reboot(RB_ENABLE_CAD);
+ /* Make sure C-A-D is handled by the kernel from this point on... */
+ if (!arg_dry_run)
+ (void) reboot(RB_ENABLE_CAD);
switch (a) {
case ACTION_HALT:
if (!arg_quiet)
log_info("Halting.");
+ if (arg_dry_run)
+ return 0;
(void) reboot(RB_HALT_SYSTEM);
return -errno;
case ACTION_POWEROFF:
if (!arg_quiet)
log_info("Powering off.");
+ if (arg_dry_run)
+ return 0;
(void) reboot(RB_POWER_OFF);
return -errno;
if (!isempty(param)) {
if (!arg_quiet)
log_info("Rebooting with argument '%s'.", param);
- (void) syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, param);
- log_warning_errno(errno, "Failed to reboot with parameter, retrying without: %m");
+ if (!arg_dry_run) {
+ (void) syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
+ LINUX_REBOOT_CMD_RESTART2, param);
+ log_warning_errno(errno, "Failed to reboot with parameter, retrying without: %m");
+ }
}
if (!arg_quiet)
log_info("Rebooting.");
+ if (arg_dry_run)
+ return 0;
(void) reboot(RB_AUTOBOOT);
return -errno;
}
break;
}
- if (arg_dry)
+ if (arg_dry_run)
action = strjoina("dry-", action);
(void) logind_set_wall_message();
return logind_schedule_shutdown();
if (geteuid() != 0) {
- if (arg_dry || arg_force > 0) {
+ if (arg_dry_run || arg_force > 0) {
log_error("Must be root.");
return -EPERM;
}
}
}
- if (!arg_dry && !arg_force)
+ if (!arg_dry_run && !arg_force)
return start_with_fallback();
assert(geteuid() == 0);
}
}
- if (arg_dry)
+ if (arg_dry_run)
return 0;
r = halt_now(arg_action);