Finit v3.1 adds support for reloading /etc/finit.conf, document what
actually is read at runtime, compared to at bootstrap, and clarify
which stanzas are for what part of the boot process.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
The difference between `runparts DIR` and `/etc/rc.local` is that one
should run just before the first runlevel change (to the configured
runlevel) at the end of bootstrap, whereas the other should run just
before launcing the TTYs, i.e. after all tasks in the configured
runlevel have been started.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch is an optimization. Now that we monitor for any .conf file
changes (as soon as the event loop starts) we can skip automatic reload
of all .conf files and services if no .conf file has changed. Unless
the user issues an `initctl reload`, `init q`, or sends us SIGHUP.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
As reported in #92, systems with an udevd very early register a service
using global_rlimit[]. The change was introduced in b68c5c1 but did
not take the ordering problem into consideration, global_rlimit[] was
left uninitialized, which likely led to severely limited udevd that
was continously crashing.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
- Validate function argument
- Skip¹ shutdown() when closing a TCP socket, not needed
___
¹ also, shutdown() segfaults a late shutdown/reboot
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
On shutdown/reboot, send SIGPR as a heads-up to watchdogd that the
system is going down. All file systems are about to be unmounted.
It's just about the last process left running in the system, so we
give it two seconds to complete its work before we continue.
When everything has been unmounted and we're ready to call reboot(),
we send SIGTERM to the registered watchdog, to give ti the chance to
let the WDT reset the system.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
When Finit enters shutdown/reboot we need to advise any watchdogd that
we are going down *before* we unmount any file systems. This to let
the user save any state, e.g. reboot counters, to disk. Right before
we call reboot() in Finit we send SIGTERM to the watchdogd to give it
the chance to use the WDT to reboot the system.
The WDT cricuitry on embedded systems is often connected to the RESETn
logic of all relevant board compoents, whereas reboot() only reboots the
SoC with the CPU. Hence, a WDT reboot is more efficient and more like a
regular power cycle, which users of embedded systems often want.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch makes it possible to control the default redirection of
(misbehaving) services output to /dev/null. With this disabled,
a service may write to its stdout/stderr and mess up the console.
By default all service/run/tasks stdout/stderr is redirected.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch adds a `nologin` flag to the `tty` configuration directive,
making it possible to set up really simple embedded systems with no
login.
Example, put the following line in `/etc/finit.d/getty.conf` to get
a "Please press Enter to ..." prompt before being presented with a
root shell prompt.
tty [12345] @console noclear nologin
Needless to say, this is not very secure, but can be really useful
for developer setups, during board bringup, or similar.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
In f3669c7 the difference between static and dynamic services was
removed. This led to a regression in handling internally created
services for, e.g., dbus-daemon and udevd, mentioned in issue #90.
This patch introduces a "protected" flag for svc_t to prevent the
mark-and-sweep handling of regularly loaded services.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
The new condition triggered hooks requrie /var/run/finit/cond to
be set up before calling the first user-configurable hooks.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
- Add newline to cond generation ID, like PID files, easier when
debugging. Does not affect fscanf() in cond_get_gen()
- Update copyright years
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Until now Finit has used mtime to determine if a file has been changed,
or simply touched to request reload, when `initctl reload` is called.
Using mtime for this purpose is a monumentally bad idea since time can
be changed at any point: a user may adjust the time, NTP continously
tunes the clock, and time stamps are stored as the walltime. So if we
compare timestamps against the last time we (booted or) did reload, we
would miss .conf file changes.
This patch replaces the mtime mistake with an inotify watcher for the
following files: /etc/finit.d/*.conf, /etc/finit.d/available/*.conf,
and /etc/finit.conf. All file changes between (bootstraps and) calls
to `initctl reload` are tracked, like the mtime backend it replaces.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>