diff --git a/docs/FAQ.md b/docs/FAQ.md index 02be27fcaf..6f2db49caa 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -47,8 +47,6 @@ A: Note that there might be more than one target active at the same time. So the $ systemctl list-units --type=target ``` -If you are just interested in a single number, you can use the venerable _runlevel_ command, but again, its output might be misleading. - **Q: I want to change a service file, but rpm keeps overwriting it in /usr/lib/systemd/system all the time, how should I handle this?** A: The recommended way is to copy the service file from /usr/lib/systemd/system to /etc/systemd/system and edit it there. The latter directory takes precedence over the former, and rpm will never overwrite it. If you want to use the distributed service file again you can simply delete (or rename) the service file in /etc/systemd/system again. diff --git a/man/rules/meson.build b/man/rules/meson.build index 12e9fd97aa..38d608db48 100644 --- a/man/rules/meson.build +++ b/man/rules/meson.build @@ -79,7 +79,6 @@ manpages = [ ['resolvectl', '1', ['resolvconf'], 'ENABLE_RESOLVE'], ['resolved.conf', '5', ['resolved.conf.d'], 'ENABLE_RESOLVE'], ['run0', '1', [], ''], - ['runlevel', '8', [], 'HAVE_SYSV_COMPAT'], ['sd-bus-errors', '3', ['SD_BUS_ERROR_ACCESS_DENIED', diff --git a/man/runlevel.xml b/man/runlevel.xml deleted file mode 100644 index 7b7e24ba6c..0000000000 --- a/man/runlevel.xml +++ /dev/null @@ -1,164 +0,0 @@ - - - - - - - - runlevel - systemd - - - - runlevel - 8 - - - - runlevel - Print previous and current SysV runlevel - - - - - runlevel - options - - - - - Overview - - "Runlevels" are an obsolete way to start and stop groups of - services used in SysV init. systemd provides a compatibility layer - that maps runlevels to targets, and associated binaries like - runlevel. Nevertheless, only one runlevel can - be "active" at a given time, while systemd can activate multiple - targets concurrently, so the mapping to runlevels is confusing - and only approximate. Runlevels should not be used in new code, - and are mostly useful as a shorthand way to refer the matching - systemd targets in kernel boot parameters. - - - Mapping between runlevels and systemd targets - - - - - - Runlevel - Target - - - - - 0 - poweroff.target - - - 1 - rescue.target - - - 2, 3, 4 - multi-user.target - - - 5 - graphical.target - - - 6 - reboot.target - - - -
-
- - - Description - - runlevel prints the previous and current - SysV runlevel if they are known. - - The two runlevel characters are separated by a single space - character. If a runlevel cannot be determined, N is printed - instead. If neither can be determined, the word "unknown" is - printed. - - Unless overridden in the environment, this will check the - utmp database for recent runlevel changes. - - - - Options - - The following option is understood: - - - - - - - - - - - - - Exit status - - If one or both runlevels could be determined, 0 is returned, - a non-zero failure code otherwise. - - - - - Environment - - - - $RUNLEVEL - - If $RUNLEVEL is set, - runlevel will print this value as current - runlevel and ignore utmp. - - - - $PREVLEVEL - - If $PREVLEVEL is set, - runlevel will print this value as previous - runlevel and ignore utmp. - - - - - - Files - - - - /run/utmp - - The utmp database runlevel reads the previous and current runlevel - from. - - - - - - - - See Also - - systemd1 - systemd.target5 - systemctl1 - - -
diff --git a/src/systemctl/meson.build b/src/systemctl/meson.build index 4cff1f31de..ca83fc8937 100644 --- a/src/systemctl/meson.build +++ b/src/systemctl/meson.build @@ -32,7 +32,6 @@ systemctl_sources = files( ) systemctl_extract_sources = files( 'systemctl-compat-halt.c', - 'systemctl-compat-runlevel.c', 'systemctl-compat-shutdown.c', 'systemctl-compat-telinit.c', 'systemctl-daemon-reload.c', @@ -75,7 +74,7 @@ executables += [ ] foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] + - (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : [])) + (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['telinit'] : [])) install_symlink(alias, pointing_to : sbin_to_bin + 'systemctl', install_dir : sbindir) diff --git a/src/systemctl/systemctl-compat-runlevel.c b/src/systemctl/systemctl-compat-runlevel.c deleted file mode 100644 index e31bfd408b..0000000000 --- a/src/systemctl/systemctl-compat-runlevel.c +++ /dev/null @@ -1,81 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ - -#include - -#include "alloc-util.h" -#include "log.h" -#include "pretty-print.h" -#include "systemctl-compat-runlevel.h" -#include "utmp-wtmp.h" - -static int runlevel_help(void) { - _cleanup_free_ char *link = NULL; - int r; - - r = terminal_urlify_man("runlevel", "8", &link); - if (r < 0) - return log_oom(); - - printf("%s [OPTIONS...]\n" - "\n%sPrints the previous and current runlevel of the init system.%s\n" - "\nOptions:\n" - " --help Show this help\n" - "\nSee the %s for details.\n", - program_invocation_short_name, - ansi_highlight(), - ansi_normal(), - link); - - return 0; -} - -int runlevel_parse_argv(int argc, char *argv[]) { - enum { - ARG_HELP = 0x100, - }; - - static const struct option options[] = { - { "help", no_argument, NULL, ARG_HELP }, - {} - }; - - int c; - - assert(argc >= 0); - assert(argv); - - while ((c = getopt_long(argc, argv, "", options, NULL)) >= 0) - switch (c) { - - case ARG_HELP: - return runlevel_help(); - - case '?': - return -EINVAL; - - default: - assert_not_reached(); - } - - if (optind < argc) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "Too many arguments."); - - return 1; -} - -int runlevel_main(void) { - int r, runlevel, previous; - - r = utmp_get_runlevel(&runlevel, &previous); - if (r < 0) { - puts("unknown"); - return r; - } - - printf("%c %c\n", - previous <= 0 ? 'N' : previous, - runlevel <= 0 ? 'N' : runlevel); - - return 0; -} diff --git a/src/systemctl/systemctl-compat-runlevel.h b/src/systemctl/systemctl-compat-runlevel.h deleted file mode 100644 index 658524bf1e..0000000000 --- a/src/systemctl/systemctl-compat-runlevel.h +++ /dev/null @@ -1,6 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -#pragma once - -int runlevel_parse_argv(int argc, char *argv[]); - -int runlevel_main(void); diff --git a/src/systemctl/systemctl-main.c b/src/systemctl/systemctl-main.c index cde07ab8cb..2e2dcd3e55 100644 --- a/src/systemctl/systemctl-main.c +++ b/src/systemctl/systemctl-main.c @@ -16,7 +16,6 @@ #include "systemctl-cancel-job.h" #include "systemctl-clean-or-freeze.h" #include "systemctl-compat-halt.h" -#include "systemctl-compat-runlevel.h" #include "systemctl-compat-telinit.h" #include "systemctl-daemon-reload.h" #include "systemctl-edit.h" @@ -236,10 +235,6 @@ static int run(int argc, char *argv[]) { r = logind_show_shutdown(); break; - case ACTION_RUNLEVEL: - r = runlevel_main(); - break; - case ACTION_EXIT: case ACTION_SLEEP: case ACTION_SUSPEND: diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 47a8867630..439e11699f 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -24,7 +24,6 @@ #include "strv.h" #include "systemctl.h" #include "systemctl-compat-halt.h" -#include "systemctl-compat-runlevel.h" #include "systemctl-compat-shutdown.h" #include "systemctl-compat-telinit.h" #include "systemctl-logind.h" @@ -1142,10 +1141,6 @@ int systemctl_dispatch_parse_argv(int argc, char *argv[]) { arg_action = _ACTION_INVALID; /* telinit_parse_argv() will figure out the actual action we'll execute */ return telinit_parse_argv(argc, argv); - - } else if (invoked_as(argv, "runlevel")) { - arg_action = ACTION_RUNLEVEL; - return runlevel_parse_argv(argc, argv); } arg_action = ACTION_SYSTEMCTL; diff --git a/src/systemctl/systemctl.h b/src/systemctl/systemctl.h index af30d2a6f5..91702d1252 100644 --- a/src/systemctl/systemctl.h +++ b/src/systemctl/systemctl.h @@ -25,7 +25,6 @@ enum action { ACTION_DEFAULT, ACTION_RELOAD, ACTION_REEXEC, - ACTION_RUNLEVEL, ACTION_CANCEL_SHUTDOWN, ACTION_SHOW_SHUTDOWN, ACTION_SYSTEMCTL_SHOW_SHUTDOWN, diff --git a/tools/command_ignorelist b/tools/command_ignorelist index 4a48d4e614..6639fb08bd 100644 --- a/tools/command_ignorelist +++ b/tools/command_ignorelist @@ -63,10 +63,6 @@ os-release.xml ./refsect1[title="Options"]/refsect2[title="Presentation informat pam_systemd.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="debug="] pam_systemd.xml ./refsect1[title="Environment"]/variablelist[1]/varlistentry[term="$XDG_SESSION_ID"] pam_systemd.xml ./refsect1[title="Environment"]/variablelist[1]/varlistentry[term="$XDG_RUNTIME_DIR"] -runlevel.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="--help"] -runlevel.xml ./refsect1[title="Environment"]/variablelist/varlistentry[term="$RUNLEVEL"] -runlevel.xml ./refsect1[title="Environment"]/variablelist/varlistentry[term="$PREVLEVEL"] -runlevel.xml ./refsect1[title="Files"]/variablelist/varlistentry[term="/run/utmp"] shutdown.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="--help"] shutdown.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="-H"] shutdown.xml ./refsect1[title="Options"]/variablelist/varlistentry[term="-P"]