diff options
author | Mike Yuan <me@yhndnzj.com> | 2022-11-27 14:18:44 +0100 |
---|---|---|
committer | Mike Yuan <me@yhndnzj.com> | 2022-12-03 13:26:19 +0100 |
commit | 108d35ac7d435b4f1378a9c0fa50858263475e09 (patch) | |
tree | 4cd902ffc25e958431cce2a92a8730d0918609a7 /src/systemctl/systemctl.c | |
parent | systemctl: warn if trying to disable a unit with no install info (diff) | |
download | systemd-108d35ac7d435b4f1378a9c0fa50858263475e09.tar.xz systemd-108d35ac7d435b4f1378a9c0fa50858263475e09.zip |
systemctl: allow suppress the warning of no install info using --no-warn
In cases like packaging scripts, it might be desired to use
enable/disable on units without install info. So, adding an
option '--no-warn' to suppress the warning.
Diffstat (limited to 'src/systemctl/systemctl.c')
-rw-r--r-- | src/systemctl/systemctl.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 3f28bcc3dc..109fb139d1 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -84,6 +84,7 @@ bool arg_show_types = false; int arg_check_inhibitors = -1; bool arg_dry_run = false; bool arg_quiet = false; +bool arg_no_warn = false; bool arg_full = false; bool arg_recursive = false; bool arg_with_dependencies = false; @@ -277,6 +278,8 @@ static int systemctl_help(void) { " kexec, suspend, hibernate, suspend-then-hibernate,\n" " hybrid-sleep, default, rescue, emergency, and exit.\n" " -q --quiet Suppress output\n" + " --no-warn Don't generate warning when trying to enable/disable\n" + " units without install information\n" " --wait For (re)start, wait until service stopped again\n" " For is-system-running, wait until startup is completed\n" " --no-block Do not wait until operation finished\n" @@ -433,6 +436,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) { ARG_READ_ONLY, ARG_MKDIR, ARG_MARKED, + ARG_NO_WARN, }; static const struct option options[] = { @@ -465,6 +469,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) { { "no-wall", no_argument, NULL, ARG_NO_WALL }, { "dry-run", no_argument, NULL, ARG_DRY_RUN }, { "quiet", no_argument, NULL, 'q' }, + { "no-warn", no_argument, NULL, ARG_NO_WARN }, { "root", required_argument, NULL, ARG_ROOT }, { "image", required_argument, NULL, ARG_IMAGE }, { "force", no_argument, NULL, 'f' }, @@ -926,6 +931,10 @@ static int systemctl_parse_argv(int argc, char *argv[]) { arg_marked = true; break; + case ARG_NO_WARN: + arg_no_warn = true; + break; + case '.': /* Output an error mimicking getopt, and print a hint afterwards */ log_error("%s: invalid option -- '.'", program_invocation_name); |