]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: kill SysV compat 'runlevel' command
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 20 Apr 2025 20:48:53 +0000 (05:48 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 12 Jul 2025 20:38:13 +0000 (05:38 +0900)
docs/FAQ.md
man/rules/meson.build
man/runlevel.xml [deleted file]
src/systemctl/meson.build
src/systemctl/systemctl-compat-runlevel.c [deleted file]
src/systemctl/systemctl-compat-runlevel.h [deleted file]
src/systemctl/systemctl-main.c
src/systemctl/systemctl.c
src/systemctl/systemctl.h
tools/command_ignorelist

index 02be27fcaf25592c4bec1be78a5eea45f7637f2d..6f2db49caa9deb3b628c2fa6ea6b66135ba1c469 100644 (file)
@@ -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.
index 12e9fd97aaa232ebc897a9b4f18ca69493ee7bf0..38d608db4825cf8e5c74f0da3a76d8df3c63031b 100644 (file)
@@ -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 (file)
index 7b7e24b..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-<?xml version='1.0'?> <!--*-nxml-*-->
-<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
-  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
-<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
-
-<refentry id="runlevel" conditional='HAVE_SYSV_COMPAT'
-    xmlns:xi="http://www.w3.org/2001/XInclude">
-
-  <refentryinfo>
-    <title>runlevel</title>
-    <productname>systemd</productname>
-  </refentryinfo>
-
-  <refmeta>
-    <refentrytitle>runlevel</refentrytitle>
-    <manvolnum>8</manvolnum>
-  </refmeta>
-
-  <refnamediv>
-    <refname>runlevel</refname>
-    <refpurpose>Print previous and current SysV runlevel</refpurpose>
-  </refnamediv>
-
-  <refsynopsisdiv>
-    <cmdsynopsis>
-      <command>runlevel</command>
-      <arg choice="opt" rep="repeat">options</arg>
-    </cmdsynopsis>
-  </refsynopsisdiv>
-
-  <refsect1>
-    <title>Overview</title>
-
-    <para>"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
-    <command>runlevel</command>. 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.</para>
-
-    <table>
-      <title>Mapping between runlevels and systemd targets</title>
-      <tgroup cols='2' align='left' colsep='1' rowsep='1'>
-        <colspec colname="runlevel" />
-        <colspec colname="target" />
-        <thead>
-          <row>
-            <entry>Runlevel</entry>
-            <entry>Target</entry>
-          </row>
-        </thead>
-        <tbody>
-          <row>
-            <entry>0</entry>
-            <entry><filename>poweroff.target</filename></entry>
-          </row>
-          <row>
-            <entry>1</entry>
-            <entry><filename>rescue.target</filename></entry>
-          </row>
-          <row>
-            <entry>2, 3, 4</entry>
-            <entry><filename>multi-user.target</filename></entry>
-          </row>
-          <row>
-            <entry>5</entry>
-            <entry><filename>graphical.target</filename></entry>
-          </row>
-          <row>
-            <entry>6</entry>
-            <entry><filename>reboot.target</filename></entry>
-          </row>
-        </tbody>
-      </tgroup>
-    </table>
-  </refsect1>
-
-  <refsect1>
-    <title>Description</title>
-
-    <para><command>runlevel</command> prints the previous and current
-    SysV runlevel if they are known.</para>
-
-    <para>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.</para>
-
-    <para>Unless overridden in the environment, this will check the
-    utmp database for recent runlevel changes.</para>
-  </refsect1>
-
-  <refsect1>
-    <title>Options</title>
-
-    <para>The following option is understood:</para>
-
-    <variablelist>
-      <varlistentry>
-        <term><option>--help</option></term>
-
-        <xi:include href="standard-options.xml" xpointer="help-text" />
-      </varlistentry>
-    </variablelist>
-
-  </refsect1>
-
-  <refsect1>
-    <title>Exit status</title>
-
-    <para>If one or both runlevels could be determined, 0 is returned,
-    a non-zero failure code otherwise.</para>
-
-  </refsect1>
-
-  <refsect1>
-    <title>Environment</title>
-
-    <variablelist class='environment-variables'>
-      <varlistentry>
-        <term><varname>$RUNLEVEL</varname></term>
-
-        <listitem><para>If <varname>$RUNLEVEL</varname> is set,
-        <command>runlevel</command> will print this value as current
-        runlevel and ignore utmp.</para></listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term><varname>$PREVLEVEL</varname></term>
-
-        <listitem><para>If <varname>$PREVLEVEL</varname> is set,
-        <command>runlevel</command> will print this value as previous
-        runlevel and ignore utmp.</para></listitem>
-      </varlistentry>
-    </variablelist>
-  </refsect1>
-
-  <refsect1>
-    <title>Files</title>
-
-    <variablelist>
-      <varlistentry>
-        <term><filename>/run/utmp</filename></term>
-
-        <listitem><para>The utmp database <command>runlevel</command> reads the previous and current runlevel
-        from.</para>
-
-        <xi:include href="version-info.xml" xpointer="v237"/></listitem>
-      </varlistentry>
-    </variablelist>
-  </refsect1>
-
-  <refsect1>
-    <title>See Also</title>
-    <para><simplelist type="inline">
-      <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
-      <member><citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
-      <member><citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
-    </simplelist></para>
-  </refsect1>
-</refentry>
index 4cff1f31de7a7735e7615f5938ddc0e1acbcf905..ca83fc8937022256c98abf6bbf15dc703d85acc7 100644 (file)
@@ -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 (file)
index e31bfd4..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1-or-later */
-
-#include <getopt.h>
-
-#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 (file)
index 658524b..0000000
+++ /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);
index cde07ab8cb400d8691c414a336aaf05f112946c0..2e2dcd3e550c8ce4233a4a3e7f653bd492436f93 100644 (file)
@@ -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:
index 47a8867630521bf3a9abaab01b14938853f97b5c..439e11699f38e926b6a3268851c8daf706c9e036 100644 (file)
@@ -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;
index af30d2a6f581a548571642ac916727e41c4c90a1..91702d1252db5a1e02638b65df0e1b8291e4a440 100644 (file)
@@ -25,7 +25,6 @@ enum action {
         ACTION_DEFAULT,
         ACTION_RELOAD,
         ACTION_REEXEC,
-        ACTION_RUNLEVEL,
         ACTION_CANCEL_SHUTDOWN,
         ACTION_SHOW_SHUTDOWN,
         ACTION_SYSTEMCTL_SHOW_SHUTDOWN,
index 4a48d4e61428279b311034d8b8fe4e8bd5fc37cb..6639fb08bd06c397ac82306c54994dabc631ea5a 100644 (file)
@@ -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"]