• Common options missed in OpenRC declarative scripts and how to improve

    From Brian Evans@21:1/5 to All on Thu Dec 2 03:10:01 2021
    This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------zlDIb0hGEpwPs8HNESAGtZHs
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: quoted-printable

    After a cursory scan of the Gentoo repository, I've noticed an
    overabundance of start_stop_daemon_args being declared in scripts committed.

    I would like to draw attention and see if we can clean these up together.

    The reason why these are important is the modular nature of the
    declarative syntax. For example, supervise-daemon should be available to
    any user for a declarative script by simply adding supervisor="supervise-daemon" to the corresponding conf.d file.

    There are many necessary options like --wait or --env which don't have a declarative replacement.

    These comments are for scripts without a start/stop function defined
    thereby relying on the default scripts in /lib/rc/sh/. There are other advanced cases for sure. I just want to discuss easy to forget options.

    Common mistakes included with start_stop_daemon_args:

    "--background --make-pidfile" ("-b -m") should be replaced by command_background="yes" (these are implied together)

    "--user" and/or "--group" should be command_user="user:group" (use root
    for user when only group is needed, the :group can be omitted)

    "--chdir /path/to/foo" (-d) should be directory="/path/to/foo"

    "--chroot /var/chroot/foo" (-r) should be chroot="/var/chroot/foo"

    "--stdout /var/log/foo" (-1) should be output_log="/var/log/foo"

    "--stderr /var/log/foo.err" (-2) should be error_log="/var/log/foo.err"

    "--pidifle /run/foo.pid" (-p) should be pidfile="/run/foo.pid"

    "--name foo" (-n) should be procname="foo"

    "--exec" (-x) should be deleted as it is included by default when
    command="" is declared (required to exist)

    In addition, command_args may need to be reevaluated for each script to
    split certain pieces out into command_args_foreground and command_args_background.

    command_args_foreground should include any options to force the
    daemon/script into the foreground instead of forking.

    command_args_background should include any option to fork a daemon and, optionally, to have it write a pidfile to monitor. (Cannot be used
    together with command_background option).

    command_args should not include the conditions of the other two in most
    cases.

    If anyone would want me to do work in obvious cleanups, I am open to
    bugs, patches or just committing.

    Comments welcome.

    Brian

    --------------zlDIb0hGEpwPs8HNESAGtZHs--

    -----BEGIN PGP SIGNATURE-----

    wsF5BAABCAAjFiEEZsLkTtkOMnWOfVXA0feB7/n0o7YFAmGoKSwFAwAAAAAACgkQ0feB7/n0o7aO ng//Qq7QkAw5Fr63SWJ2s5miAbaf0p24FQ217CBNzUHLkZwkl7zsozaVSz3Yz8K8LLo553tZy02u ddcJ6lW9eHnP08GgH2F94Y7oWZQVDEo1vqUzun8ARu0jRoWplmR4UDfC6dgg3X7WJ3wNfh6Nb0gq qet3MJS+TqjLXI+ZPcIkKJt7H5jwzSVmolZXbKBHcxghlsNNNOgtrs1JQDJ/JkIWyj9h3p7ctTGJ 3t+DZWzl/S6ZVwls4fjXy3r3wDTHacvEUCxlAxWpLj9PqG2+2uUQ5eVOCh5ZhlDLKc4iXeggJGC/ ejXOFC7bqVPprJ9OusZPMlME6zmsgap7mGIxOtyL3Tg7cpmz1Ce6kaa3G46ZYdz4WokHEGPtn0qV h6MQeW/oSnbT4hkWv9d8IaBmS7IkEIhWN0jkehkyYBnSWDSitEPSP+ygYVQUQ+J5V/Ns+6u9wFlB 4f//VIrkVpF/IdbPkAgueamYrUx5k9+3D0RyXaqxOwim88lhCRXgYy/zNsActTaNr8jj+1iBzQaK vxBKAEdcNHPrkC636mCv2xgT2QSMdtoOFQEN7KteQbBT6OG9nQZRRPRgPymOcmKK3BNBrb/oLaeT UWrUUAuRtrRtEPf95Fb8EJiHXdceoW/9NHWKsEDF/vvF68fnCVF6feoJ3EtbOOqzd0dE9xQoc9V4 mLw=
    =1yrC
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)