Commit Graph
3303 Commits
Author SHA1 Message Date
Joachim Wiberg 2dd5fb0f77 test: s6/systemd style services do not necessarily create a PID file
Ensure the test mimics actual real-world scenario where daemons do not
create a PID file at all.

Issue #343.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-15 06:34:05 +01:00
Joachim Wiberg 63044a4b81 test: extend notify.sh with checks for 'restart serv' and 'reload'
Issue #343.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-15 06:34:05 +01:00
Joachim Wiberg 4e74f9783a test: minor fix to 'serv' test service
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-15 06:34:05 +01:00
Joachim Wiberg c3c662fe64 initctl: ensure 'cond get' support flux state
The 'initctl cond' commands were initiallý added to only manage usr
conditions.  Recently the 'cond get' command was expanded to allow
reading general conditions as well.

However, since general conditions support three states the command
returned 'on' for conditions that were in flux.  This patch fixes
that oversight.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-15 06:34:05 +01:00
Joachim Wiberg 7c2764790c Issue #343: READY state lost when service is restarted after crash
The svc_set_state() function not only handles state transitions, it also
makes sure to cancel any outstaing service timeouts.  Before the service
readiness support was added, service conditions were simply a single bit
of information, so clearing its conditions before changing states had no
impact.  With readiness we have multiple bits of information that are
set as conditions.

When restarting a crashing service we set a timeout to retry restarting,
or ensure the service is now running.  This means that the service can
signal READY before RUNNING is reasserted, but the RUNNING state can be
set also by the service state machine, so we need to ensure we do not
re-assert RUNNING if it's already set, and thereby clearing READY.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-15 06:33:55 +01:00
Joachim Wiberg 732d500cf5 Avoid reserved keyword 'new'
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-13 07:50:45 +01:00
Joachim Wiberg 4e1ac726ac Minor, update debug message to align PID output
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-13 07:49:17 +01:00
Joachim Wiberg fba58085c6 test: verify readiness notification on crash/restart
Issue #343 reports that readiness notification on crash/restart is lost.
This update to notify.sh reproduces that bug.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-12 09:03:10 +01:00
Joachim Wiberg d1ebb255c6 initctl: add 'kill' alias to 'signal' command
Principle of least surprise.  When no even the maintainer remembers
the correct command, it is time to add an alias.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-12 09:00:57 +01:00
Joachim Wiberg a39ee0b44d Fix #342: prevent certain commands at bootstrap and shutdown
Over the years there have been multiple cases of invalid and/or unsafe
uses of signals and initctl commands at bootstrap and shutdown.  These
cases cannot be safely supported.  This commit locks down finit a bit
to avoid the most common cases.

If you run into this, please open a new discussion at GitHub and we'll
talk about it.  Maybe I've been overzealous or you have another use-case
that warrants opening up some or parts of the API.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-10 17:18:50 +01:00
Joachim Wiberg 947d91acd5 Minor, whitespace only
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 10:51:12 +01:00
Joachim Wiberg 8c206d52e5 Fix imlicit declaration build warning
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 10:49:32 +01:00
Joachim Wiberg 0f445dc9f4 doc: add missing /etc/finit.d and fix indendation (untabify)
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 10:38:14 +01:00
Joachim Wiberg c71b35e61a doc: document recommended filesystem layout + automounter
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 10:00:43 +01:00
Joachim Wiberg d20308b7d7 Follow-up to e4e54a8: spellcheck hook name
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 09:08:33 +01:00
Joachim Wiberg e4e54a88d9 Adjust boundaries for when conditions are allowed
Not until fs_mount_all() has completed do we have /run, or /var/run, and
never after shutdown has been initiated.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 09:00:35 +01:00
Joachim Wiberg 308b7c5197 Follow-up to #338: return early if conditions are not available
As pointed out by Jack Newman in issue #338, when conditions are not
available (at boot before cond_init(), or shutdown when /var or /var/run
have been unmounted) we should not try to create any conditions.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 08:17:09 +01:00
Joachim Wiberg 89772bf6c0 Merge pull request #338 from JackNewman12/shutdown-hook-fix
Fix shutdown hooks not running

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 08:08:32 +01:00
Joachim Wiberg 077002e647 doc: follow-up to 02a110e, rename new section, add list of runlevels
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 07:07:18 +01:00
Joachim Wiberg 988cdf9878 Merge pull request #341 from troglobit/reboot-delay
Add support for optional reboot delay

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-09 06:25:45 +01:00
Joachim Wiberg 97db2078f5 Follow-up, spell check
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-08 14:19:09 +01:00
Joachim Wiberg 02a110e6c2 Fix #336: update main config.md Introduction with new .conf overview
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-08 14:18:30 +01:00
Joachim Wiberg 681ef8de6f doc: minor, styling
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-08 14:18:30 +01:00
Joachim Wiberg 0147e0e64f Minor, ensure pointer is legit in --enable-static mode
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-08 14:18:30 +01:00
Joachim Wiberg 311c6be9aa Add support for optional reboot delay
Slightly different take on issue #334 making it optional, possible to
enable per system.

    reboot-delay <0-60>           # default: 0 (disabled)

When enabled (non-zero), runs after filesystems have been unmounted,
the root filesystems has been remounted read-only, and sync(2) has
been called, twice.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-08 09:37:19 +01:00
Joachim Wiberg c22d123ab0 plugins: sys.so and usr.so must run after bootmisc
The bootmisc plugin sets up the base path for finit and figures out if
the system has /run or /var/run -- needed by the other plugins.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 18:07:40 +01:00
Joachim Wiberg 96b5991355 .github: ::set-output is deprecated
https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 18:04:45 +01:00
Joachim Wiberg 06bd352863 .github: fix missing quote
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 17:59:47 +01:00
Joachim Wiberg a918f7497a .github: revise weekly check
For details, see https://stackoverflow.com/a/67527144/1708249

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 17:56:42 +01:00
Joachim Wiberg 8bbae3d414 plugins: ensure /var/run/finit/cond exists
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 17:42:49 +01:00
Joachim Wiberg bfd1f36fdd .github: spellcheck yaml
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 17:26:08 +01:00
Joachim Wiberg 6fc702a560 .github: enable manual trigger as well
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 17:24:45 +01:00
Joachim Wiberg 40dcc5541b .github: split build in a regular build+test and weekly distcheck
This to save time during regular pushes and pull requests, the tests
run from distcheck take a long time, and they're not getting fewer.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 17:19:33 +01:00
Joachim Wiberg 5b41c6e327 HOOK_BASEFS_UP must run as soon as all filesystems are mounted
At this hook point the bootmisc.so plugin runs and creates all relevant
system directories.  Much of the rest of system bootstrap relies on this
so it should be called together with the other FS hooks as soon as all
the filesystems have been mounted.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 15:09:50 +01:00
Joachim Wiberg 4bd81b4d4c conf_saverc: enaure /var/run/finit exists first
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 15:08:58 +01:00
Joachim Wiberg c29589c2ca initctl: add support for --json to list command
This allows for easy access to the *disabled* services:

    root@anarchy:~# initctl ls --json |jq '.available - .enabled'
    [
      "chronyd.conf",
      "dnsmasq.conf",
      "gdbserver.conf",
      "inadyn.conf",
      "inetd.conf",
      "isisd.conf",
      "lldpd.conf",
      "mstpd.conf",
      "ntpd.conf",
      "ospf6d.conf",
      "ospfd.conf",
      "querierd.conf",
      "ripd.conf",
      "ripng.conf",
      "sshd.conf",
      "syslogd.conf",
      "telnetd.conf",
      "uftpd.conf",
      "wpa_supplicant.conf",
      "zebra.conf"
    ]

As discussed in PR issue #335

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 14:00:28 +01:00
Joachim Wiberg 73b89430e4 Fix #340: Finit ignores deleted/moved .conf files in /etc/finit.d
Works locally with/without this patch, but I cannot understand why it
would ever be needed in the first place, so removing.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 14:00:28 +01:00
Joachim Wiberg 2a62fa3d85 Fix #329: add support for multiple args to initctl cond set/clr
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 14:00:16 +01:00
Joachim Wiberg 4542fdb5bb Fix #339: use absolute path in enabled symlinks
When the /etc/finit.d/enabled directory is a symlink elsehwere, e.g.,
/var/finit.d/enabled, a relative symlink will not work.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 11:30:46 +01:00
Joachim Wiberg 525aaf1f66 plugins: s/Initializing/Seeding/ better choice of words
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 09:43:27 +01:00
Joachim Wiberg 910dac5f3a Merge pull request #337 from JackNewman12/autoreload-fix
Fix AUTO_RELOAD #define typo

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-07 09:31:57 +01:00
Jack Newman 2a5c319084 Fix shutdown hooks not running
sig.c was calling plugin_run_hooks for the shutdown hooks, but the
shutdown hooks do not have registered callbacks in hook-scripts.c

Instead directly call plugin_script_run()
2023-01-06 10:29:58 +10:00
Jack 612f4fe288 Merge branch 'troglobit:master' into autoreload-fix 2023-01-06 10:00:03 +10:00
Jack Newman c058c05651 Fix AUTO_RELOAD typo 2023-01-05 09:00:51 +10:00
Joachim Wiberg 0de4578e50 Merge pull request #333 from JackNewman12/config-reload
Mark service dirty if the command line args have changed

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-04 17:00:29 +01:00
Jack Newman b9e94e4695 Consider a service dirty if the command line args have changed
This fixes `initctl reload` correctly restarting all daemons that have new
command line arguments.

Previously command line arguments changes were only acted upon if the
service was explicitly reloaded `initctl reload myservice`.
2023-01-04 13:31:41 +10:00
Joachim Wiberg 9887003b25 doc: clarify and fix confusing pid:/run/bar.pid example
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-02 00:30:19 +01:00
Joachim Wiberg f6bfbc86e9 Drop mdevd plugin, not needed since notify:s6 support was added
For an example how to set it up, see the finit-skel repository:

https://github.com/troglobit/finit-skel/blob/main/skel/etc/finit.d/available/mdevd.conf

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-12-21 11:57:48 +01:00
Joachim Wiberg 4c90b51d80 doc: update conditions wrt new devmon plugin
Issue #185

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-12-20 14:08:03 +01:00
Joachim Wiberg 48cfbfe5ed Follow-up to 685e0a80, drop extra snprintf() args
Issue #332

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-12-20 13:35:19 +01:00