mirror of
https://github.com/troglobit/finit.git
synced 2026-10-12 10:12:32 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d9b6b5201 | ||
|
|
c0b74c5e53 | ||
|
|
88a6864fd4 | ||
|
|
2b2c6aaf4e | ||
|
|
8ed37f5fa0 | ||
|
|
8fe4aad53e | ||
|
|
54e5fd2a78 | ||
|
|
1d6737eac1 | ||
|
|
fa0c2f7050 | ||
|
|
70c0a38307 | ||
|
|
217df432d6 | ||
|
|
cfa97253be | ||
|
|
6462bac249 | ||
|
|
b0a1d6bd61 | ||
|
|
ee4768ba53 | ||
|
|
c7c0c723d6 | ||
|
|
b7c1a2a198 | ||
|
|
af45166814 | ||
|
|
1a881389b2 | ||
|
|
6306c757a2 | ||
|
|
3865ce765e | ||
|
|
aa08221666 | ||
|
|
7c8b0df720 | ||
|
|
cb802cd54e |
@@ -76,4 +76,4 @@ Bill & Ted; [be excellent to each other][conduct].
|
||||
[github]: https://github.com/troglobit/finit/
|
||||
[KNF]: https://en.wikipedia.org/wiki/Kernel_Normal_Form
|
||||
[gitbook]: https://git-scm.com/book/ch5-2.html
|
||||
[conduct]: https://github.com/troglobit/finit/blob/master/CODE-OF-CONDUCT.md
|
||||
[conduct]: CODE-OF-CONDUCT.md
|
||||
+18
-3
@@ -20,7 +20,7 @@ Bug fix release, but also cgroups and a new progress!
|
||||
* Support for tracking custom PID files, using `pid:!/path/to/foo.pid`,
|
||||
useful with new `sysv` or `service` which fork to background
|
||||
* Support starting run/task/services without absolute path, trust `$PATH`
|
||||
* Add support for `--disable-docs` and `--disable-contrib` to speed up
|
||||
* Add support for `--disable-doc` and `--disable-contrib` to speed up
|
||||
builds and work around issue with massively parallel builds
|
||||
* Add support for `@console` also for external getty
|
||||
* Add `-b`, batch mode, for non-interactive use to `initctl`
|
||||
@@ -58,6 +58,19 @@ Bug fix release, but also cgroups and a new progress!
|
||||
can be enabled with `./configure --enable-auto-reload`
|
||||
* Support for logging security related events, e.g., runlevel change,
|
||||
star/stop or failure to start services, by Jonas Holmberg, Westermo
|
||||
* Mount devtpts with recommended `ptxmode=0666`
|
||||
* Mount /run tmpfs with nosuid,nodev,noexec for added security
|
||||
* Support for `console` as alias for `@console` in tty stanzas
|
||||
* Drop `--enable-rw-roots` configure option, use `rw` for your `/`
|
||||
partition in `/etc/fstab` instead to trigger remount at boot
|
||||
* Drop default tty speed (38400) and use 0 (kernel default) instead
|
||||
* Make `:ID` optional for real, use NULL/zero internally and only
|
||||
force :ID (numbered) for inetd services, this allows ...
|
||||
* Handle use-cases where multiple services share the same PID filem
|
||||
and thus the same condition path, e.g. different instances for
|
||||
different runlevels. Allow custom condition path with `name:foo`
|
||||
syntax, creates conditions w/o a path, and ...
|
||||
* Always append `:ID` qualifier to conditions if set for a service
|
||||
|
||||
### Fixes
|
||||
|
||||
@@ -109,6 +122,8 @@ Bug fix release, but also cgroups and a new progress!
|
||||
* Restore Ctrl-D and Ctrl-U support in built-in getty
|
||||
* Remove service condition when service is deleted
|
||||
* Fix C++ compilation issues, by Robert Andersson, Atlas Copco
|
||||
* Build fixes for uClibc
|
||||
* Provide service description for built-in watchdog daemon
|
||||
|
||||
|
||||
[3.1][] - 2018-01-23
|
||||
@@ -183,7 +198,7 @@ This version requires at least libuEv v2.1.0 and libite v2.0.1
|
||||
possibility of running a second stage mount command before files in
|
||||
`/run` and similar are created
|
||||
* Skip `gdbserver` when unleashing the grim reaper at shutdown
|
||||
* Distribute and install `docs/` and `contrib/` directories
|
||||
* Distribute and install `doc/` and `contrib/` directories
|
||||
|
||||
### Fixes
|
||||
|
||||
@@ -246,7 +261,7 @@ distributions.
|
||||
* Ensure plugins always have a default name, file name
|
||||
* Reorganization, move all source files to a `src/` sub-directory
|
||||
* Add support for `initctl <list|enable|disable> <SVC>`, much needed by
|
||||
distributions. See [docs/distro.md](docs/distro.md) for details
|
||||
distributions. See [doc/distro.md](doc/distro.md) for details
|
||||
* Remove `UNUSED()` macro, mentioned here because it may have been used
|
||||
by external plugin developers. Set `-Wno-unused-parameter` instead
|
||||
* New table headings in `initctl`, using `top` style inverted text
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@ EXTRA_DIST = README.md LICENSE ChangeLog.md contrib/finit.conf
|
||||
if CONTRIB
|
||||
SUBDIRS += contrib
|
||||
endif
|
||||
if DOCS
|
||||
SUBDIRS += docs
|
||||
if DOC
|
||||
SUBDIRS += doc
|
||||
endif
|
||||
|
||||
# Compat hook
|
||||
|
||||
@@ -3,19 +3,19 @@
|
||||
|
||||
* [Introduction](#introduction)
|
||||
* [Features](#features)
|
||||
* [Bootstrap](docs/bootstrap.md#bootstrap)
|
||||
* [Bootstrap](doc/bootstrap.md#bootstrap)
|
||||
* [Runlevels](#runlevels)
|
||||
* [Syntax](docs/config.md#syntax)
|
||||
* [Inetd](docs/inetd.md#inetd)
|
||||
* [Syntax](doc/config.md#syntax)
|
||||
* [Inetd](doc/inetd.md#inetd)
|
||||
* [Runparts & /etc/rc.local](#runparts--etcrclocal)
|
||||
* [Hooks, Callbacks & Plugins](docs/plugins.md#hooks-callbacks--plugins)
|
||||
* [Hooks, Callbacks & Plugins](doc/plugins.md#hooks-callbacks--plugins)
|
||||
* [Rebooting & Halting](#rebooting--halting)
|
||||
* [Commands & Status](#commands--status)
|
||||
* [Tips & Tricks with the kernel cmdline](docs/cmdline.md)
|
||||
* [Building](docs/build.md#building)
|
||||
* [Running](docs/build.md#running)
|
||||
* [Recovery](docs/build.md#recovery)
|
||||
* [Debugging](docs/build.md#debugging)
|
||||
* [Tips & Tricks with the kernel cmdline](doc/cmdline.md)
|
||||
* [Building](doc/build.md#building)
|
||||
* [Running](doc/build.md#running)
|
||||
* [Recovery](doc/build.md#recovery)
|
||||
* [Debugging](doc/build.md#debugging)
|
||||
* [Requirements](#requirements)
|
||||
* [Origin & References](#origin--references)
|
||||
|
||||
@@ -95,21 +95,21 @@ inetd ssh/tcp@*,!eth0 nowait [2345] /sbin/dropbear -i -R -F -- SSH service
|
||||
# Run start scripts from this directory
|
||||
# runparts /etc/start.d
|
||||
|
||||
# Virtual consoles run BusyBox getty
|
||||
tty [12345] /sbin/getty -L 115200 /dev/tty1 linux
|
||||
tty [12345] /sbin/getty -L 115200 /dev/tty2 linux
|
||||
tty [12345] /sbin/getty -L 115200 /dev/tty3 linux
|
||||
# Virtual consoles run BusyBox getty, keep kernel default speed
|
||||
tty [12345] /sbin/getty -L 0 /dev/tty1 linux
|
||||
tty [12345] /sbin/getty -L 0 /dev/tty2 linux
|
||||
tty [12345] /sbin/getty -L 0 /dev/tty3 linux
|
||||
|
||||
# Use built-in getty for serial port and USB serial
|
||||
tty [12345] /dev/ttyAMA0 115200 noclear nowait
|
||||
tty [12345] /dev/ttyUSB0 115200 noclear
|
||||
tty [12345] /dev/ttyAMA0 noclear nowait
|
||||
tty [12345] /dev/ttyUSB0 noclear
|
||||
|
||||
# Just give me a shell, I need to debug this embedded system!
|
||||
tty [12345] @console noclear nologin
|
||||
```
|
||||
|
||||
The `service` stanza, as well as `task`, `run`, `inetd` and others are
|
||||
described in full in [docs/config.md](docs/config.md). Here's a quick
|
||||
described in full in [doc/config.md](doc/config.md). Here's a quick
|
||||
overview of some of the most common components needed to start a UNIX
|
||||
daemon:
|
||||
|
||||
@@ -130,7 +130,7 @@ advanced uses as well:
|
||||
|
||||
service /usr/sbin/sshd -D
|
||||
|
||||
Dependencies are handled using [conditions](docs/conditions.md). One of
|
||||
Dependencies are handled using [conditions](doc/conditions.md). One of
|
||||
the most common conditions is to wait for basic networking to become
|
||||
available:
|
||||
|
||||
@@ -171,7 +171,7 @@ Start, monitor and restart services should they fail.
|
||||
|
||||
**Inetd**
|
||||
|
||||
Finit comes with a built-in [inetd server](docs/inetd.md). No need to
|
||||
Finit comes with a built-in [inetd server](doc/inetd.md). No need to
|
||||
maintain a separate config file for services that you want to start on
|
||||
demand.
|
||||
|
||||
@@ -186,7 +186,7 @@ Built-in optional inetd services:
|
||||
- discard [RFC863][]
|
||||
- time (rdate) [RFC868][]
|
||||
|
||||
For more information, see [docs/inetd.md](docs/inetd.md).
|
||||
For more information, see [doc/inetd.md](doc/inetd.md).
|
||||
|
||||
|
||||
**Getty**
|
||||
@@ -197,9 +197,9 @@ waits for user input before handing over to `/bin/login`, which is
|
||||
responsible for handling the actual authentication.
|
||||
|
||||
```conf
|
||||
tty [12345] /dev/tty1 38400 nowait linux
|
||||
tty [12345] /dev/ttyAMA0 115200 noclear vt100
|
||||
tty [12345] /sbin/getty -L 115200 /dev/ttyAMA0 vt100
|
||||
tty [12345] /dev/tty1 nowait linux
|
||||
tty [12345] /dev/ttyAMA0 noclear vt100
|
||||
tty [12345] /sbin/getty -L /dev/ttyAMA0 vt100
|
||||
```
|
||||
|
||||
Users of embedded systems may want to enable automatic serial console
|
||||
@@ -208,12 +208,12 @@ system uses `ttyS0`, `ttyAMA0`, `ttyMXC0`, or anything else. Finit
|
||||
figures it out by querying sysfs: `/sys/class/tty/console/active`.
|
||||
|
||||
```conf
|
||||
tty [12345] @console 115200 linux noclear
|
||||
tty [12345] @console linux noclear
|
||||
```
|
||||
|
||||
Notice the optional `noclear`, `nowait`, and `nologin` flags. The
|
||||
latter is for skipping the login process entirely. For more information,
|
||||
see [docs/config.md](docs/config.md#syntax).
|
||||
see [doc/config.md](doc/config.md#syntax).
|
||||
|
||||
|
||||
**Runlevels**
|
||||
@@ -258,7 +258,7 @@ Extensions and functionality not purely related to what an `/sbin/init`
|
||||
needs to start a system are available as a set of plugins that either
|
||||
hook into the boot process or respond to various I/O.
|
||||
|
||||
For more information, see [docs/plugins.md](docs/plugins.md).
|
||||
For more information, see [doc/plugins.md](doc/plugins.md).
|
||||
|
||||
|
||||
**Progress**
|
||||
@@ -277,7 +277,7 @@ append="init=/sbin/finit splash"
|
||||
|
||||
For a really nice boot, add `quiet` as well. This silences the output
|
||||
from the kernel, leaving only warnings and errors. For other kernel
|
||||
command line parameters, see [docs/build.md](docs/build.md#recovery).
|
||||
command line parameters, see [doc/build.md](doc/build.md#recovery).
|
||||
|
||||
|
||||
**Automatic Reload**
|
||||
@@ -313,8 +313,8 @@ Right after the runlevel change when all services have started properly,
|
||||
No configuration stanza in `/etc/finit.conf` is required for `rc.local`.
|
||||
If it exists and is an executable shell script Finit calls it at the very
|
||||
end of the boot, before calling the `HOOK_SYSTEM_UP`. See more on hooks
|
||||
in [docs/plugins.md](docs/plugins.md#hooks), and about the system bootstrap
|
||||
in [docs/bootstrap.md](docs/bootstrap.md).
|
||||
in [doc/plugins.md](doc/plugins.md#hooks), and about the system bootstrap
|
||||
in [doc/bootstrap.md](doc/bootstrap.md).
|
||||
|
||||
|
||||
Runlevels
|
||||
@@ -392,7 +392,7 @@ section.
|
||||
For compatibility reasons Finit listens to the same set of signals as
|
||||
BusyBox init. This is not 100% compatible with SysV init, but clearly
|
||||
the more common combination for Finit. For more details, see
|
||||
[docs/signals.md](docs/signals.md).
|
||||
[doc/signals.md](doc/signals.md).
|
||||
|
||||
Finit also listens to the classic SysV init FIFO, used by `telinit`.
|
||||
Support for this is implemented by the `initctl.so` plugin. Hence,
|
||||
@@ -463,7 +463,7 @@ Commands:
|
||||
|
||||
For services *not* supporting `SIGHUP` the `<!>` notation in the .conf
|
||||
file must be used to tell Finit to stop and start it on `reload` and
|
||||
`runlevel` changes. If `<>` holds more [conditions](docs/conditions.md),
|
||||
`runlevel` changes. If `<>` holds more [conditions](doc/conditions.md),
|
||||
these will also affect how a service is maintained.
|
||||
|
||||
**Note:** even though it is possible to start services not belonging in
|
||||
|
||||
+7
-15
@@ -1,4 +1,4 @@
|
||||
AC_INIT(Finit, 3.2-rc2, https://github.com/troglobit/finit/issues, finit, http://troglobit.com/finit.html)
|
||||
AC_INIT(Finit, 3.2-rc3, https://github.com/troglobit/finit/issues, finit, https://troglobit.com/finit.html)
|
||||
AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz subdir-objects])
|
||||
AM_SILENT_RULES([yes])
|
||||
|
||||
@@ -9,7 +9,7 @@ AC_CONFIG_FILES([Makefile
|
||||
contrib/alpine/Makefile contrib/alpine/finit.d/Makefile contrib/alpine/finit.d/available/Makefile
|
||||
contrib/debian/Makefile contrib/debian/finit.d/Makefile contrib/debian/finit.d/available/Makefile contrib/debian/grub.d/Makefile
|
||||
contrib/void/Makefile contrib/void/finit.d/Makefile contrib/void/finit.d/available/Makefile
|
||||
docs/Makefile
|
||||
doc/Makefile
|
||||
plugins/Makefile
|
||||
src/Makefile])
|
||||
|
||||
@@ -61,10 +61,6 @@ AC_ARG_ENABLE(auto_reload,
|
||||
AS_HELP_STRING([--enable-auto-reload], [Automatic reload on any .conf change]),,[
|
||||
enable_auto_reload=no])
|
||||
|
||||
AC_ARG_ENABLE(rw-rootfs,
|
||||
AS_HELP_STRING([--enable-rw-rootfs], [Remount / R/W at boot, usually not for embedded]),,[
|
||||
enable_rw_rootfs=no])
|
||||
|
||||
AC_ARG_ENABLE(progress,
|
||||
AS_HELP_STRING([--enable-progress], [Modern progress display at bootup]),,[
|
||||
enable_progress=no])
|
||||
@@ -93,9 +89,9 @@ AC_ARG_ENABLE(logrotate,
|
||||
AS_HELP_STRING([--disable-logrotate], [Disable built-in rotation of /var/log/wtmp, default enabled]),,[
|
||||
enable_logrotate=yes])
|
||||
|
||||
AC_ARG_ENABLE(docs,
|
||||
AS_HELP_STRING([--disable-docs], [Disable build and install of docs section]),,[
|
||||
enable_docs=yes])
|
||||
AC_ARG_ENABLE(doc,
|
||||
AS_HELP_STRING([--disable-doc], [Disable build and install of doc/ section]),,[
|
||||
enable_doc=yes])
|
||||
|
||||
AC_ARG_ENABLE(contrib,
|
||||
AS_HELP_STRING([--disable-contrib], [Disable build and install of contrib section]),,[
|
||||
@@ -164,9 +160,6 @@ AS_IF([test "x$enable_fallback_shell" = "xyes"], [
|
||||
AS_IF([test "x$enable_auto_reload" = "xyes"], [
|
||||
AC_DEFINE(AUTO_RELOAD, 1, [Finit automatically does `initctl reload` on any .conf change])])
|
||||
|
||||
AS_IF([test "x$enable_rw_rootfs" = "xyes"], [
|
||||
AC_DEFINE(REMOUNT_ROOTFS, 1, [Remount / as rw at boot])])
|
||||
|
||||
AS_IF([test "x$enable_progress" = "xyes"], [
|
||||
AC_DEFINE(PROGRESS_STYLE, 2, [Modern bootup messages, systemd inspired])])
|
||||
|
||||
@@ -253,7 +246,7 @@ AM_CONDITIONAL(STATIC, [test "x$enable_static" = "xyes"])
|
||||
AM_CONDITIONAL(INETD, [test "x$enable_inetd" = "xyes"])
|
||||
AM_CONDITIONAL(WATCHDOGD, [test "x$enable_watchdog" = "xyes"])
|
||||
AM_CONDITIONAL(LOGIT, [test "x$enable_logit" = "xyes"])
|
||||
AM_CONDITIONAL(DOCS, [test "x$enable_docs" = "xyes"])
|
||||
AM_CONDITIONAL(DOC, [test "x$enable_doc" = "xyes"])
|
||||
AM_CONDITIONAL(CONTRIB, [test "x$enable_contrib" = "xyes"])
|
||||
|
||||
# Override default libdir, used for plugins and rescue.conf
|
||||
@@ -293,7 +286,7 @@ Behavior:
|
||||
Plugins...............: $plugins
|
||||
|
||||
Optional features:
|
||||
Install docs/.........: $enable_docs
|
||||
Install doc/..........: $enable_doc
|
||||
Install contrib/......: $enable_contrib
|
||||
Built-in inetd........: $enable_inetd
|
||||
Built-in watchdogd....: $enable_watchdog
|
||||
@@ -301,7 +294,6 @@ Optional features:
|
||||
Scripting tool logit..: $enable_logit
|
||||
Emergency shell.......: $enable_emergency_shell
|
||||
Fallback shell........: $enable_fallback_shell
|
||||
Remount / RW at boot..: $enable_rw_rootfs
|
||||
Modern progress.......: $enable_progress
|
||||
Classic progress......: $enable_progress_classic
|
||||
Default console dev...: $console
|
||||
|
||||
@@ -14,7 +14,7 @@ fi
|
||||
# The plugins are optional, but you may need D-Bus and X11 if you want
|
||||
# to run X-Window, the other configure flags are however required.
|
||||
PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig ./configure \
|
||||
--enable-rw-rootfs --enable-progress \
|
||||
--enable-progress \
|
||||
--enable-dbus-plugin --enable-x11-common-plugin \
|
||||
--enable-alsa-utils-plugin --enable-inetd-echo-plugin \
|
||||
--enable-inetd-chargen-plugin --enable-inetd-daytime-plugin \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Consoles to start getty on when system is up
|
||||
tty /dev/tty1 noclear nowait
|
||||
tty /dev/tty2 noclear nowait
|
||||
tty /dev/tty3 noclear nowait
|
||||
tty [12345] /dev/tty1 noclear nowait
|
||||
tty [2345] /dev/tty2 noclear nowait
|
||||
tty [2345] /dev/tty3 noclear nowait
|
||||
|
||||
@@ -22,7 +22,7 @@ echo
|
||||
# The plugins are optional, but you may need D-Bus and X11 if you want
|
||||
# to run X-Window, the other configure flags are however required.
|
||||
./configure \
|
||||
--enable-rw-rootfs --enable-progress \
|
||||
--enable-progress \
|
||||
--enable-dbus-plugin --enable-x11-common-plugin \
|
||||
--enable-alsa-utils-plugin --enable-inetd-echo-plugin \
|
||||
--enable-inetd-chargen-plugin --enable-inetd-daytime-plugin \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Consoles to start getty on when system is up
|
||||
tty [12345] /dev/tty1 115200 vt100 noclear nowait
|
||||
tty [2345] /dev/tty2 38400 linux noclear nowait
|
||||
tty [2345] /dev/tty3 38400 linux noclear nowait
|
||||
tty [12345] /dev/tty1 linux noclear nowait
|
||||
tty [2345] /dev/tty2 linux noclear nowait
|
||||
tty [2345] /dev/tty3 linux noclear nowait
|
||||
|
||||
@@ -14,7 +14,7 @@ fi
|
||||
# The plugins are optional, but you may need D-Bus and X11 if you want
|
||||
# to run X-Window, the other configure flags are however required.
|
||||
PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig ./configure \
|
||||
--enable-rw-rootfs --enable-progress \
|
||||
--enable-progress \
|
||||
--enable-dbus-plugin --enable-x11-common-plugin \
|
||||
--enable-alsa-utils-plugin --enable-inetd-echo-plugin \
|
||||
--enable-inetd-chargen-plugin --enable-inetd-daytime-plugin \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Consoles to start Finit built-in getty on when system is up
|
||||
tty /dev/tty1 noclear nowait
|
||||
tty /dev/tty2 noclear nowait
|
||||
tty /dev/tty3 noclear nowait
|
||||
tty [12345] /dev/tty1 noclear nowait
|
||||
tty [2345] /dev/tty2 noclear nowait
|
||||
tty [2345] /dev/tty3 noclear nowait
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
docsdir := @docdir@/docs
|
||||
docsdir := @docdir@/doc
|
||||
docs_DATA = config.md conditions.md distro.md inetd.md plugins.md \
|
||||
service.md signals.md svc-machine.png cmdline.md
|
||||
EXTRA_DIST = $(docs_DATA)
|
||||
@@ -12,7 +12,7 @@ Bootstrap
|
||||
9. Parse `/etc/finit.conf` and all `/etc/finit.d/*.conf` files
|
||||
10. Start built-in watchdog, if enabled
|
||||
11. Set hostname
|
||||
12. Pivot root, or remount `/` read-write, depending on system type
|
||||
12. Remount `/` read-write if `/` is listed in `/etc/fstab` without `ro`
|
||||
13. Call 1st level hooks, `HOOK_ROOTFS_UP`
|
||||
14. Mount all file systems listed in `/etc/fstab` and swap, if available
|
||||
15. Enable SysV init signals
|
||||
@@ -40,11 +40,6 @@ Below are a few of the main switches to configure:
|
||||
|
||||
* `--disable-inetd`: Disable the built-in inetd server.
|
||||
|
||||
* `--enable-rw-rootfs`: Most desktop and server systems boot with the
|
||||
root file stystem read-only. With this setting Finit will remount it
|
||||
as read-write early at boot so the `bootmisc.so` plugin can run.
|
||||
Usually not needed on embedded systems.
|
||||
|
||||
* `--enable-static`: Build Finit statically. The plugins will be
|
||||
built-ins (.o files) and all external libraries, except the C library
|
||||
will be linked statically.
|
||||
@@ -73,7 +68,7 @@ First, unpack the archive:
|
||||
Then configure, build and install:
|
||||
|
||||
```shell
|
||||
$ ./configure --enable-rw-rootfs --enable-inetd-echo-plugin \
|
||||
$ ./configure --enable-inetd-echo-plugin \
|
||||
--enable-inetd-chargen-plugin --enable-inetd-daytime-plugin \
|
||||
--enable-inetd-discard-plugin --enable-inetd-time-plugin \
|
||||
--with-heading="Alpine Linux 3.4" --with-hostname=alpine
|
||||
@@ -301,8 +301,9 @@ Syntax
|
||||
`tty [LVLS] <CMD> <ARGS> [noclear] [nowait]`
|
||||
The first variant of this option uses the built-in getty on the given
|
||||
TTY device DEV, in the given runlevels. The DEV may be the special
|
||||
keyword `@console`, which is very useful on embedded systems. Default
|
||||
baud rate is `38400`.
|
||||
keyword `@console`, or `console`, useful on embedded systems.
|
||||
|
||||
The default baud rate is 0, i.e., keep kernel default.
|
||||
|
||||
**Example:**
|
||||
```conf
|
||||
@@ -340,11 +341,12 @@ Syntax
|
||||
Embedded systems may want to enable automatic `DEV` by supplying the
|
||||
special `@console` device. This works regardless weather the system
|
||||
uses `ttyS0`, `ttyAMA0`, `ttyMXC0`, or anything else. Finit figures
|
||||
it out by querying sysfs: `/sys/class/tty/console/active`.
|
||||
it out by querying sysfs: `/sys/class/tty/console/active`. The speed
|
||||
can be omitted to keep the kernel default.
|
||||
|
||||
**Example:**
|
||||
```conf
|
||||
tty [12345] @console 115200 noclear vt220
|
||||
tty [12345] @console noclear vt220
|
||||
```
|
||||
|
||||
On really bare bones systems Finit offers a fallback shell, which
|
||||
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
+11
-8
@@ -103,19 +103,22 @@ static int watcher_del(struct context *ctx, struct wd_entry *wde)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void update_conds(char *name, uint32_t mask)
|
||||
static void update_conds(char *dir, char *name, uint32_t mask)
|
||||
{
|
||||
svc_t *svc;
|
||||
char cond[MAX_COND_LEN];
|
||||
char fn[PATH_MAX];
|
||||
svc_t *svc;
|
||||
|
||||
_d("name: %s", name);
|
||||
svc = svc_find_by_pidfile(name);
|
||||
_d("Got dir: %s, name: %s, mask: %08x", dir, name, mask);
|
||||
snprintf(fn, sizeof(fn), "%s/%s", dir, name);
|
||||
|
||||
svc = svc_find_by_pidfile(fn);
|
||||
if (!svc) {
|
||||
_d("pidfile: No matching svc for %s", name);
|
||||
_d("pidfile: No matching svc for %s", fn);
|
||||
return;
|
||||
}
|
||||
|
||||
_d("Event %s for svc %s", name, svc->cmd);
|
||||
_d("pidfile: Found svc %s for %s with pid %d", svc->name, fn, svc->pid);
|
||||
|
||||
mkcond(svc, cond, sizeof(cond));
|
||||
if (mask & (IN_CREATE | IN_ATTRIB | IN_MODIFY | IN_MOVED_TO)) {
|
||||
@@ -154,7 +157,7 @@ static void scan_for_pidfiles(struct context *ctx, char *dir, int len)
|
||||
|
||||
for (i = 0; i < gl.gl_pathc; i++) {
|
||||
_d("scan found %s", gl.gl_pathv[i]);
|
||||
update_conds(gl.gl_pathv[i], IN_CREATE);
|
||||
update_conds(dir, gl.gl_pathv[i], IN_CREATE);
|
||||
}
|
||||
globfree(&gl);
|
||||
}
|
||||
@@ -246,7 +249,7 @@ static void pidfile_callback(void *arg, int fd, int events)
|
||||
}
|
||||
|
||||
if (ev->mask & (IN_CREATE | IN_ATTRIB | IN_MODIFY | IN_MOVED_TO))
|
||||
update_conds(ev->name, ev->mask);
|
||||
update_conds(wde->path, ev->name, ev->mask);
|
||||
}
|
||||
done:
|
||||
free(buf);
|
||||
|
||||
+22
-4
@@ -59,15 +59,21 @@ char *mkcond(svc_t *svc, char *buf, size_t len)
|
||||
{
|
||||
char path[256];
|
||||
char *pidfile;
|
||||
char *ptr;
|
||||
char *ptr, *nm;
|
||||
|
||||
strlcpy(path, svc->cmd, sizeof(path));
|
||||
ptr = rindex(path, '/');
|
||||
if (ptr)
|
||||
*ptr = 0;
|
||||
*ptr++ = 0;
|
||||
else
|
||||
path[0] = 0;
|
||||
|
||||
/* Figure out default name used when registering service */
|
||||
if (ptr)
|
||||
nm = ptr;
|
||||
else
|
||||
nm = svc->cmd;
|
||||
|
||||
pidfile = pid_file(svc);
|
||||
ptr = strstr(pidfile, "run");
|
||||
if (ptr)
|
||||
@@ -75,8 +81,14 @@ char *mkcond(svc_t *svc, char *buf, size_t len)
|
||||
else
|
||||
ptr = rindex(pidfile, '/');
|
||||
|
||||
snprintf(buf, len, "svc%s%s%s", path[0] != 0 && path[0] != '/' ? "/" : "", path, ptr);
|
||||
_d("Composed condition from cmd %s (path %s) and pidfile %s => %s", svc->cmd, path, ptr, buf);
|
||||
/* Custom name:foo declaration found => svc/foo instead of /svc/bin/path/pidfile-.pid */
|
||||
if (strcmp(nm, svc->name)) {
|
||||
snprintf(buf, len, "svc/%s", svc->name);
|
||||
_d("Composed condition from svc->name %s => %s", svc->name, buf);
|
||||
} else {
|
||||
snprintf(buf, len, "svc%s%s%s", path[0] != 0 && path[0] != '/' ? "/" : "", path, ptr);
|
||||
_d("Composed condition from cmd %s (path %s) and pidfile %s => %s", svc->cmd, path, ptr, buf);
|
||||
}
|
||||
|
||||
/* Case: /var/run/dbus/pid */
|
||||
ptr = strstr(buf, "/pid");
|
||||
@@ -88,6 +100,12 @@ char *mkcond(svc_t *svc, char *buf, size_t len)
|
||||
if (ptr && !strcmp(ptr, ".pid"))
|
||||
*ptr = 0;
|
||||
|
||||
/* Always append /ID if service is declared with :ID */
|
||||
if (svc->id[0]) {
|
||||
strlcat(buf, "/", len);
|
||||
strlcat(buf, svc->id, len);
|
||||
}
|
||||
|
||||
_d("Creating condition => %s", buf);
|
||||
|
||||
return buf;
|
||||
|
||||
+5
-7
@@ -369,15 +369,12 @@ pid_t run_getty(char *tty, char *baud, char *term, int noclear, int nowait, stru
|
||||
|
||||
pid = fork();
|
||||
if (!pid) {
|
||||
speed_t speed = B38400;
|
||||
|
||||
if (baud && baud[0]) {
|
||||
speed = stty_parse_speed(baud);
|
||||
if (B0 == speed)
|
||||
logit(LOG_CRIT, "TTY %s: Invalid speed %s", tty, baud);
|
||||
}
|
||||
speed_t speed;
|
||||
|
||||
speed = stty_parse_speed(baud);
|
||||
logit(LOG_INFO, "Starting built-in getty on %s, speed %u", tty, speed);
|
||||
prepare_tty(tty, speed, "tty", rlimit);
|
||||
|
||||
if (activate_console(noclear, nowait))
|
||||
_exit(getty(tty, speed, term, NULL));
|
||||
}
|
||||
@@ -415,6 +412,7 @@ pid_t run_getty2(char *tty, char *cmd, char *args[], int noclear, int nowait, st
|
||||
dup2(fd, STDERR_FILENO);
|
||||
|
||||
/* Dunno speed, tell stty() to not mess with it */
|
||||
logit(LOG_INFO, "Starting external getty on %s, speed %u", tty, B0);
|
||||
prepare_tty(tty, B0, "getty", rlimit);
|
||||
|
||||
if (ioctl(STDIN_FILENO, TIOCSCTTY, 1) < 0)
|
||||
|
||||
+29
-9
@@ -421,9 +421,9 @@ int main(int argc, char *argv[])
|
||||
else if (whichp("udevadm"))
|
||||
run_interactive("udevadm info --cleanup-db", "Cleaning up udev db");
|
||||
|
||||
/* Some systems use /dev/pts */
|
||||
/* Modern systems use /dev/pts */
|
||||
makedir("/dev/pts", 0755);
|
||||
mount("devpts", "/dev/pts", "devpts", 0, "gid=5,mode=620");
|
||||
mount("devpts", "/dev/pts", "devpts", 0, "gid=5,mode=620,ptmxmode=0666");
|
||||
|
||||
/*
|
||||
* Some systems rely on us to both create /dev/shm and, to mount
|
||||
@@ -433,14 +433,14 @@ int main(int argc, char *argv[])
|
||||
*/
|
||||
makedir("/dev/shm", 0755);
|
||||
if (!fismnt("/dev/shm") && !ismnt("/etc/fstab", "/dev/shm"))
|
||||
mount("shm", "/dev/shm", "tmpfs", 0, NULL);
|
||||
mount("shm", "/dev/shm", "tmpfs", 0, "mode=0777");
|
||||
|
||||
/*
|
||||
* New tmpfs based /run for volatile runtime data
|
||||
* For details, see http://lwn.net/Articles/436012/
|
||||
*/
|
||||
if (fisdir("/run") && !fismnt("/run"))
|
||||
mount("tmpfs", "/run", "tmpfs", MS_NODEV, "mode=0755,size=10%");
|
||||
mount("tmpfs", "/run", "tmpfs", MS_NODEV | MS_NOSUID | MS_NOEXEC, "mode=0755,size=10%");
|
||||
umask(022);
|
||||
|
||||
/* Bootstrap conditions, needed for hooks */
|
||||
@@ -492,16 +492,36 @@ int main(int argc, char *argv[])
|
||||
* Start bundled watchdogd as soon as possible, if enabled
|
||||
*/
|
||||
if (which(FINIT_LIBPATH_ "/watchdogd"))
|
||||
service_register(SVC_TYPE_SERVICE, FINIT_LIBPATH_ "/watchdogd", global_rlimit, NULL);
|
||||
service_register(SVC_TYPE_SERVICE, FINIT_LIBPATH_ "/watchdogd -- Finit watchdog daemon", global_rlimit, NULL);
|
||||
|
||||
/*
|
||||
* Mount filesystems
|
||||
*/
|
||||
if (!rescue) {
|
||||
#ifdef REMOUNT_ROOTFS
|
||||
run("mount -n -o remount,rw /");
|
||||
#endif
|
||||
#ifdef SYSROOT
|
||||
#ifndef SYSROOT
|
||||
/*
|
||||
* Remount / read-write if it exists in fstab is not 'ro'.
|
||||
* This is what the Debian sysv initscripts does.
|
||||
*/
|
||||
if (setfsent()) {
|
||||
struct fstab *fs;
|
||||
|
||||
while ((fs = getfsent())) {
|
||||
if (strcmp(fs->fs_file, "/"))
|
||||
continue;
|
||||
|
||||
if (strcmp(fs->fs_type, "ro"))
|
||||
run_interactive("mount -n -o remount,rw /", "Remounting / as read-write");
|
||||
break;
|
||||
}
|
||||
|
||||
endfsent();
|
||||
}
|
||||
#else
|
||||
/*
|
||||
* XXX: Untested, in the initramfs age we should
|
||||
* probably use switch_root instead.
|
||||
*/
|
||||
mount(SYSROOT, "/", NULL, MS_MOVE, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
+3
-3
@@ -421,9 +421,9 @@ static int show_status(char *arg)
|
||||
for (svc = client_svc_iterator(1); svc; svc = client_svc_iterator(0)) {
|
||||
char jobid[20], args[512] = "", *lvls;
|
||||
|
||||
// if (svc_is_unique(svc))
|
||||
// snprintf(jobid, sizeof(jobid), "%d", svc->job);
|
||||
// else
|
||||
if (!svc->id[0])
|
||||
snprintf(jobid, sizeof(jobid), "%d", svc->job);
|
||||
else
|
||||
snprintf(jobid, sizeof(jobid), "%d:%s", svc->job, svc->id);
|
||||
|
||||
printf("%-9s %8s ", jobid, svc_status(svc));
|
||||
|
||||
+11
-10
@@ -307,7 +307,7 @@ static int service_start(svc_t *svc)
|
||||
|
||||
/* Don't try and start service if it doesn't exist. */
|
||||
if (!whichp(svc->cmd) && !svc->inetd.cmd) {
|
||||
print(1, "Service %s does not exist!", svc->cmd);
|
||||
print(1, "Service %s does not exist", svc->cmd);
|
||||
svc_missing(svc);
|
||||
return 1;
|
||||
}
|
||||
@@ -827,7 +827,8 @@ static void parse_cmdline_args(svc_t *svc, char *cmd)
|
||||
*
|
||||
* Service conditions can be: svc/<PATH> for PID files, net/<IFNAME>/up
|
||||
* and net/<IFNAME>/exists. The condition handling is further described
|
||||
* docs/conditions.md.
|
||||
* in doc/conditions.md, but worth mentioning here is that the condition
|
||||
* name itself can be modified using the :ID and name:foo syntax.
|
||||
*
|
||||
* For multiple instances of the same command, e.g. multiple DHCP
|
||||
* clients, the user must enter an ID, using the :ID syntax.
|
||||
@@ -843,8 +844,8 @@ static void parse_cmdline_args(svc_t *svc, char *cmd)
|
||||
*/
|
||||
int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
|
||||
{
|
||||
char id_str[MAX_ID_LEN];
|
||||
#ifdef INETD_ENABLED
|
||||
char id_str[MAX_ID_LEN];
|
||||
int forking = 0;
|
||||
#endif
|
||||
int levels = 0;
|
||||
@@ -977,20 +978,18 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
|
||||
parse_cmdline_args(svc, cmd);
|
||||
goto inetd_setup;
|
||||
}
|
||||
if (!id) {
|
||||
int n = svc_next_id_int(cmd);
|
||||
|
||||
if (n) {
|
||||
snprintf(id_str, sizeof(id_str), "%d", n);
|
||||
id = id_str;
|
||||
}
|
||||
/* inetd services need a unique ID, so we must always set one. */
|
||||
if (!id) {
|
||||
snprintf(id_str, sizeof(id_str), "%d", svc_next_id_int(cmd));
|
||||
id = id_str;
|
||||
}
|
||||
}
|
||||
recreate:
|
||||
#endif
|
||||
|
||||
if (!id)
|
||||
id = "1";
|
||||
id = "";
|
||||
|
||||
svc = svc_find(cmd, id);
|
||||
if (!svc) {
|
||||
@@ -1427,11 +1426,13 @@ restart:
|
||||
char name[MAX_COND_LEN];
|
||||
|
||||
mkcond(svc, name, sizeof(name));
|
||||
_d("Reassert condition %s", name);
|
||||
cond_set_path(cond_path(name), COND_ON);
|
||||
}
|
||||
break;
|
||||
|
||||
case COND_OFF:
|
||||
_d("Condition for %s is off, sending SIGCONT + SIGTERM", svc->name);
|
||||
kill(svc->pid, SIGCONT);
|
||||
service_stop(svc);
|
||||
break;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <sys/ttydefaults.h> /* Not included by default in musl libc */
|
||||
#include <termios.h>
|
||||
|
||||
/* B0 means; keep kernel default */
|
||||
speed_t stty_parse_speed(char *baud)
|
||||
{
|
||||
char *ptr;
|
||||
@@ -66,6 +67,9 @@ speed_t stty_parse_speed(char *baud)
|
||||
{ 4000000, B4000000 },
|
||||
};
|
||||
|
||||
if (!baud || !baud[0])
|
||||
return B0;
|
||||
|
||||
errno = 0;
|
||||
val = strtoul(baud, &ptr, 10);
|
||||
if (errno || ptr == baud)
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <err.h>
|
||||
#include <ctype.h> /* isdigit() */
|
||||
#include <time.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
#include <sys/time.h>
|
||||
@@ -60,6 +61,7 @@ static void svc_gc(void *arg)
|
||||
continue;
|
||||
|
||||
TAILQ_REMOVE(&gc_list, svc, link);
|
||||
_d("Cleaning out %s, clearing any conditions ...", svc->name);
|
||||
cond_clear(mkcond(svc, cond, sizeof(cond)));
|
||||
free(svc);
|
||||
}
|
||||
@@ -98,7 +100,8 @@ svc_t *svc_new(char *cmd, char *id, int type)
|
||||
|
||||
svc->type = type;
|
||||
svc->job = job;
|
||||
strlcpy(svc->id, id, sizeof(svc->id));
|
||||
if (id && id[0])
|
||||
strlcpy(svc->id, id, sizeof(svc->id));
|
||||
strlcpy(svc->cmd, cmd, sizeof(svc->cmd));
|
||||
|
||||
/* Default description, if missing */
|
||||
@@ -376,18 +379,49 @@ svc_t *svc_find_by_nameid(char *name, char *id)
|
||||
* svc_find_by_plidfile - Find an service object by its PID file
|
||||
* @fn: PID file, can be absolute path or relative to /run
|
||||
*
|
||||
* This function is primarily used by the pidfile plugin to track the
|
||||
* conditions and dependencies of services.
|
||||
*
|
||||
* Note, the PID file is assumed to exist so the contents can be
|
||||
* compared to the the PID of a located service. There may be several
|
||||
* services, in many runlevels, that use the same name for the PID file.
|
||||
* So we won't know for sure until the PID is compared.
|
||||
*
|
||||
* Returns:
|
||||
* A pointer to an &svc_t object, or %NULL if not found.
|
||||
*/
|
||||
svc_t *svc_find_by_pidfile(char *fn)
|
||||
{
|
||||
svc_t *svc, *iter = NULL;
|
||||
char adjpath[strlen(fn) + 10]; /* + sizeof("/var/run/") */
|
||||
char fnpath[PATH_MAX];
|
||||
|
||||
pid_runpath(fn, adjpath, sizeof(adjpath));
|
||||
if (!realpath(adjpath, fnpath)) {
|
||||
_pe("adjpath: %s, errno %d", adjpath, errno);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (svc = svc_iterator(&iter, 1); svc; svc = svc_iterator(&iter, 0)) {
|
||||
char path[MAX_ARG_LEN];
|
||||
char path[PATH_MAX];
|
||||
char *pidfn;
|
||||
pid_t pid;
|
||||
|
||||
if (string_compare(pid_runpath(fn, path, sizeof(path)), pid_file(svc)))
|
||||
return svc;
|
||||
pidfn = pid_file(svc);
|
||||
if (!pidfn || !realpath(pidfn, path)) {
|
||||
if (errno != ENOENT)
|
||||
_pe("pidfn: %s, errno %d", pidfn ?: "<NULL>", errno);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!string_compare(fnpath, path))
|
||||
continue;
|
||||
|
||||
pid = pid_file_read(path);
|
||||
if (svc->pid != pid)
|
||||
continue;
|
||||
|
||||
return svc;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -502,7 +536,10 @@ int svc_enabled(svc_t *svc)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Same base service, return unique ID as an integer */
|
||||
/*
|
||||
* Same base service, return unique ID as an integer
|
||||
* Note: intended for use with INETD services.
|
||||
*/
|
||||
int svc_next_id_int(char *cmd)
|
||||
{
|
||||
int n = 1;
|
||||
@@ -519,7 +556,7 @@ int svc_next_id_int(char *cmd)
|
||||
n++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int svc_is_unique(svc_t *svc)
|
||||
|
||||
@@ -161,7 +161,7 @@ int tty_register(char *line, struct rlimit rlimit[], char *file)
|
||||
if ((!cmd && !dev) || (cmd && !dev)) {
|
||||
if (args[i][0] == '[')
|
||||
runlevels = line;
|
||||
if (!strcmp(args[i], "@console"))
|
||||
if (!strcmp(args[i], "@console") || !strcmp(args[i], "console"))
|
||||
dev = args[i];
|
||||
if (!strncmp(args[i], "/dev", 4))
|
||||
dev = args[i];
|
||||
@@ -197,7 +197,7 @@ int tty_register(char *line, struct rlimit rlimit[], char *file)
|
||||
}
|
||||
|
||||
/* Auto-detect serial console, for embedded devices mostly */
|
||||
if (!strcmp(dev, "@console")) {
|
||||
if (!strcmp(dev, "@console") || !strcmp(dev, "console")) {
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen("/sys/class/tty/console/active", "r");
|
||||
@@ -262,7 +262,7 @@ again:
|
||||
char *arg = args[i];
|
||||
|
||||
/* Replace @console with actual device */
|
||||
if (arg && !strcmp(arg, "@console"))
|
||||
if (arg && (!strcmp(arg, "@console") || !strcmp(arg, "console")))
|
||||
arg = dev;
|
||||
if (arg)
|
||||
entry->args[j++] = strdup(arg);
|
||||
|
||||
Reference in New Issue
Block a user