summaryrefslogtreecommitdiff
path: root/src/systemctl/systemctl.c
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2022-11-27 21:18:44 +0800
committerMike Yuan <me@yhndnzj.com>2022-12-03 20:26:19 +0800
commit108d35ac7d435b4f1378a9c0fa50858263475e09 (patch)
tree4cd902ffc25e958431cce2a92a8730d0918609a7 /src/systemctl/systemctl.c
parentbf1bea43f15b04152a3948702ba1695a0835c2bf (diff)
downloadsystemd-108d35ac7d435b4f1378a9c0fa50858263475e09.tar.gz
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.c9
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);