Skip to content

init scripts: rewrite S01logging

Carlos Santos buildroot 7 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest4 patches 0 repliesNew
  2. v44 patches 0 repliesSuperseded
  3. v3 posting 3/30 of 8 patches 0 repliesSuperseded
Earlier versions · 4
VersionPostedPatchesRepliesStatus
v3 posting 2/30 of 8 patches0 repliesSuperseded
v3 posting 1/38 patches0 repliesSuperseded
v28 patches0 repliesSuperseded
v18 patches0 repliesSuperseded

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4busybox: rewrite logging init scriptpackage/busybox/S01logging package/busybox/S01syslogd package/busybox/S02klogd +1 more+121 -481 reply
2/4rsyslog: rewrite init scriptpackage/rsyslog/S01logging package/rsyslog/S01rsyslogd package/rsyslog/rsyslog.mk+55 -380 replies
3/4sysklogd: rewrite init scriptpackage/sysklogd/S01logging package/sysklogd/S01syslogd package/sysklogd/S02klogd +1 more+131 -270 replies
4/4syslog-ng: rewrite init scriptpackage/syslog-ng/S01logging package/syslog-ng/S01syslog-ng package/syslog-ng/syslog-ng.mk+64 -400 replies

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchMatt Weber
1/4R-b
2/4R-b
3/4R-b
4/4R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [Buildroot] [PATCH v5 0/4] init scripts: rewrite S01logging

Continuing our effort to improve daemon startup scripts, this series focuses on S01logging, which starts the logging daemon. Common features are:

- Indent with tabs, not spaces.
- Implement start, stop, restart and reload as functions.
- Use start-stop-daemon.
- Correctly detect and report start/stop/restart/reload errors.
- Support a configuration file at /etc/default.
- Use one init script per daemom. Name the script accordding to the daemon it starts (e.g. S01syslogd, S02klogd).

All files implement the following FSM:

                                                  +---------+
             +-------stop--------+   +----(1s)----| stopped |
             |                   |   |            |     |
             |                   |   |            +---------+
             v                   |   v                 ^
      +---------+             +---------+              |
      |         |             |         |----restart---+
      | STOPPED |----start--->| STARTED |
      |         |             |         |----reload----+
      +---------+             +---------+              |
                                     ^                 |
                                     |                 |
                                     +-----------------+

* "stopped" is an intermediary state that transitions to STARTED after one second.

Attempts to do invalid transitions (e.g. start from STARTED state) will fail. That's why we don't pass -o (--oknodo) to start-stop-daemon. This changes the script behavior, in some cases, while in other cases just reports errors that were ignored previously.

The "restart" transition is implemented as "stop, sleep 1, start", so restarting from STOPPED state is possible, although an error message is shown because "stop" fails.

The "reload" transition semantics is "reload the configuration and keep running", when possible, otherwise it is the same as "restart" (in this series, sysklogd and syslog-ng support true "reload" operations).

The scripts were checked with shellcheck v0.5.0:

  $ shellcheck package/*/S0*log*

Carlos Santos (4):
busybox: rewrite logging init script
rsyslog: rewrite init script
sysklogd: rewrite init script
syslog-ng: rewrite init script

 package/busybox/S01logging     | 40 ---------------------
 package/busybox/S01syslogd     | 55 ++++++++++++++++++++++++++++
 package/busybox/S02klogd       | 55 ++++++++++++++++++++++++++++
 package/busybox/busybox.mk     | 19 +++++-----
 package/rsyslog/S01logging     | 36 -------------------
 package/rsyslog/S01rsyslogd    | 53 +++++++++++++++++++++++++++
 package/rsyslog/rsyslog.mk     |  4 +--
 package/sysklogd/S01logging    | 25 -------------
 package/sysklogd/S01syslogd    | 62 ++++++++++++++++++++++++++++++++
 package/sysklogd/S02klogd      | 65 ++++++++++++++++++++++++++++++++++
 package/sysklogd/sysklogd.mk   |  6 ++--
 package/syslog-ng/S01logging   | 38 --------------------
 package/syslog-ng/S01syslog-ng | 62 ++++++++++++++++++++++++++++++++
 package/syslog-ng/syslog-ng.mk |  4 +--
 14 files changed, 371 insertions(+), 153 deletions(-)
 delete mode 100644 package/busybox/S01logging
 create mode 100644 package/busybox/S01syslogd
 create mode 100644 package/busybox/S02klogd
 delete mode 100644 package/rsyslog/S01logging
 create mode 100644 package/rsyslog/S01rsyslogd
 delete mode 100644 package/sysklogd/S01logging
 create mode 100644 package/sysklogd/S01syslogd
 create mode 100644 package/sysklogd/S02klogd
 delete mode 100644 package/syslog-ng/S01logging
 create mode 100644 package/syslog-ng/S01syslog-ng
Signature · 1 line
2.17.1