[systemd-devel] [PATCH 1/2] systemctl: Don't skip native units when enabling/disabling SysV init.d scripts

Lennart Poettering lennart at poettering.net
Wed May 27 06:18:10 PDT 2015


On Wed, 27.05.15 15:07, Martin Pitt (martin.pitt at ubuntu.com) wrote:

> Hello,
> 
> as discussed in the "get some distro patches upstream" thread, this is
> the generalization for supporting different
> chkconfig/update-rc.d/whatnot distro implementations of enabling
> init.d scripts, as per LSB specification.
> 
> I figure at some point we might want to drop the explicit
> --enable-chkconfig support and instead provide a Fedora/RedHat
> chckconfig wrapper in /usr/lib/lsb/{install,remove}_initd ? Then we
> can get rid of the #ifdeffery and some code.

Such a wrapper should be added downstream in the Fedora initscripts
package I am sure... I'd like to fully remove native support for this
Fedora tool upstream. The fewer distro-specific hacks the better.

> I tested this with enabling/disabling with "only systemd unit" and
> "only SysV unit", both with and with not having the LSB wrappers. If
> there is both a script and a unit for the same name we need a second
> patch, will post that separately as 2/2 as it's unrelated to this
> change.

If we do this, then I'd like to go all the way right-away: strip
chkconfig support if we add support for the new hook.

>  
>          if (!streq(verb, "enable") &&
> -            !streq(verb, "disable") &&
> -            !streq(verb, "is-enabled"))
> +            !streq(verb, "disable")
> +/* LSB has no way of checking the enablement status */
> +#if defined(HAVE_CHKCONFIG)
> +            && !streq(verb, "is-enabled")
> +#endif
> +            )
>                  return 0;

[...]

>  
> -                log_info("%s is not a native service, redirecting to /sbin/chkconfig.", name);
> -
> +#if defined(HAVE_CHKCONFIG)
> +                argv[0] = "/sbin/chkconfig";
>                  if (!isempty(arg_root))
>                          argv[c++] = q = strappend("--root=", arg_root);
>  
> @@ -5170,6 +5174,25 @@ static int enable_sysv_units(const char *verb, char **args) {
>                  argv[c++] =
>                          streq(verb, "enable") ? "on" :
>                          streq(verb, "disable") ? "off" : "--level=5";
> +
> +#else
> +                if (!isempty(arg_root) && !streq(arg_root, "/")) {
> +                        log_error("Can not %s SysV init script when a root directory other than / is specified", verb);
> +                        continue;
> +                }

Hmm, this makes me feel a bit uneasy about the LSB support... If
neither "is-enabled" nor "--root=" can covered by the LSB tool, I
wonder if we should use it at all... Also, as it appears the LSB tool
only takes a single script per invocation, which is also incompatible
with how we need it...

Maybe introducing a new tool for this that covers all options is the
better idea.  Let's call it /usr/lib/systemd/systemd-sysv-install or
so, taking the --root= switch as before, plus "enable", "disable",
"is-enabled" plus one or more LSB init script names is the better
option... Distros implementing LSB can then direct this tool to the
LSB tools if they wish, and Fedora can translate this to chkconfig,
without losing any functionality...

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list