mirror of
https://github.com/troglobit/finit.git
synced 2026-10-12 10:12:32 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44137806e4 |
@@ -1,3 +0,0 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [troglobit]
|
||||
@@ -1,12 +0,0 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
finit is a small project, as such we have no possibility to support older versions.
|
||||
The only supported version is the latest released on GitHub:
|
||||
|
||||
<https://github.com/troglobit/finit/releases>
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Contact the project's main author and owner to report and discuss vulnerabilities.
|
||||
@@ -9,13 +9,11 @@ GSYMS
|
||||
GTAGS
|
||||
|
||||
# GNU configure and build system
|
||||
/aux
|
||||
/.deps
|
||||
/autom4te.cache
|
||||
/aclocal.m4
|
||||
/ar-lib
|
||||
/compile
|
||||
/config.cache
|
||||
/config.h
|
||||
/config.mk
|
||||
/config.guess
|
||||
@@ -33,9 +31,6 @@ GTAGS
|
||||
/Makefile.in
|
||||
/stamp-h1
|
||||
|
||||
/test-driver
|
||||
/test-suite.log
|
||||
|
||||
# TroglOS build system
|
||||
/.config
|
||||
/.stamp
|
||||
|
||||
+12
-18
@@ -9,16 +9,14 @@ sudo: false
|
||||
#sudo: true
|
||||
|
||||
# Test build with both GCC and Clang (LLVM)
|
||||
# - clang
|
||||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
|
||||
# The secure: declaration is the encrypted COVERITY_SCAN_TOKEN, created
|
||||
# via the "travis encrypt" command using the project repo's public key
|
||||
env:
|
||||
global:
|
||||
- PKG_CONFIG_PATH=/tmp/lib/pkgconfig
|
||||
- CFLAGS="-W -Wall -Wextra"
|
||||
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
|
||||
# via the "travis encrypt" command using the project repo's public key
|
||||
- secure: "eOiuHs02lG2Uv146K9dMqucGTWUJFEhpz1oAtwe+kPrRXsXWc20hYMO+DSpMgD05vSvNeQA6p7h7LdRFQ+/g/Obj27TsOE+RKkUvRAtdwzxnKVyii9C/nmML8cFw7rIA0VS8O9mAkVYeyDxNDupBp3e9DPCibhKPvqCvioTnyy4="
|
||||
|
||||
addons:
|
||||
@@ -30,25 +28,25 @@ addons:
|
||||
name: "troglobit/finit"
|
||||
description: "finit | Fast & Extensible init for Linux"
|
||||
notification_email: troglobit@gmail.com
|
||||
build_command_prepend: "./autogen.sh && ./configure --prefix=/tmp"
|
||||
build_command_prepend: "./autogen.sh && PKG_CONFIG_PATH=/tmp/lib/pkgconfig ./configure --prefix=/tmp"
|
||||
build_command: "make"
|
||||
branch_pattern: dev
|
||||
|
||||
install:
|
||||
- wget https://github.com/troglobit/libuev/releases/download/v2.3.2/libuev-2.3.2.tar.xz
|
||||
- wget https://github.com/troglobit/libite/releases/download/v2.3.1/libite-2.3.1.tar.gz
|
||||
- tar xf libuev-2.3.2.tar.xz
|
||||
- tar xf libite-2.3.1.tar.gz
|
||||
- (cd libuev-2.3.2 && ./configure --prefix=/tmp && make && make install-strip)
|
||||
- (cd libite-2.3.1 && ./configure --prefix=/tmp && make && make install-strip)
|
||||
- wget https://github.com/troglobit/libuev/releases/download/v2.2.0/libuev-2.2.0.tar.xz
|
||||
- wget https://github.com/troglobit/libite/releases/download/v2.0.1/libite-2.0.1.tar.xz
|
||||
- tar xf libuev-2.2.0.tar.xz
|
||||
- tar xf libite-2.0.1.tar.xz
|
||||
- (cd libuev-2.2.0 && ./configure --prefix=/tmp && make && make install-strip)
|
||||
- (cd libite-2.0.1 && ./configure --prefix=/tmp && make && make install-strip)
|
||||
|
||||
# Custom build script for the time being, no "make test" yet
|
||||
script:
|
||||
- ./autogen.sh
|
||||
- ./configure --prefix=/tmp --enable-static
|
||||
- PKG_CONFIG_PATH=/tmp/lib/pkgconfig ./configure --prefix=/tmp --disable-inetd --enable-static
|
||||
- make clean
|
||||
- make V=1 -j5
|
||||
- ./configure --prefix=/tmp --enable-x11-common-plugin --enable-fallback-shell --enable-watchdog --enable-logit
|
||||
- PKG_CONFIG_PATH=/tmp/lib/pkgconfig ./configure --prefix=/tmp --enable-inetd-echo-plugin --enable-inetd-time-plugin --enable-x11-common-plugin --enable-inetd-chargen-plugin --enable-fallback-shell --enable-watchdog
|
||||
- cat config.log
|
||||
- make clean
|
||||
- make V=1 -j5
|
||||
@@ -59,7 +57,3 @@ script:
|
||||
- size /tmp/sbin/initctl
|
||||
- size /tmp/sbin/reboot
|
||||
- LD_LIBRARY_PATH=/tmp/lib /tmp/sbin/initctl -h
|
||||
- unshare -V
|
||||
- nsenter -V
|
||||
- chroot --version
|
||||
- 'LD_LIBRARY_PATH=/tmp/lib make distcheck || (cat finit-4.0-beta1/_build/sub/test/test-suite.log; exit 1)'
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
Current Maintainer(s):
|
||||
* Joachim Wiberg <troglobit@gmail.com>
|
||||
* Joachim Nilsson <troglobit@gmail.com>
|
||||
|
||||
Major Contributors:
|
||||
* Tobias Waldekranz <tobias@waldekranz.com>
|
||||
* Mattias Walström <mattias.walstrom@westermo.se>
|
||||
* Jonas Johansson <jonas.johansson@westermo.se>
|
||||
* Jacques de Laval <jacques@de-laval.se>
|
||||
|
||||
Original Author(s):
|
||||
* Claudio Matsuoka <cmatsuoka@gmail.com>
|
||||
|
||||
+24
-88
@@ -4,45 +4,14 @@ Change Log
|
||||
All relevant changes are documented in this file.
|
||||
|
||||
|
||||
[4.0][UNRELEASED] - 2021-02-21
|
||||
[3.2][UNRELEASED] - 2018-10-xx
|
||||
------------------------------
|
||||
|
||||
This release became v4.0, and not v3.2, because of incompatible changes
|
||||
to service conditions. There are other significant changes as well, so
|
||||
make sure to read the whole changelog when upgrading.
|
||||
Bug fix release.
|
||||
|
||||
### Changes
|
||||
* The stand-alone `reboot` tool has been replaced with a symlink to
|
||||
`initctl`, like its siblings: halt, shutdown, poweroff, and suspend.
|
||||
Calling `reboot` & C:o now defaults to the corresponding `initctl cmd`
|
||||
with a fallback to sending signals as per traditional SysV init. The
|
||||
`-f` (force) flag remains, where `reboot(2)` is called directly
|
||||
* Introducing Finit progress 𝓜𝓸𝓭𝓮𝓻𝓷
|
||||
* Removed built-in inetd super server. If you need this functionality,
|
||||
use an external inetd, like xinetd, instead. A pull request for a
|
||||
stand-alone inetd, like watchdogd and getty, is most welcome!
|
||||
* Incompatible `configure` script changes, i.e., you must give proper
|
||||
path arguments to the script, no more guessing just GNU defaults.
|
||||
There are examples in the documentation and the `contrib/` section
|
||||
* Change service conditions from the non-obvious `<svc/path/to/foo>` to
|
||||
`<pid/foo:id>`. This to hopefully make it clear that one service's
|
||||
'pid:!foo' pidfile is another service's `<pid/foo>` condition
|
||||
* Initial support for cgroups, every service now runs in its own cgroup
|
||||
https://twitter.com/b0rk/status/1214341831049252870?s=20
|
||||
* Major refactor of Finit's `main()` function to be able to start the
|
||||
event loop earlier. This also facilitated factoring out functionality
|
||||
previously hard-coded in Finit, e.g., starting the bundled watchdogd,
|
||||
various distro packed udevd and other hotplugging tools
|
||||
* Support for `sysv` start/stop scripts as well as monitoring forking
|
||||
services, stared using `sysv` or `service` stanza
|
||||
* Support for custom `kill:DELAY`, default 3 sec.
|
||||
* Support for custom `halt:SIGNAL`, default SIGTERM
|
||||
* 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-doc` and `--disable-contrib` to speed up
|
||||
* Add support for `--disable-docs` 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`
|
||||
* Prefer udev to handle `/dev/` if mdev is also available
|
||||
* Redirect dbus daemon output to syslog
|
||||
@@ -50,7 +19,7 @@ make sure to read the whole changelog when upgrading.
|
||||
* Finit no longer automatically reloads its `*.conf` files after running
|
||||
`/etc/rc.local` or run-parts. Use `initctl reload` instead.
|
||||
* `initctl` without an argument or option now defaults to list services
|
||||
* Convert built-in watchdog daemon to standalone mini watchdogd, issue #102
|
||||
* Converted built-in watchdog daemon to standalone mini watchdogd
|
||||
* Improved watchdog hand-over, now based on `svc_t` and not PID
|
||||
* Extended bootstrap, runlevel S, timeout: 10 --> 120 sec. before services
|
||||
not allowed in the runtime runlevel are unconditionally stopped
|
||||
@@ -65,64 +34,37 @@ make sure to read the whole changelog when upgrading.
|
||||
the kernel can invalidate deleted events before enqueing to userspace
|
||||
* Rename `hwclock.so` plugin to `rtc.so` since it now is stand-alone
|
||||
from the `hwclock` tool. Note: the kernel can also be set to load
|
||||
and store RTC to/from system clock at boot/halt as well, issue #110
|
||||
* New plugin to support cold plugging devices, auto-loading of modules
|
||||
at boot. Detects required modules by reading `/sys/devices/*`
|
||||
* New plugin for `/etc/modules-load.d/` by Robert Andersson, Atlas Copco
|
||||
* New `name:foo` support for services, by Robert Andersson, Atlas Copco
|
||||
* New `manual:yes` support for services, by Robert Andersson, Atlas Copco
|
||||
* New `log:console` support for services, by Robert Andersson, Atlas Copco
|
||||
* Support for `:ID` as a string, by Jonas Johansson, Westermo
|
||||
* Support for auto-reload, instead of having to do `initctl reload`,
|
||||
when a service configuration has changed. Disabled by default, but
|
||||
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, use NULL/zero internally 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
|
||||
* The IPC socket has moved from `/run/finit.sock` to `/run/finit/socket`
|
||||
officially only supported for use by the `initctl` tool
|
||||
* Improved support for modern `/etc/network/interfaces`, which has
|
||||
include statements. No more native `ifup` of individual interfaces,
|
||||
Finit now calls `ifup -a`, or `ifdown -a`, delegating all details to
|
||||
the operating system. Also, this is now done in the background, by
|
||||
popular request
|
||||
and store RTC to/from system clock at boot/halt as well.
|
||||
|
||||
### Fixes
|
||||
|
||||
* Fix #96: Start udevd as a proper service
|
||||
* Ensure we track run commands as well as task/service, once per runlevel
|
||||
* Fix #98: FTBFS with `--disable-inetd`
|
||||
* Make sure to unblock UDP inetd services when connection terminates.
|
||||
Regression introduced in v3.1
|
||||
* Ensure run/tasks also go to stopping state on exit, like services,
|
||||
otherwise it is unnecessarily hard to restart them
|
||||
* Fix #99: Do not try to `SIGKILL` inetd services, they are not backed
|
||||
by a PID. This caused a use after free issue crashing finit. Found
|
||||
and fixed by Tobias Waldekranz, Westermo
|
||||
* Fix missing OS/Finit title bug, adds leading newline before banner
|
||||
* Remove "Failed connecting to watchdog ..." error message on systems
|
||||
that do not have a watchdog
|
||||
* Fix #100: Early condition handling may not work if `/var/run` does
|
||||
not yet exist (symlink to `/run`). Added compat layer for access
|
||||
* Fix #103: Register multiple getty if `@console` resolves to >1 TTY,
|
||||
* Fix #103: Register multiple getty if `@console` resolves to >1 TTY
|
||||
* Fix #105: Only remove /etc/nologin when moving from runlevel 0, 1, 6
|
||||
* Fix #106: Don't mark inetd connections for deletion at .conf reload.
|
||||
Fixed by Jonas Johansson, Westermo
|
||||
* Fix #109: Support for PID files in sub-directories to `/var/run`
|
||||
* Handle rename of PID files, by Robert Andersson, Atlas Copco
|
||||
* Fix #120: Redirect `stdin` to `/dev/null` for services by default
|
||||
* Fix #122: Switch to `nanosleep()` to achieve "signal safe" sleep,
|
||||
fixed by Jacques de Laval, Westermo
|
||||
* Fix #124: Lingering processes in process group when session leader
|
||||
exits. E.g., lingering `logit` processes when parent dies
|
||||
* Fix service name matching, e.g. for condition handling, may match with
|
||||
wrong service, by Jonas Holmberg, Westermo
|
||||
* Run all run-parts scripts using `/bin/sh -c foo` just like the standard
|
||||
run-parts tool. Found by Magnus Malm, Westermo
|
||||
* Fix #107: Stop spawned inetd conncections when stopping inetd service.
|
||||
Fixed by Jonas Johansson, Westermo
|
||||
* Fix #111: Only restart inetd services when necessary. E.g., if the
|
||||
listening interface is changed. Only stop established connections
|
||||
which are no longer allowed, i.e. do not touch already allowed
|
||||
established connections. Fixed by Jonas Johansson, Westermo
|
||||
* Fix: update inetd service args on config change. Found and fixed by
|
||||
Petrus Hellgren, Westermo
|
||||
* Fix `initctl [start | restart]`, should behave the same for services
|
||||
that have crashed. Found by Mattias Walström, Westermo
|
||||
* Wait for bootstrap phase to complete before cleaning out any bootstrap
|
||||
@@ -130,13 +72,7 @@ make sure to read the whole changelog when upgrading.
|
||||
* Reassert condition when an unmodified run/task/service goes from
|
||||
WAITING back to RUNNING again after a reconfiguration event.
|
||||
Found and fixed by Jonas Johansson, Westermo
|
||||
* 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
|
||||
* Fix #138: Handle `SIGPWR` like `SIGSUR2`, i.e., power off the system
|
||||
* Drop the '%m' GNUism, for compat with older musl libc
|
||||
|
||||
|
||||
[3.1][] - 2018-01-23
|
||||
@@ -211,7 +147,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 `doc/` and `contrib/` directories
|
||||
* Distribute and install `docs/` and `contrib/` directories
|
||||
|
||||
### Fixes
|
||||
|
||||
@@ -274,7 +210,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 [doc/distro.md](doc/distro.md) for details
|
||||
distributions. See [docs/distro.md](docs/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
|
||||
@@ -845,7 +781,7 @@ Major bug fix release.
|
||||
* Initial release
|
||||
|
||||
[UNRELEASED]: https://github.com/troglobit/finit/compare/3.1...HEAD
|
||||
[4.0]: https://github.com/troglobit/finit/compare/3.1...4.0
|
||||
[3.2]: https://github.com/troglobit/finit/compare/3.1...3.2
|
||||
[3.1]: https://github.com/troglobit/finit/compare/3.0...3.1
|
||||
[3.0]: https://github.com/troglobit/finit/compare/2.4...3.0
|
||||
[2.4]: https://github.com/troglobit/finit/compare/2.3...2.4
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Copyright (c) 2008-2010 Claudio Matsuoka <cmatsuoka@gmail.com>
|
||||
Copyright (c) 2008-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
Copyright (c) 2008-2014 Joachim Nilsson <troglobit@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+6
-8
@@ -1,13 +1,13 @@
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
SUBDIRS = plugins src test
|
||||
SUBDIRS = plugins src
|
||||
doc_DATA = README.md LICENSE contrib/finit.conf
|
||||
EXTRA_DIST = README.md LICENSE ChangeLog.md contrib/finit.conf
|
||||
|
||||
if CONTRIB
|
||||
SUBDIRS += contrib
|
||||
endif
|
||||
if DOC
|
||||
SUBDIRS += doc
|
||||
if DOCS
|
||||
SUBDIRS += docs
|
||||
endif
|
||||
|
||||
# Compat hook
|
||||
@@ -16,9 +16,8 @@ install-dev:
|
||||
|
||||
# Target to run when building a release
|
||||
release: distcheck
|
||||
@for file in $(DIST_ARCHIVES); do \
|
||||
md5sum $$file > ../$$file.md5; \
|
||||
sha256sum $$file > ../$$file.sha256; \
|
||||
@for file in $(DIST_ARCHIVES); do \
|
||||
md5sum $$file > ../$$file.md5; \
|
||||
done
|
||||
@mv $(DIST_ARCHIVES) ../
|
||||
@echo
|
||||
@@ -26,6 +25,5 @@ release: distcheck
|
||||
@echo "================================================================="
|
||||
@for file in $(DIST_ARCHIVES); do \
|
||||
printf "$$file \tDistribution tarball\n"; \
|
||||
printf "$$file.md5\t"; cat ../$$file.md5 | cut -f1 -d' '; \
|
||||
printf "$$file.sha256\t"; cat ../$$file.sha256 | cut -f1 -d' '; \
|
||||
printf "$$file.md5\t"; cat ../$$file.md5 | cut -f1 -d' '; \
|
||||
done
|
||||
|
||||
@@ -1,38 +1,39 @@
|
||||
[![License Badge][]][License] [![Travis Status]][Travis] [![Coverity Status]][Coverity Scan]
|
||||
<img align="right" src="img/finit3.png" alt="Finit: Fast Init">
|
||||
|
||||
* [Introduction](#introduction)
|
||||
* [Features](#features)
|
||||
* [Bootstrap](doc/bootstrap.md#bootstrap)
|
||||
* [Bootstrap](docs/bootstrap.md#bootstrap)
|
||||
* [Runlevels](#runlevels)
|
||||
* [Syntax](doc/config.md#syntax)
|
||||
* [Syntax](docs/config.md#syntax)
|
||||
* [Inetd](docs/inetd.md#inetd)
|
||||
* [Runparts & /etc/rc.local](#runparts--etcrclocal)
|
||||
* [Hooks, Callbacks & Plugins](doc/plugins.md#hooks-callbacks--plugins)
|
||||
* [Hooks, Callbacks & Plugins](docs/plugins.md#hooks-callbacks--plugins)
|
||||
* [Rebooting & Halting](#rebooting--halting)
|
||||
* [Commands & Status](#commands--status)
|
||||
* [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)
|
||||
* [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)
|
||||
* [Requirements](#requirements)
|
||||
* [Origin & References](#origin--references)
|
||||
|
||||
|
||||
Introduction
|
||||
------------
|
||||
[![License Badge][]][License] [![Travis Status]][Travis] [![Coverity Status]][Coverity Scan]
|
||||
|
||||
Finit is a simple alternative to [SysV init][4] and [systemd][6]. It
|
||||
was reverse engineered from the [EeePC fastinit][] over ten years ago
|
||||
by [Claudio Matsuoka][] — "gaps filled with frog DNA …"
|
||||
was reverse engineered from the [EeePC fastinit][] ten years ago by
|
||||
[Claudio Matsuoka][] — "gaps filled with frog DNA …"
|
||||
|
||||
Focus is on small and embedded systems, although Finit is fully usable
|
||||
on server and desktop systems as well. For working examples, see the
|
||||
[contrib/](contrib/) section with tutorials for:
|
||||
|
||||
* [Void Linux](contrib/void/),
|
||||
* [Alpine Linux](contrib/alpine/), and
|
||||
* [Debian GNU/Linux](contrib/debian/)
|
||||
* [Alpine Linux](contrib/alpine/),
|
||||
* [Debian GNU/Linux](contrib/debian/), and
|
||||
* [Void Linux](contrib/void/)
|
||||
|
||||

|
||||
The screenshot shows [Alpine Linux](https://www.alpinelinux.org/).
|
||||
@@ -58,79 +59,89 @@ runlevel 2
|
||||
log size=100k count=4
|
||||
|
||||
# Services to be monitored and respawned as needed
|
||||
service [S12345] watchdogd -L -f -- System watchdog daemon
|
||||
service [S12345] syslogd -n -b 3 -D -- System log daemon
|
||||
service [S12345] <pid/syslogd> klogd -n -- Kernel log daemon
|
||||
service [2345] lldpd -d -c -M1 -H0 -i -- LLDP daemon (IEEE 802.1ab)
|
||||
service [S12345] /sbin/watchdogd -L -f -- System watchdog daemon
|
||||
service [S12345] /sbin/syslogd -n -b 3 -D -- System log daemon
|
||||
service [S12345] /sbin/klogd -n -- Kernel log daemon
|
||||
service [2345] /sbin/lldpd -d -c -M1 -H0 -i -- LLDP daemon (IEEE 802.1ab)
|
||||
|
||||
# The BusyBox ntpd does not use syslog when running in the foreground
|
||||
# So we use this trick to redirect stdout/stderr to a log file. The
|
||||
# log file is rotated with the above settings. The condition declares
|
||||
# a dependency on a system default route (gateway) to be set. A single
|
||||
# <!> at the beginning means ntpd does not respect SIGHUP for restart.
|
||||
service [2345] log:/var/log/ntpd.log <!net/route/default> ntpd -n -l -I eth0 -- NTP daemon
|
||||
service [2345] log:/var/log/ntpd.log <!net/route/default> /sbin/ntpd -n -l -I eth0 -- NTP daemon
|
||||
|
||||
# For multiple instances of the same service, add :ID somewhere between
|
||||
# the service/run/task keyword and the command.
|
||||
service :80 [2345] merecat -n -p 80 /var/www -- Web server
|
||||
service :8080 [2345] merecat -n -p 8080 /var/www -- Old web server
|
||||
service :1 [2345] /sbin/merecat -n -p 80 /var/www -- Web server
|
||||
service :2 [2345] /sbin/merecat -n -p 8080 /var/www -- Old web server
|
||||
|
||||
# Alternative method instead of below runparts, can also use /etc/rc.local
|
||||
#task [S] /etc/init.d/keyboard-setup start -- Setting up preliminary keymap
|
||||
#task [S] /etc/init.d/acpid start -- Starting ACPI Daemon
|
||||
#task [S] /etc/init.d/kbd start -- Preparing console
|
||||
#task [S] /etc/init.d/keyboard-setup start -- Setting up preliminary keymap
|
||||
#task [S] /etc/init.d/acpid start -- Starting ACPI Daemon
|
||||
#task [S] /etc/init.d/kbd start -- Preparing console
|
||||
|
||||
# Inetd services to start on demand, with alternate ports and filtering
|
||||
inetd ftp/tcp nowait [2345] /sbin/in.ftpd -- FTP daemon
|
||||
inetd tftp/udp wait [2345] /sbin/in.tftpd -- TFTP daemon
|
||||
inetd time/udp wait [2345] internal -- UNIX rdate service
|
||||
inetd time/tcp nowait [2345] internal -- UNIX rdate service
|
||||
inetd 3737/tcp nowait [2345] internal.time -- UNIX rdate service
|
||||
inetd telnet/tcp nowait [2345] /sbin/telnetd -i -F -- Telnet daemon
|
||||
inetd 2323/tcp nowait [2345] /sbin/telnetd -i -F -- Telnet daemon
|
||||
inetd 222/tcp@eth0 nowait [2345] /sbin/dropbear -i -R -F -- SSH service
|
||||
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, 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
|
||||
# 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
|
||||
|
||||
# Use built-in getty for serial port and USB serial
|
||||
tty [12345] /dev/ttyAMA0 noclear nowait
|
||||
tty [12345] /dev/ttyUSB0 noclear
|
||||
tty [12345] /dev/ttyAMA0 115200 noclear nowait
|
||||
tty [12345] /dev/ttyUSB0 115200 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` and others are 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:
|
||||
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
|
||||
overview of some of the most common components needed to start a UNIX
|
||||
daemon:
|
||||
|
||||
```
|
||||
service [LVLS] <COND> log env:[-]/etc/default/daemon daemon ARGS -- Daemon daemon
|
||||
^ ^ ^ ^ ^ ^ ^ ^
|
||||
| | | | | | | `-- Optional description
|
||||
| | | | | | `----------- Daemon arguments
|
||||
| | | | | `-------------------------- Path to daemon
|
||||
| | | | `---------------------------------------------------- Optional env. file
|
||||
| | | `-------------------------------------------------------- Redirect output to log
|
||||
| | `--------------------------------------------------------------- Optional conditions
|
||||
| `---------------------------------------------------------------------- Optional Runlevels
|
||||
`------------------------------------------------------------------------------ Monitored application
|
||||
service [LVLS] <COND> /path/to/daemon ARGS -- Some text
|
||||
^ ^ ^ ^ ^ ^
|
||||
| | | | | `-- Optional description
|
||||
| | | | `---------- Daemon arguments
|
||||
| | | `-------------------------- Path to daemon
|
||||
| | `--------------------------------- Optional conditions
|
||||
| `---------------------------------------- Optional Runlevels
|
||||
`------------------------------------------------ Monitored application
|
||||
```
|
||||
|
||||
Some components are optional: runlevel(s), condition(s) and description,
|
||||
making it easy to create simple start scripts and still possible for more
|
||||
advanced uses as well:
|
||||
|
||||
service sshd -D
|
||||
service /usr/sbin/sshd -D
|
||||
|
||||
Dependencies are handled using [conditions](doc/conditions.md). One of
|
||||
Dependencies are handled using [conditions](docs/conditions.md). One of
|
||||
the most common conditions is to wait for basic networking to become
|
||||
available:
|
||||
|
||||
service <net/route/default> nginx -- High performace HTTP server
|
||||
service <net/route/default> /usr/sbin/nginx -- High performace HTTP server
|
||||
|
||||
Here is another example where we instruct Finit to not start BusyBox
|
||||
`ntpd` until `syslogd` has started properly. Finit waits for `syslogd`
|
||||
to create its PID file, by default `/var/run/syslogd.pid`.
|
||||
|
||||
service [2345] log <!pid/syslogd> ntpd -n -N -p pool.ntp.org
|
||||
service [S12345] syslogd -n -- Syslog daemon
|
||||
service [2345] log <svc/sbin/syslogd> /usr/sbin/ntpd -n -N -p pool.ntp.org
|
||||
service [S12345] /sbin/syslogd -n -- Syslog daemon
|
||||
|
||||
Notice the `log` keyword, BusyBox `ntpd` uses `stderr` for logging when
|
||||
run in the foreground. With `log` Finit redirects `stdout` + `stderr`
|
||||
@@ -139,7 +150,7 @@ to the system log daemon using the command line `logger(1)` tool.
|
||||
A service, or task, can have multiple dependencies listed. Here we wait
|
||||
for *both* `syslogd` to have started and basic networking to be up:
|
||||
|
||||
service [2345] log <pid/syslogd,net/route/default> ntpd -n -N -p pool.ntp.org
|
||||
service [2345] log <svc/sbin/syslogd,net/route/default> /usr/sbin/ntpd -n -N -p pool.ntp.org
|
||||
|
||||
If either condition fails, e.g. loss of networking, `ntpd` is stopped
|
||||
and as soon as it comes back up again `ntpd` is restarted automatically.
|
||||
@@ -158,6 +169,26 @@ Features
|
||||
Start, monitor and restart services should they fail.
|
||||
|
||||
|
||||
**Inetd**
|
||||
|
||||
Finit comes with a built-in [inetd server](docs/inetd.md). No need to
|
||||
maintain a separate config file for services that you want to start on
|
||||
demand.
|
||||
|
||||
All inetd services started can be filtered per port and inbound
|
||||
interface, reducing the need for a full blown firewall.
|
||||
|
||||
Built-in optional inetd services:
|
||||
|
||||
- echo [RFC862][]
|
||||
- chargen [RFC864][]
|
||||
- daytime [RFC867][]
|
||||
- discard [RFC863][]
|
||||
- time (rdate) [RFC868][]
|
||||
|
||||
For more information, see [docs/inetd.md](docs/inetd.md).
|
||||
|
||||
|
||||
**Getty**
|
||||
|
||||
Finit supports external getty but also comes with a limited built-in
|
||||
@@ -166,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 nowait linux
|
||||
tty [12345] /dev/ttyAMA0 noclear vt100
|
||||
tty [12345] /sbin/getty -L /dev/ttyAMA0 vt100
|
||||
tty [12345] /dev/tty1 38400 nowait linux
|
||||
tty [12345] /dev/ttyAMA0 115200 noclear vt100
|
||||
tty [12345] /sbin/getty -L 115200 /dev/ttyAMA0 vt100
|
||||
```
|
||||
|
||||
Users of embedded systems may want to enable automatic serial console
|
||||
@@ -177,19 +208,19 @@ system uses `ttyS0`, `ttyAMA0`, `ttyMXC0`, or anything else. Finit
|
||||
figures it out by querying sysfs: `/sys/class/tty/console/active`.
|
||||
|
||||
```conf
|
||||
tty [12345] @console linux noclear
|
||||
tty [12345] @console 115200 linux noclear
|
||||
```
|
||||
|
||||
Notice the optional `noclear`, `nowait`, and `nologin` flags. The
|
||||
latter is for skipping the login process entirely. For more information,
|
||||
see [doc/config.md](doc/config.md#syntax).
|
||||
see [docs/config.md](docs/config.md#syntax).
|
||||
|
||||
|
||||
**Runlevels**
|
||||
|
||||
Support for SysV init-style [runlevels][5] is available, in the same
|
||||
minimal style as everything else in Finit. The `[2345]` syntax can be
|
||||
applied to service, task, run, and TTY stanzas.
|
||||
applied to service, task, run, inetd, and TTY stanzas.
|
||||
|
||||
Reserved runlevels are 0 and 6, halt and reboot, respectively just like
|
||||
SysV init. Runlevel 1 can be configured freely, but is recommended to
|
||||
@@ -219,26 +250,34 @@ Capabilities:
|
||||
Hook into the boot at predefined points to extend Finit
|
||||
- **I/O**
|
||||
Listen to external events and control Finit behavior/services
|
||||
- **Inetd**
|
||||
Extend Finit with internal inetd services, for an example, see
|
||||
`plugins/time.c`
|
||||
|
||||
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 [doc/plugins.md](doc/plugins.md).
|
||||
For more information, see [docs/plugins.md](docs/plugins.md).
|
||||
|
||||
|
||||
**Automatic Reload**
|
||||
**Progress**
|
||||
|
||||
By default, Finit monitors `/etc/finit.d/` and `/etc/finit.d/enabled/`
|
||||
registering any changes to `.conf` files. To activate a change the user
|
||||
must call `initctl reload`, which reloads all modified files, stops any
|
||||
removed services, starts new ones, and restarts any modified ones, with
|
||||
SIGHUP if the process supports it.
|
||||
Finit prior to v3.0 showed the progress at boot: plugins and modules
|
||||
being loaded, run/tasks/services being started, etc. By default Finit
|
||||
is now silent, but progress can still be enabled at build-time using:
|
||||
|
||||
For some use-cases the extra step of calling `initctl reload` creates an
|
||||
unnecessary overhead, which can be removed at build-time using:
|
||||
configure --enable-progress
|
||||
|
||||
configure --enable-auto-reload
|
||||
or at boot from the kernel cmdline using the boot parameter `splash`:
|
||||
|
||||
```shell
|
||||
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).
|
||||
|
||||
|
||||
Runparts & /etc/rc.local
|
||||
@@ -260,8 +299,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 [doc/plugins.md](doc/plugins.md#hooks), and about the system bootstrap
|
||||
in [doc/bootstrap.md](doc/bootstrap.md).
|
||||
in [docs/plugins.md](docs/plugins.md#hooks), and about the system bootstrap
|
||||
in [docs/bootstrap.md](docs/bootstrap.md).
|
||||
|
||||
|
||||
Runlevels
|
||||
@@ -282,10 +321,10 @@ To specify an allowed set of runlevels for a `service`, `run` command,
|
||||
`task`, or `tty`, add `[NNN]` to your `/etc/finit.conf`, like this:
|
||||
|
||||
```
|
||||
service [S12345] syslogd -n -x -- System log daemon
|
||||
run [S] /etc/init.d/acpid start -- Starting ACPI Daemon
|
||||
task [S] /etc/init.d/kbd start -- Preparing console
|
||||
service [S12345] <pid/syslogd> klogd -n -x -- Kernel log daemon
|
||||
service [S12345] /sbin/syslogd -n -x -- System log daemon
|
||||
run [S] /etc/init.d/acpid start -- Starting ACPI Daemon
|
||||
task [S] /etc/init.d/kbd start -- Preparing console
|
||||
service [S12345] /sbin/klogd -n -x -- Kernel log daemon
|
||||
|
||||
tty [12345] /dev/tty1
|
||||
tty [2] /dev/tty2
|
||||
@@ -332,19 +371,42 @@ Rebooting & Halting
|
||||
|
||||
Traditionally, rebooting and halting a UNIX system is done by changing
|
||||
its runlevel. Finit comes with its own tooling providing: `shutdown`,
|
||||
`reboot`, `poweroff`, and `suspend`, but also the `initctl` tool,
|
||||
detailed in the next section.
|
||||
`reboot`, `poweroff`, and `suspend`, but also the traditional `init` and
|
||||
`telinit`, as well as a more modern `initctl` tool, detailed in the next
|
||||
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
|
||||
[doc/signals.md](doc/signals.md).
|
||||
[docs/signals.md](docs/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,
|
||||
`telinit q` will work as the UNIX beards intended.
|
||||
|
||||
```shell
|
||||
~ # telinit -h
|
||||
Usage: telinit [OPTIONS] [q | Q | 0-9]
|
||||
|
||||
Options:
|
||||
-h, --help This help text
|
||||
-V, --version Show Finit version
|
||||
|
||||
Commands:
|
||||
0 Power-off the system, same as initctl poweroff
|
||||
6 Reboot the system, same as initctl reboot
|
||||
2, 3, 4, 5 Change runlevel. Starts services in new runlevel, stops any
|
||||
services in prev. runlevel that are not allowed in new.
|
||||
q, Q Reload *.conf in /etc/finit.d/, same as initctl reload or
|
||||
sending SIGHUP to PID 1
|
||||
1, s, S Enter system rescue mode, runlevel 1
|
||||
```
|
||||
|
||||
|
||||
Commands & Status
|
||||
-----------------
|
||||
|
||||
Finit also implements a modern API to query status, and start/stop
|
||||
Finit also implements a more modern API to query status, and start/stop
|
||||
services, called `initctl`. Unlike `telinit` the `initctl` tool does
|
||||
not return until the given command has fully completed.
|
||||
|
||||
@@ -367,6 +429,8 @@ Commands:
|
||||
touch <CONF> Mark .conf in /etc/finit.d/ for reload
|
||||
reload Reload *.conf in /etc/finit.d/ (activates changes)
|
||||
|
||||
cond set <COND> Set (assert) condition => +COND
|
||||
cond clear <COND> Clear (deassert) condition => -COND
|
||||
cond show Show condition status
|
||||
cond dump Dump all conditions and their status
|
||||
|
||||
@@ -387,7 +451,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](doc/conditions.md),
|
||||
`runlevel` changes. If `<>` holds more [conditions](docs/conditions.md),
|
||||
these will also affect how a service is maintained.
|
||||
|
||||
**Note:** even though it is possible to start services not belonging in
|
||||
@@ -426,7 +490,7 @@ done slightly differently and on systems with udev you might want to add
|
||||
the following one-shot task early in your `/etc/finit.conf`:
|
||||
|
||||
```conf
|
||||
run [S] udevadm settle --timeout=120 -- Waiting for udev
|
||||
run [S] /sbin/udevadm settle --timeout=120 -- Waiting for udev
|
||||
```
|
||||
|
||||
Finit has a built-in Getty for TTYs, but requires a working `/bin/login`
|
||||
@@ -435,6 +499,9 @@ or `/bin/sh`, if no TTYs are configured in `/etc/finit.conf`.
|
||||
For a fully operational system `/var`, `/run` and `/tmp` must be set up
|
||||
properly in `/etc/fstab` -- which is iterated over at boot.
|
||||
|
||||
The built-in Inetd requires `/etc/services` and `/etc/protocols` to work
|
||||
with port names rather than numbers.
|
||||
|
||||
|
||||
Origin & References
|
||||
-------------------
|
||||
@@ -443,7 +510,7 @@ This project is based on the [original finit][] by [Claudio Matsuoka][]
|
||||
which was reverse engineered from syscalls of the [EeePC fastinit][] —
|
||||
"gaps filled with frog DNA …"
|
||||
|
||||
Finit is developed and maintained by [Joachim Wiberg][] at [GitHub][].
|
||||
Finit is developed and maintained by [Joachim Nilsson][] at [GitHub][].
|
||||
Please file bug reports, clone it, or send pull requests for bug fixes
|
||||
and proposed extensions.
|
||||
|
||||
@@ -466,12 +533,12 @@ and proposed extensions.
|
||||
[openrc]: http://www.gentoo.org/proj/en/base/openrc/
|
||||
[run-parts(8)]: http://manpages.debian.org/cgi-bin/man.cgi?query=run-parts
|
||||
[original finit]: http://helllabs.org/finit/
|
||||
[EeePC fastinit]: https://web.archive.org/web/20071208212450/http://wiki.eeeuser.com/boot_process:the_boot_process
|
||||
[EeePC fastinit]: http://wiki.eeeuser.com/boot_process:the_boot_process
|
||||
[Claudio Matsuoka]: https://github.com/cmatsuoka
|
||||
[Joachim Wiberg]: http://troglobit.com
|
||||
[Joachim Nilsson]: http://troglobit.com
|
||||
[GitHub]: https://github.com/troglobit/finit
|
||||
[License]: https://en.wikipedia.org/wiki/MIT_License
|
||||
[License Badge]: https://img.shields.io/badge/License-MIT-teal.svg
|
||||
[License Badge]: https://img.shields.io/badge/License-MIT-yellow.svg
|
||||
[Travis]: https://travis-ci.org/troglobit/finit
|
||||
[Travis Status]: https://travis-ci.org/troglobit/finit.png?branch=master
|
||||
[Coverity Scan]: https://scan.coverity.com/projects/3545
|
||||
|
||||
+72
-54
@@ -1,6 +1,5 @@
|
||||
AC_INIT(Finit, 4.0-rc1, https://github.com/troglobit/finit/issues, finit, https://troglobit.com/finit.html)
|
||||
AC_CONFIG_AUX_DIR(aux)
|
||||
AM_INIT_AUTOMAKE([1.11 foreign dist-xz subdir-objects])
|
||||
AC_INIT(Finit, 3.2-rc1, https://github.com/troglobit/finit/issues, finit, http://troglobit.com/finit.html)
|
||||
AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz subdir-objects])
|
||||
AM_SILENT_RULES([yes])
|
||||
|
||||
AC_CONFIG_SRCDIR([src/finit.c])
|
||||
@@ -10,17 +9,18 @@ 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
|
||||
doc/Makefile
|
||||
docs/Makefile
|
||||
plugins/Makefile
|
||||
src/Makefile
|
||||
test/test.env
|
||||
test/Makefile])
|
||||
src/Makefile])
|
||||
|
||||
# Older versions of autoconf (<2.58) do not have AC_CONFIG_MACRO_DIR()
|
||||
#m4_include([m4/plugin.m4])
|
||||
#m4_include([m4/expand.m4])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
# Change default prefix, we're PID 1 after all ...
|
||||
AC_PREFIX_DEFAULT([])
|
||||
|
||||
# Handle building plugins either as dynamically loadable, or built-in
|
||||
LT_INIT([shared disable-static dlopen aix-soname=both disable-fast-install])
|
||||
|
||||
@@ -40,12 +40,9 @@ AC_TYPE_UINT8_T
|
||||
AC_TYPE_UINT16_T
|
||||
AC_TYPE_UINT32_T
|
||||
|
||||
# Check for pkg-config first, warn if it's not installed
|
||||
PKG_PROG_PKG_CONFIG
|
||||
|
||||
# Check for required libraries
|
||||
PKG_CHECK_MODULES([uev], [libuev >= 2.2.0])
|
||||
PKG_CHECK_MODULES([lite], [libite >= 2.2.0])
|
||||
PKG_CHECK_MODULES([lite], [libite >= 2.0.1])
|
||||
|
||||
# Check for configured Finit features
|
||||
AC_ARG_ENABLE(emergency_shell,
|
||||
@@ -57,9 +54,13 @@ AC_ARG_ENABLE(fallback_shell,
|
||||
AS_HELP_STRING([--enable-fallback-shell], [Start a shell if no TTYs can start]),,[
|
||||
enable_fallback_shell=no])
|
||||
|
||||
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], [Pre Finit v3 bootup progress and heading]),,[
|
||||
enable_progress=no])
|
||||
|
||||
AC_ARG_ENABLE(watchdog,
|
||||
AS_HELP_STRING([--enable-watchdog], [Enable built-in watchdog, uses /dev/watchdog]),,[
|
||||
@@ -69,17 +70,17 @@ AC_ARG_ENABLE(redirect,
|
||||
AS_HELP_STRING([--enable-redirect], [Redirect service output to /dev/null, default: no]),,[
|
||||
enable_redirect_output=no])
|
||||
|
||||
AC_ARG_ENABLE(logit,
|
||||
AS_HELP_STRING([--disable-logit], [Disable logit, used for log redirection, default: enable]),,[
|
||||
enable_logit=yes])
|
||||
AC_ARG_ENABLE(inetd,
|
||||
AS_HELP_STRING([--disable-inetd], [Disable built-in inetd super server, default enabled]),,[
|
||||
enable_inetd=yes])
|
||||
|
||||
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(doc,
|
||||
AS_HELP_STRING([--disable-doc], [Disable build and install of doc/ section]),,[
|
||||
enable_doc=yes])
|
||||
AC_ARG_ENABLE(docs,
|
||||
AS_HELP_STRING([--disable-docs], [Disable build and install of docs section]),,[
|
||||
enable_docs=yes])
|
||||
|
||||
AC_ARG_ENABLE(contrib,
|
||||
AS_HELP_STRING([--disable-contrib], [Disable build and install of contrib section]),,[
|
||||
@@ -89,7 +90,11 @@ AC_ARG_ENABLE(contrib,
|
||||
enable_all_plugins=auto
|
||||
AC_PLUGIN([alsa-utils], [no], [Save and restore ALSA sound settings using alsactl])
|
||||
AC_PLUGIN([dbus], [no], [Setup and start system message bus, D-Bus])
|
||||
AC_PLUGIN([hotplug], [yes], [Setup and start udev or mdev hotplug daemon])
|
||||
AC_PLUGIN([inetd-echo], [no], [Inetd plugin: echo server, RFC862])
|
||||
AC_PLUGIN([inetd-chargen], [no], [Inetd plugin: character generator, RFC864])
|
||||
AC_PLUGIN([inetd-daytime], [no], [Inetd plugin: daytime server, RFC867])
|
||||
AC_PLUGIN([inetd-discard], [no], [Inetd plugin: discard server, RFC863])
|
||||
AC_PLUGIN([inetd-time], [no], [Inetd plugin: time (rdate) server, RFC868])
|
||||
AC_PLUGIN([modules-load], [no], [Scans /etc/modules-load.d for modules to load])
|
||||
AC_PLUGIN([resolvconf], [no], [Setup necessary files for resolvconf])
|
||||
AC_PLUGIN([x11-common], [no], [Console setup (for X)])
|
||||
@@ -98,35 +103,40 @@ AC_PLUGIN([netlink], [yes], [Basic netlink plugin for IFUP/IFDN and GW eve
|
||||
# Check for extra arguments or packages
|
||||
AC_ARG_WITH(heading,
|
||||
AS_HELP_STRING([--with-heading=GREET], [Display GREET instead of Finit version at boot]),
|
||||
[heading=$withval], [heading=yes])
|
||||
[heading=$withval], [heading="$PACKAGE_NAME v$PACKAGE_VERSION"])
|
||||
|
||||
AC_ARG_WITH(fifo,
|
||||
AS_HELP_STRING([--with-fifo=FIFO], [FIFO for init/telinit clients, default /var/run/initctl]),
|
||||
[fifo=$withval], [fifo=$localstatedir/run/initctl])
|
||||
|
||||
AC_ARG_WITH(config,
|
||||
AS_HELP_STRING([--with-config=CONFIG], [Finit bootstrap config file, default /etc/finit.conf]),
|
||||
[conf=$withval], [conf=yes])
|
||||
[conf=$withval], [conf=$sysconfdir/finit.conf])
|
||||
|
||||
AC_ARG_WITH(rcsd,
|
||||
AS_HELP_STRING([--with-rcsd=DIR], [Finit rcS.d/ directory, default /etc/finit.d]),
|
||||
[rcsd=$withval], [rcsd=yes])
|
||||
[rcsd=$withval], [rcsd=$sysconfdir/finit.d])
|
||||
|
||||
AC_ARG_WITH(rc-local,
|
||||
AS_HELP_STRING([--with-rc-local=FILE], [SysV init /etc/rc.local file, default /etc/rc.local]),
|
||||
[rclocal=$withval], [rclocal=yes])
|
||||
[rclocal=$withval], [rclocal=$sysconfdir/rc.local])
|
||||
|
||||
AC_ARG_WITH(sysconfig,
|
||||
AS_HELP_STRING([--with-sysconfig=DIR], [System environment, default /etc/default & /etc/conf.d]),
|
||||
[sysconfig=$withval], [sysconfig=default])
|
||||
AC_ARG_WITH(console,
|
||||
AS_HELP_STRING([--with-console=DEV], [Console to use, default: /dev/console]),
|
||||
[console=$withval], [console=/dev/console])
|
||||
|
||||
AC_ARG_WITH(hostname,
|
||||
AS_HELP_STRING([--with-hostname=NAME], [If /etc/hostname is missing, default: noname]),
|
||||
[hostname=$withval], [hostname=yes])
|
||||
[hostname=$withval], [hostname=noname])
|
||||
|
||||
AC_ARG_WITH(runlevel,
|
||||
AS_HELP_STRING([--with-runlevel=N], [Runlevel to switch to after bootstrap, default: 2]),
|
||||
[runlevel=$withval], [runlevel=yes])
|
||||
[runlevel=$withval], [runlevel=2])
|
||||
|
||||
AC_ARG_WITH(random-seed,
|
||||
AS_HELP_STRING([--with-random-seed=FILE], [Save a random seed for /dev/urandom across reboots, default /var/lib/misc/random-seed]),
|
||||
[random_seed=$withval], [random_seed=yes])
|
||||
[random_seed=$withval], [random_seed=/var/lib/misc/random-seed])
|
||||
|
||||
|
||||
### Enable features ###########################################################################
|
||||
|
||||
@@ -137,8 +147,13 @@ AS_IF([test "x$enable_emergency_shell" = "xyes"], [
|
||||
AS_IF([test "x$enable_fallback_shell" = "xyes"], [
|
||||
AC_DEFINE(FALLBACK_SHELL, 1, [Start /bin/sh on console if no TTYs.])])
|
||||
|
||||
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(SILENT_MODE, 0, [Pre Finit v3 bootup messages and heading])
|
||||
], [
|
||||
AC_DEFINE(SILENT_MODE, 1, [Completely silent until login prompt])])
|
||||
|
||||
AS_IF([test "x$enable_watchdog" = "xyes"], [
|
||||
AC_DEFINE(BUILTIN_WATCHDOG, 1, [Enable built-in watchdog, kicks on /dev/watchdog])])
|
||||
@@ -147,26 +162,31 @@ AS_IF([test "x$enable_redirect" = "xyes"], [
|
||||
AC_DEFINE(REDIRECT_OUTPUT, 1, [Enable redirection of service output to /dev/null])])
|
||||
|
||||
### Disable features ###########################################################################
|
||||
AS_IF([test "x$enable_logit" != "xno"], [
|
||||
AC_DEFINE(LOGIT_ENABLED, 1, [Enable logit tool, used for log redirection by Finit])])
|
||||
AS_IF([test "x$enable_inetd" != "xno"], [
|
||||
enable_inetd="yes"
|
||||
AC_DEFINE(INETD_ENABLED, 1, [Enable built-in inetd])])
|
||||
|
||||
AS_IF([test "x$enable_logrotate" != "xno"], [
|
||||
AC_DEFINE(LOGROTATE_ENABLED, 1, [Enable built-in rotation of /var/log/wtmp et al.])])
|
||||
|
||||
### With features ##############################################################################
|
||||
AS_IF([test "x$with_fifo" != "xno"], [
|
||||
AS_IF([test "x$fifo" = "xyes"], [
|
||||
fifo='$localstatedir/run/initctl'])])
|
||||
AC_EXPAND_DIR(fifo_path, "$fifo")
|
||||
AC_DEFINE_UNQUOTED(FINIT_FIFO, "$fifo_path", [FIFO for old style init/telinit client programs])
|
||||
|
||||
AS_IF([test "x$with_config" != "xno"], [
|
||||
AS_IF([test "x$conf" = "xyes"], [
|
||||
AS_IF([test "x$config" = "xyes"], [
|
||||
conf=$sysconfdir/finit.conf])])
|
||||
AC_EXPAND_DIR(conf_path, "$conf")
|
||||
AC_DEFINE_UNQUOTED(FINIT_CONF, "$conf_path", [Main Finit configuration file, default /etc/finit.conf])
|
||||
AC_SUBST(FINIT_CONF, "$conf_path")
|
||||
|
||||
AS_IF([test "x$with_rcsd" != "xno"], [
|
||||
AS_IF([test "x$rcsd" = "xyes"], [
|
||||
rcsd=$sysconfdir/finit.d])])
|
||||
AC_EXPAND_DIR(rcsd_path, "$rcsd")
|
||||
AC_DEFINE_UNQUOTED(FINIT_RCSD, "$rcsd_path", [Finit rcS.d/, default /etc/finit.d])
|
||||
AC_SUBST(FINIT_RCSD, "$rcsd_path")
|
||||
|
||||
AS_IF([test "x$with_rc_local" != "xno"], [
|
||||
AS_IF([test "x$rclocal" = "xyes"], [
|
||||
@@ -174,17 +194,16 @@ AS_IF([test "x$with_rc_local" != "xno"], [
|
||||
AC_EXPAND_DIR(rclocal_path, "$rclocal")
|
||||
AC_DEFINE_UNQUOTED(FINIT_RC_LOCAL, "$rclocal_path", [Compat SysV /etc/rc.local file to run last at boot.])
|
||||
|
||||
AS_IF([test "x$with_sysconfig" != "xno"], [
|
||||
AS_IF([test "x$sysconfig" != "xdefault"], [
|
||||
AC_EXPAND_DIR(sysconfig_path, "$sysconfig")
|
||||
AC_DEFINE_UNQUOTED(FINIT_SYSCONFIG, "$sysconfig_path",
|
||||
[System environment, default /etc/default & /etc/conf.d])])])
|
||||
|
||||
AS_IF([test "x$with_heading" != "xno"], [
|
||||
AS_IF([test "x$heading" = "xyes"], [
|
||||
heading="$PACKAGE_NAME v$PACKAGE_VERSION"])])
|
||||
AC_DEFINE_UNQUOTED(INIT_HEADING, "$heading", [Displayed by Finit at boot])
|
||||
|
||||
AS_IF([test "x$with_console" != "xno"], [
|
||||
AS_IF([test "x$console" = "xyes"], [
|
||||
console=/dev/console])])
|
||||
AC_DEFINE_UNQUOTED(CONSOLE, "$console", [Default console to use])
|
||||
|
||||
AS_IF([test "x$with_hostname" != "xno"], [
|
||||
AS_IF([test "x$hostname" = "xyes"], [
|
||||
hostname=noname])])
|
||||
@@ -192,8 +211,7 @@ AC_DEFINE_UNQUOTED(DEFHOST, "$hostname", [For /etc/hostname])
|
||||
|
||||
AS_IF([test "x$with_runlevel" != "xno"], [
|
||||
AS_IF([test "x$runlevel" = "xyes"], [
|
||||
runlevel=2
|
||||
AC_DEFINE_UNQUOTED(RUNLEVEL, $runlevel, [Default runlevel to start after S])])
|
||||
AC_DEFINE_UNQUOTED(RUNLEVEL, 2, [Default runlevel to start after S])])
|
||||
AC_DEFINE_UNQUOTED(RUNLEVEL, $runlevel, [Runlevel to start after S])])
|
||||
|
||||
AS_IF([test "x$with_random_seed" != "xno"], [
|
||||
@@ -204,9 +222,9 @@ AS_IF([test "x$with_random_seed" != "xno"], [
|
||||
|
||||
# Control build with automake flags
|
||||
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(DOC, [test "x$enable_doc" = "xyes"])
|
||||
AM_CONDITIONAL(DOCS, [test "x$enable_docs" = "xyes"])
|
||||
AM_CONDITIONAL(CONTRIB, [test "x$enable_contrib" = "xyes"])
|
||||
|
||||
# Override default libdir, used for plugins and rescue.conf
|
||||
@@ -221,8 +239,6 @@ AC_DEFINE_UNQUOTED(PLUGIN_PATH, "$plugin_path", [Finit plugin path])
|
||||
|
||||
AC_EXPAND_DIR(rescue_conf, "$libdir/finit/rescue.conf")
|
||||
AC_DEFINE_UNQUOTED(RESCUE_CONF, "$rescue_conf", [Finit rescue mode .conf])
|
||||
AC_EXPAND_DIR(sample_conf, "$libdir/finit/sample.conf")
|
||||
AC_DEFINE_UNQUOTED(SAMPLE_CONF, "$sample_conf", [Finit sameple.conf for initctl create])
|
||||
|
||||
# Generate all files
|
||||
AC_OUTPUT
|
||||
@@ -232,14 +248,13 @@ cat <<EOF
|
||||
------------------ Summary ------------------
|
||||
$PACKAGE_NAME version $PACKAGE_VERSION
|
||||
Prefix................: $prefix
|
||||
Exec prefix...........: $eprefix
|
||||
Sysconfdir............: `eval echo $sysconfdir`
|
||||
Localstatedir.........: `eval echo $localstatedir`
|
||||
FIFO path.............: $fifo_path
|
||||
Finit config file.....: $conf_path
|
||||
Finit config.d path...: $rcsd_path
|
||||
Finit plugin path.....: $plugin_path
|
||||
Compat rc.local path..: $rclocal_path
|
||||
System environment....: ${sysconfig_path:-${sysconfig}}
|
||||
Random seed path......: $random_path
|
||||
C Compiler............: $CC $CFLAGS $CPPFLAGS $LDFLAGS $LIBS
|
||||
Linker................: $LD $LLDP_LDFLAGS $LLDP_BIN_LDFLAGS $LDFLAGS $LIBS
|
||||
@@ -249,13 +264,16 @@ Behavior:
|
||||
Plugins...............: $plugins
|
||||
|
||||
Optional features:
|
||||
Install doc/..........: $enable_doc
|
||||
Install docs/.........: $enable_docs
|
||||
Install contrib/......: $enable_contrib
|
||||
Built-in inetd........: $enable_inetd
|
||||
Built-in watchdogd....: $enable_watchdog
|
||||
Built-in logrotate....: $enable_logrotate
|
||||
Scripting tool logit..: $enable_logit
|
||||
Emergency shell.......: $enable_emergency_shell
|
||||
Fallback shell........: $enable_fallback_shell
|
||||
Remount / RW at boot..: $enable_rw_rootfs
|
||||
Traditional progress..: $enable_progress
|
||||
Default console dev...: $console
|
||||
Default hostname......: $hostname
|
||||
Default runlevel......: $runlevel
|
||||
|
||||
|
||||
@@ -14,11 +14,12 @@ 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 \
|
||||
--prefix=/usr --exec-prefix= \
|
||||
--sysconfdir=/etc --localstatedir=/var \
|
||||
--enable-dbus-plugin --enable-x11-common-plugin \
|
||||
--enable-alsa-utils-plugin --enable-watchdog \
|
||||
--with-heading="Alpine Linux 3.13"
|
||||
--enable-rw-rootfs --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 \
|
||||
--enable-inetd-discard-plugin --enable-inetd-time-plugin \
|
||||
--with-heading="Alpine Linux 3.6" --with-hostname=alpine
|
||||
|
||||
echo
|
||||
echo "*** Building ..."
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
SUBDIRS = available
|
||||
docsdir := @docdir@/contrib/alpine/finit.d
|
||||
d_LINKS = acpid.conf crond.conf dropbear.conf getty.conf \
|
||||
keymap.conf modules.conf ntpd.conf \
|
||||
klogd.conf syslogd.conf
|
||||
d_LINKS = dropbear.conf getty.conf keymap.conf modules.conf klogd.conf \
|
||||
syslogd.conf
|
||||
|
||||
install-exec-hook:
|
||||
@$(MKDIR_P) $(DESTDIR)$(docsdir)/available
|
||||
@$(MKDIR_P) $(DESTDIR)$(docsdir)/enabled
|
||||
@for file in $(d_LINKS); do \
|
||||
lnk=$(DESTDIR)$(docsdir)/enabled/$$file; \
|
||||
lnk=$(DESTDIR)$(docsdir)/$$file; \
|
||||
src=available/$$file; \
|
||||
rm -f $$lnk; \
|
||||
$(LN_S) ../$$src $$lnk; \
|
||||
if [ -L $$lnk ]; then \
|
||||
echo "Skipping $$lnk exists."; \
|
||||
else \
|
||||
$(LN_S) $$src $$lnk; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
|
||||
uninstall-hook:
|
||||
@for file in $(d_LINKS); do \
|
||||
lnk=$(DESTDIR)$(docsdir)/enabled/$$file; \
|
||||
lnk=$(DESTDIR)$(docsdir)/$$file; \
|
||||
src=available/$$file; \
|
||||
$(RM) -f $$lnk; \
|
||||
if [ "`readlink $$lnk`" != "$$src" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
$(RM) $$lnk; \
|
||||
done
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
docsdir := @docdir@/contrib/alpine/finit.d/available
|
||||
docs_DATA = acpid.conf crond.conf dropbear.conf getty.conf keymap.conf \
|
||||
lxdm.conf modules.conf ntpd.conf klogd.conf syslog.conf \
|
||||
watchdog.conf
|
||||
docs_DATA = acpid.conf crond.conf dropbear.conf getty.conf keymap.conf \
|
||||
lxdm.conf modules.conf ntpd.conf klogd.conf syslogd.conf
|
||||
EXTRA_DIST = $(docs_DATA)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# Handle PWR button to shutdown/reboot -- useful in Qemu (virt-manager)
|
||||
# Depends on syslogd having started. Redirect any output to log.
|
||||
service [2345] <pid/syslogd> log acpid -f -- ACPI daemon
|
||||
service [2345] log <svc/sbin/syslogd> /sbin/acpid -f -- ACPI daemon
|
||||
|
||||
@@ -1 +1 @@
|
||||
service [2345] <pid/syslogd> env:-/etc/conf.d/crond crond -f -S $CRON_OPTS -- Cron daemon
|
||||
service [2345] <svc/sbin/syslogd> /usr/sbin/crond -f -S -c /etc/crontabs -- Cron daemon
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# Start SSH daemon as soon as basic networking comes up
|
||||
service [2345] env:-/etc/conf.d/dropbear dropbear -R -F $DROPBEAR_OPTS -- Dropbear SSH daemon
|
||||
service [2345] <net/lo/up> /usr/sbin/dropbear -R -F -p 22 -- Dropbear SSH daemon
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Consoles to start getty on when system is up
|
||||
tty [12345] /dev/tty1 noclear nowait
|
||||
tty [2345] /dev/tty2 noclear nowait
|
||||
tty [2345] /dev/tty3 noclear nowait
|
||||
tty /dev/tty1 noclear nowait
|
||||
tty /dev/tty2 noclear nowait
|
||||
tty /dev/tty3 noclear nowait
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# Oneshot task to run once at bootstrap
|
||||
task [S] env:/etc/conf.d/loadkmap zcat $KEYMAP | loadkmap -- Loading keymap
|
||||
task [S] zcat /etc/keymap/se.bmap.gz | loadkmap -- Loading keymap
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# Start klogd as soon as possible, after syslogd, should always run
|
||||
service [S12345] <pid/syslogd> env:-/etc/conf.d/klogd klogd -n $KLOGD_OPTS -- Kernel log daemon
|
||||
# Start klogd as soon as possible, should always run
|
||||
service [S12345] /sbin/klogd -n -- Kernel log daemon
|
||||
|
||||
@@ -1 +1 @@
|
||||
service [2345] lxdm -- Lightweight Login Manager
|
||||
service [2345] /usr/sbin/lxdm -- Lightweight Login Manager
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## Linux kernel modules to load
|
||||
#module fbcon
|
||||
#module button
|
||||
#module evdev
|
||||
#module mousedev
|
||||
#module 8139cp
|
||||
module button
|
||||
module evdev
|
||||
module mousedev
|
||||
module 8139cp
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# Busybox ntpd has no option to use syslog when running in foreground
|
||||
service [2345] <pid/syslogd> env:-/etc/conf.d/ntpd log ntpd -n $NTPD_OPTS -- NTP daemon
|
||||
# Silly Busybox ntpd has no option to use syslog when running in foreground
|
||||
service [2345] log <svc/sbin/syslogd> /usr/sbin/ntpd -n -N -p pool.ntp.org -- NTP daemon
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Start syslogd as soon as possible, should always run
|
||||
service [S12345] env:-/etc/conf.d/syslog syslogd -n $SYSLOGD_OPTS -- Syslog daemon
|
||||
@@ -0,0 +1,2 @@
|
||||
# Start syslogd as soon as possible, should always run
|
||||
service [S12345] /sbin/syslogd -n -- Syslog daemon
|
||||
@@ -1 +0,0 @@
|
||||
service [S123456789] env:-/etc/conf.d/watchdog watchdog $WATCHDOG_OPTS $WATCHDOG_DEV -- System watchdog
|
||||
+1
@@ -0,0 +1 @@
|
||||
available/dropbear.conf
|
||||
+1
@@ -0,0 +1 @@
|
||||
available/getty.conf
|
||||
+1
@@ -0,0 +1 @@
|
||||
available/keymap.conf
|
||||
+1
@@ -0,0 +1 @@
|
||||
available/klogd.conf
|
||||
+1
@@ -0,0 +1 @@
|
||||
available/modules.conf
|
||||
+1
@@ -0,0 +1 @@
|
||||
available/syslogd.conf
|
||||
@@ -29,7 +29,7 @@ if [ "x$yorn" = "xy" -o "x$yorn" = "xY" ]; then
|
||||
echo
|
||||
echo "*** Installing Finit files ..."
|
||||
make install
|
||||
cd /usr/share/doc/finit/contrib/alpine
|
||||
cd `dirname $0`
|
||||
for file in finit.conf rc.local; do
|
||||
install -vbD $file /etc/$file
|
||||
done
|
||||
@@ -41,11 +41,6 @@ if [ "x$yorn" = "xy" -o "x$yorn" = "xY" ]; then
|
||||
cd /sbin
|
||||
rm init
|
||||
ln -s finit init
|
||||
|
||||
rm halt shutdown suspend
|
||||
ln -s reboot halt
|
||||
ln -s reboot shutdown
|
||||
ln -s reboot suspend
|
||||
fi
|
||||
echo "*** Done"
|
||||
echo
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "x`id -u`" != "x0" ]; then
|
||||
echo
|
||||
echo "*** This script must run as root"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
read -p "Do you really want to uninstall Finit (y/N)? " yorn
|
||||
|
||||
if [ "x$yorn" = "xy" -o "x$yorn" = "xY" ]; then
|
||||
echo
|
||||
echo "*** Removing all Finit files ..."
|
||||
rm -rf /usr/share/doc/finit
|
||||
rm -rf /etc/finit.conf
|
||||
rm -rf /etc/finit.d
|
||||
rm -rf /lib/finit
|
||||
if [ -e /etc/rc.local ]; then
|
||||
echo "*** Skipping /etc/rc.local, not sure if we installed it ..."
|
||||
fi
|
||||
|
||||
echo "*** Restoring BusyBox as /sbin/init ..."
|
||||
cd /sbin
|
||||
rm init
|
||||
ln -s /bin/busybox init
|
||||
|
||||
rm halt shutdown reboot suspend
|
||||
ln -s /bin/busybox halt
|
||||
ln -s /bin/busybox shutdown
|
||||
ln -s /bin/busybox reboot
|
||||
ln -s /bin/busybox suspend
|
||||
echo "*** Done"
|
||||
echo
|
||||
else
|
||||
echo
|
||||
echo "*** Aborting uninstall."
|
||||
echo
|
||||
fi
|
||||
@@ -21,13 +21,14 @@ 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 \
|
||||
--prefix=/usr --exec-prefix= \
|
||||
--sysconfdir=/etc --localstatedir=/var \
|
||||
--enable-dbus-plugin --enable-x11-common-plugin \
|
||||
--enable-alsa-utils-plugin \
|
||||
--with-random-seed=/var/lib/urandom/random-seed \
|
||||
--with-heading="Debian GNU/Linux"
|
||||
./configure \
|
||||
--enable-rw-rootfs --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 \
|
||||
--enable-inetd-discard-plugin --enable-inetd-time-plugin \
|
||||
--with-random-seed=/var/lib/urandom/random-seed \
|
||||
--with-heading="Debian GNU/Linux" --with-hostname="stretch"
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo
|
||||
|
||||
@@ -5,18 +5,23 @@ d_LINKS = console-setup.conf getty.conf keyboard-setup.conf \
|
||||
|
||||
install-exec-hook:
|
||||
@$(MKDIR_P) $(DESTDIR)$(docsdir)/available
|
||||
@$(MKDIR_P) $(DESTDIR)$(docsdir)/enabled
|
||||
@for file in $(d_LINKS); do \
|
||||
lnk=$(DESTDIR)$(docsdir)/enabled/$$file; \
|
||||
lnk=$(DESTDIR)$(docsdir)/$$file; \
|
||||
src=available/$$file; \
|
||||
rm -f $$lnk; \
|
||||
$(LN_S) ../$$src $$lnk; \
|
||||
if [ -L $$lnk ]; then \
|
||||
echo "Skipping $$lnk exists."; \
|
||||
else \
|
||||
$(LN_S) $$src $$lnk; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
|
||||
uninstall-hook:
|
||||
@for file in $(d_LINKS); do \
|
||||
lnk=$(DESTDIR)$(docsdir)/enabled/$$file; \
|
||||
lnk=$(DESTDIR)$(docsdir)/$$file; \
|
||||
src=available/$$file; \
|
||||
$(RM) -f $$lnk; \
|
||||
if [ "`readlink $$lnk`" != "$$src" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
$(RM) $$lnk; \
|
||||
done
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
docsdir := @docdir@/contrib/debian/finit.d/available
|
||||
docs_DATA = acpid.conf console-setup.conf getty.conf keyboard-setup.conf \
|
||||
lightdm.conf modules.conf rsyslogd.conf sntpd.conf \
|
||||
sshd.conf syslogd.conf xdm.conf
|
||||
docs_DATA = acpid.conf console-setup.conf getty.conf \
|
||||
keyboard-setup.conf lightdm.conf modules.conf \
|
||||
ntpclient.conf rsyslogd.conf sshd.conf xdm.conf
|
||||
EXTRA_DIST = $(docs_DATA)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# Handle PWR button to shutdown/reboot -- useful in Qemu (virt-manager)
|
||||
# Depends on a syslog daemon having started. Redirect any output to log.
|
||||
service [2345] <pid/syslogd> env:-/etc/default/acpid log acpid -f $OPTIONS -- ACPI daemon
|
||||
# Depends on rsyslogd having started. Redirect any output to log.
|
||||
service [2345] <svc/usr/sbin/rsyslogd> log /usr/sbin/acpid -f -- ACPI daemon
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Consoles to start getty on when system is up
|
||||
tty [12345] /dev/tty1 linux noclear nowait
|
||||
tty [2345] /dev/tty2 linux noclear nowait
|
||||
tty [2345] /dev/tty3 linux noclear nowait
|
||||
tty [12345] /dev/tty1 115200 vt100 noclear nowait
|
||||
tty [2345] /dev/tty2 38400 linux noclear nowait
|
||||
tty [2345] /dev/tty3 38400 linux noclear nowait
|
||||
|
||||
@@ -1 +1 @@
|
||||
service [3] lightdm -- Light Display Manager
|
||||
service [3] /usr/sbin/lightdm -- Light Display Manager
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
## Linux kernel modules to load
|
||||
#module fbcon
|
||||
#module button
|
||||
#module evdev
|
||||
#module loop
|
||||
#module psmouse
|
||||
#module mousedev
|
||||
#module 8139cp
|
||||
module button
|
||||
module evdev
|
||||
module loop
|
||||
module psmouse
|
||||
module mousedev
|
||||
module 8139cp
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
# Simple NTP client (SNTP)
|
||||
service [2345] <net/route/default> /usr/sbin/ntpclient -n -L pool.ntp.org -- SNTP client
|
||||
@@ -1,3 +1,2 @@
|
||||
# Start rsyslogd as soon as possible, should always run
|
||||
# Provides pid/syslogd condition
|
||||
service [S12345] name:syslogd env:-/etc/default/rsyslog rsyslogd -n $RSYSLOGD_OPTIONS -- Reliable syslog daemon
|
||||
service [S12345] /usr/sbin/rsyslogd -n -- Reliable and extended syslog daemon
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Simple NTP client (SNTP)
|
||||
service [2345] <net/route/default> env:-/etc/default/sntpd sntpd -n $SNTPD_OPTIONS -- SNTP client
|
||||
@@ -1,2 +1,2 @@
|
||||
# Start SSH daemon as soon as basic networking comes up
|
||||
service [2345] <net/lo/up> env:-/etc/default/ssh /usr/sbin/sshd -D $SSHD_OPTS -- OpenSSH daemon
|
||||
service [2345] <net/lo/up> /usr/sbin/sshd -D -- OpenSSH daemon
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Start sysklogd as soon as possible, should always run if enabled
|
||||
service [S123456789] env:-/etc/default/syslogd syslogd -F $SYSLOGD_OPTIONS -- System logging daemon
|
||||
@@ -1,4 +1,4 @@
|
||||
# Here we use XDM since it has few dependencies (relatively speaking).
|
||||
# It is also an example of a service without a -- description.
|
||||
# service [3] lxdm -- Lightweight Login Manager
|
||||
service [3] xdm -nodaemon -- X Display Manager
|
||||
# service [3] /usr/sbin/lxdm -- Lightweight Login Manager
|
||||
service [3] /usr/bin/xdm -nodaemon
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
available/console-setup.conf
|
||||
+1
@@ -0,0 +1 @@
|
||||
available/getty.conf
|
||||
@@ -0,0 +1 @@
|
||||
available/keyboard-setup.conf
|
||||
+1
@@ -0,0 +1 @@
|
||||
available/modules.conf
|
||||
+1
@@ -0,0 +1 @@
|
||||
available/rsyslogd.conf
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
available/sshd.conf
|
||||
@@ -31,10 +31,8 @@ echo
|
||||
if [ "x$yorn" = "xy" -o "x$yorn" = "xY" ]; then
|
||||
echo "Installing Finit files ..."
|
||||
make install
|
||||
cd /usr/share/doc/finit/contrib/debian
|
||||
for file in finit.conf; do
|
||||
install -vbD $file /etc/$file
|
||||
done
|
||||
cd `dirname $0`
|
||||
install -vbD finit.conf /etc/finit.conf
|
||||
cp -va finit.d /etc/
|
||||
|
||||
echo "*** Setting up a GRUB boot entry ..."
|
||||
|
||||
+16
-6
@@ -2,6 +2,9 @@
|
||||
#
|
||||
host testbed
|
||||
|
||||
# Devices to fsck at boot
|
||||
check /dev/vda1
|
||||
|
||||
# Linux kernel modules to load
|
||||
module button
|
||||
module evdev
|
||||
@@ -30,21 +33,28 @@ tty /dev/tty3
|
||||
#run [2] /etc/init.d/networking start -- Start networking
|
||||
|
||||
# Services to be monitored and respawned as needed
|
||||
service [2345] <pid/syslogd> klogd -n -- Kernel logging server
|
||||
service [2345] syslogd -n -- Syslog server
|
||||
service [3] gdm -- GNOME Display Manager
|
||||
service [2345] /sbin/klogd -n -- Kernel logging server
|
||||
service [2345] /sbin/syslogd -n -- Syslog server
|
||||
service [3] /usr/sbin/gdm -- GNOME Display Manager
|
||||
|
||||
# The BusyBox ntpd does not use syslog when running in the foreground
|
||||
# So we use this trick to redirect stdout/stderr to a log file. The
|
||||
# log file is rotated with the above settings. The condition declares
|
||||
# a dependency on a system default route (gateway) to be set. A single
|
||||
# <!> at the beginning means ntpd does not respect SIGHUP for restart.
|
||||
service [2345] <!net/route/default> log:/var/log/ntpd.log ntpd -n -l -I eth0 -- NTP daemon
|
||||
service [2345] log:/var/log/ntpd.log <!net/route/default> /sbin/ntpd -n -l -I eth0 -- NTP daemon
|
||||
|
||||
# Run start scripts from this directory
|
||||
# runparts /etc/start.d
|
||||
|
||||
# Inetd services
|
||||
inetd time/udp wait [2345] internal -- UNIX rdate service
|
||||
inetd time/tcp nowait [2345] internal -- UNIX rdate service
|
||||
inetd ssh@eth0:222/tcp nowait [2345] /usr/sbin/sshd -i -- SSH service
|
||||
inetd ssh/tcp nowait [2345] /usr/sbin/sshd -i -- SSH service
|
||||
|
||||
# For multiple instances of the same service, add :ID somewhere between
|
||||
# the service/run/task keyword and the command.
|
||||
service :80 [2345] /sbin/httpd -f -h /http -p 80 -- Web server
|
||||
service :8080 [2345] /sbin/httpd -f -h /http -p 8080 -- Old web server
|
||||
service :1 [2345] /sbin/httpd -f -h /http -p 80 -- Web server
|
||||
service :2 [2345] /sbin/httpd -f -h /http -p 8080 -- Old web server
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
# This is a basic /etc/fstab that mounts up all of the virtual filesystems
|
||||
# that older versions of Finit used to mount internally. It can serve as a
|
||||
# starting point for systems running Busybox's mount implementation. Make
|
||||
# sure that CONFIG_FEATURE_MOUNT_HELPERS enabled; as this is required
|
||||
# create the /dev/{pts,shm} directories.
|
||||
|
||||
devtmpfs /dev devtmpfs defaults 0 0
|
||||
mkdir#-p /dev/pts helper none 0 0
|
||||
devpts /dev/pts devpts mode=620,ptmxmode=0666 0 0
|
||||
mkdir#-p /dev/shm helper none 0 0
|
||||
tmpfs /dev/shm tmpfs mode=0777 0 0
|
||||
proc /proc proc defaults 0 0
|
||||
tmpfs /tmp tmpfs mode=1777,nosuid,nodev 0 0
|
||||
tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0
|
||||
sysfs /sys sysfs defaults 0 0
|
||||
@@ -14,11 +14,12 @@ 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 \
|
||||
--prefix=/usr --exec-prefix= \
|
||||
--sysconfdir=/etc --localstatedir=/var \
|
||||
--enable-dbus-plugin --enable-x11-common-plugin \
|
||||
--enable-alsa-utils-plugin --enable-watchdog \
|
||||
--with-heading="Void Linux"
|
||||
--enable-rw-rootfs --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 \
|
||||
--enable-inetd-discard-plugin --enable-inetd-time-plugin \
|
||||
--with-heading="Void Linux" --with-hostname=void
|
||||
|
||||
echo
|
||||
echo "*** Building ..."
|
||||
|
||||
@@ -4,18 +4,23 @@ d_LINKS = acpid.conf dhcpcd.conf getty.conf sshd.conf uuidd.conf
|
||||
|
||||
install-exec-hook:
|
||||
@$(MKDIR_P) $(DESTDIR)$(docsdir)/available
|
||||
@$(MKDIR_P) $(DESTDIR)$(docsdir)/enabled
|
||||
@for file in $(d_LINKS); do \
|
||||
lnk=$(DESTDIR)$(docsdir)/enabled/$$file; \
|
||||
lnk=$(DESTDIR)$(docsdir)/$$file; \
|
||||
src=available/$$file; \
|
||||
rm -f $$lnk; \
|
||||
$(LN_S) ../$$src $$lnk; \
|
||||
if [ -L $$lnk ]; then \
|
||||
echo "Skipping $$lnk exists."; \
|
||||
else \
|
||||
$(LN_S) $$src $$lnk; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
|
||||
uninstall-hook:
|
||||
@for file in $(d_LINKS); do \
|
||||
lnk=$(DESTDIR)$(docsdir)/enabled/$$file; \
|
||||
lnk=$(DESTDIR)$(docsdir)/$$file; \
|
||||
src=available/$$file; \
|
||||
$(RM) -f $$lnk; \
|
||||
if [ "`readlink $$lnk`" != "$$src" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
$(RM) $$lnk; \
|
||||
done
|
||||
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
available/acpid.conf
|
||||
@@ -1,3 +1,3 @@
|
||||
# Handle PWR button to shutdown/reboot -- useful in Qemu (virt-manager)
|
||||
# Depends on syslogd having started. Redirect any output to log.
|
||||
service [2345] acpid -f -- ACPI daemon
|
||||
service [2345] /sbin/acpid -f -- ACPI daemon
|
||||
|
||||
@@ -1 +1 @@
|
||||
service [2345] <pid/syslogd> crond -f -S -c /etc/crontabs -- Cron daemon
|
||||
service [2345] <svc/sbin/syslogd> /usr/sbin/crond -f -S -c /etc/crontabs -- Cron daemon
|
||||
|
||||
@@ -1 +1 @@
|
||||
service [2345] dhcpcd -B -M -- DHCP client
|
||||
service [2345] /usr/sbin/dhcpcd -B -M -- DHCP client
|
||||
|
||||
@@ -1 +1 @@
|
||||
service [S12345] dmeventd -f -- Device mapper event daemon
|
||||
service [S12345] /sbin/dmeventd -f -- Device mapper event daemon
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Consoles to start Finit built-in getty on when system is up
|
||||
tty [12345] /dev/tty1 noclear nowait
|
||||
tty [2345] /dev/tty2 noclear nowait
|
||||
tty [2345] /dev/tty3 noclear nowait
|
||||
tty /dev/tty1 noclear nowait
|
||||
tty /dev/tty2 noclear nowait
|
||||
tty /dev/tty3 noclear nowait
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# Start klogd as soon as possible, should always run
|
||||
service [S12345] <pid/syslogd> klogd -n -- Kernel log daemon
|
||||
service [S12345] /sbin/klogd -n -- Kernel log daemon
|
||||
|
||||
@@ -1 +1 @@
|
||||
service [2345] lxdm -- Lightweight Login Manager
|
||||
service [2345] /usr/sbin/lxdm -- Lightweight Login Manager
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## Linux kernel modules to load
|
||||
#module fbcon
|
||||
#module button
|
||||
#module evdev
|
||||
#module mousedev
|
||||
#module 8139cp
|
||||
module button
|
||||
module evdev
|
||||
module mousedev
|
||||
module 8139cp
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# Silly Busybox ntpd has no option to use syslog when running in foreground
|
||||
service [2345] <pid/syslogd> log ntpd -n -N -p pool.ntp.org -- NTP daemon
|
||||
service [2345] log <svc/sbin/syslogd> /usr/sbin/ntpd -n -N -p pool.ntp.org -- NTP daemon
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# Start SSH daemon as soon as basic networking comes up
|
||||
service [2345] /usr/sbin/sshd -D -- OpenSSH daemon
|
||||
service [2345] <net/lo/up> /usr/sbin/sshd -D -- OpenSSH daemon
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# Start syslogd as soon as possible, should always run
|
||||
service [S12345] syslogd -n -- Syslog daemon
|
||||
service [S12345] /sbin/syslogd -n -- Syslog daemon
|
||||
|
||||
@@ -1 +1 @@
|
||||
service @uuidd:uuidd [2345] uuidd -F -- UUID generation daemon
|
||||
service @uuidd:uuidd [2345] /sbin/uuidd -F -- UUID generation daemon
|
||||
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
available/dhcpcd.conf
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
available/getty.conf
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
available/sshd.conf
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
available/uuidd.conf
|
||||
@@ -30,7 +30,7 @@ if [ "x$yorn" = "xy" -o "x$yorn" = "xY" ]; then
|
||||
echo
|
||||
echo "*** Installing Finit files ..."
|
||||
make install
|
||||
cd /usr/share/doc/finit/contrib/void
|
||||
cd `dirname $0`
|
||||
for file in finit.conf rc.local; do
|
||||
install -vbD $file /etc/$file
|
||||
done
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
docsdir := @docdir@/doc
|
||||
docs_DATA = config.md conditions.md distro.md plugins.md \
|
||||
service.md signals.md svc-machine.png cmdline.md
|
||||
EXTRA_DIST = $(docs_DATA)
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
Goals of Finit
|
||||
==============
|
||||
|
||||
Initially Finit aimed to be more than a processes monitor, acting as a
|
||||
replacement for cron/at and inetd as well. Over time, however, the true
|
||||
value in the project turned out to be:
|
||||
|
||||
> A simple SysV init and systemd replacement, primarily for embedded
|
||||
> systems, container, and dedicated server applications.
|
||||
|
||||
|
||||
Misc TODOs
|
||||
----------
|
||||
|
||||
Some of these are also registered in the issue tracker on GitHub.
|
||||
|
||||
* Refactor the .conf parser, parse user input in a separate process
|
||||
* Move process monitor to separate process (same as parser?)
|
||||
* Add new (complimentary) .svc file format to slowly migrate away
|
||||
from the very terse one-liner format currently used
|
||||
* Allow running as non-pid1 => read .conf and RCSD form cmdline
|
||||
* When a process dies, and Finit does not restart it, we should collect
|
||||
a `siginfo_t` from the SIGCHLD signal and supply to the user in case
|
||||
`initctl status <process>` is called to debug the issue.
|
||||
* Add `finit.conf` support for UPS notification (SIGPWR) to start a task
|
||||
using, e.g. <sys/power/{ok,fail,low}> conditions. More info in sig.c
|
||||
* Add `finit.conf` support for ctrl-alt-delete (SIGINT) and kbrequest,
|
||||
i.e. KeyboardSignal, (SIGWINCH) behavior. Using conditions to a task,
|
||||
e.g, <sys/key/ctrlaltdel> and <sys/key/signal> like SIGPWR handling.
|
||||
* Write man pages for finit and `finit.conf`, steal from the excellent
|
||||
`pimd` man pages ...
|
||||
* Add support for timed shutdown in Finit, including cancelled shutdown
|
||||
* Add support for JSON output, or similar, from `initctl show`, e.g.
|
||||
`initctl show --json`
|
||||
|
||||
|
||||
Init
|
||||
----
|
||||
|
||||
Finit in itself is not SysV Init compatible, it doesn't use `/etc/rc.d`
|
||||
and `/etc/init.d` scripts to boot the system. However, a plausible way
|
||||
to achieve compatibility would be to add a plugin to finit which reads
|
||||
`/etc/inittab` to be able to start standard Linux systems.
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
Tips & Tricks with the kernel cmdline
|
||||
=====================================
|
||||
|
||||
This document summarizes the different boot parameters that can be
|
||||
passed on the Linux kernel command line. Not limited to Finit.
|
||||
|
||||
The `bool` setting is one of `on, off, true false, 1, 0`.
|
||||
|
||||
|
||||
* `debug`: Enable kernel debug. Debug messages are printed to the
|
||||
console until Finit starts up.
|
||||
|
||||
* `finit.debug[=bool]`: Enable finit debug. This is operated
|
||||
independently of the kernel debug setting. New as of Finit v4.
|
||||
|
||||
* `finit.show_status[=bool]`: Control finit boot progress, including
|
||||
banner.
|
||||
|
||||
* `finit.status_style=<classic,modern>`: Set Finit boot progress style,
|
||||
when enabled.
|
||||
|
||||
* `init=/bin/sh`: Bypass system default init and tell kernel to start a
|
||||
shell. Note, this shell is very limited and does not support
|
||||
signals and has no job control. Recommend using, and modifying,
|
||||
`rescue` mode instead.
|
||||
|
||||
* `panic=SEC`: By default the kernel does not reboot after a kernel
|
||||
panic. This setting will cause a kernel reboot after SEC seconds.
|
||||
|
||||
* `quiet`: Suppress kernel logging to console, except for warnings and
|
||||
errors.
|
||||
|
||||
* `rescue`: Start Finit rescue mode; no network, no `fsck` of file
|
||||
systems in `/etc/fstab`, no `/etc/rc.local`, no `runparts`. The
|
||||
configuration is read from `/lib/finit/rescue.conf`, and can be
|
||||
modified by the operator.
|
||||
|
||||
* `single`, or `S`: Single user mode, runlevel 1, in Finit. Useful to
|
||||
debug problems with the regular runlevel. All services and TTYs in
|
||||
`[1]` will be started, so a `tty [1] @console nologin` configuration
|
||||
presents you with a root console without login.
|
||||
|
||||
For more on kernel boot paramaters, see the man page [bootparam(7)][].
|
||||
|
||||
|
||||
[bootparam(7)]: https://www.man7.org/linux/man-pages/man7/bootparam.7.html
|
||||
-510
@@ -1,510 +0,0 @@
|
||||
Configuration
|
||||
=============
|
||||
|
||||
* [Introduction](#introduction)
|
||||
* [Service Wrapper Scripts](#service-wrapper-scripts)
|
||||
* [Configuration File Syntax](#configuration-file-syntax)
|
||||
* [Hostname](#hostname)
|
||||
* [Kernel Modules](#kernel-modules)
|
||||
* [Networking](#networking)
|
||||
* [Resource Limits](#resource-limits)
|
||||
* [Runlevels](#runlevels)
|
||||
* [One-shot Commands (sequence)](#one-shot-commands--sequence-)
|
||||
* [One-shot Commands (parallel)](#one-shot-commands--parallel-)
|
||||
* [SysV Init Scripts](#sysv-init-scripts)
|
||||
* [Services](#services)
|
||||
* [Run-parts Scripts](#run-parts-scripts)
|
||||
* [Including Finit Configs](#including-finit-configs)
|
||||
* [General Logging](#general-logging)
|
||||
* [TTYs and Consoles](#ttys-and-consoles)
|
||||
* [Non-privileged Services](#non-privileged-services)
|
||||
* [Redirecting Output](#redirecting-output)
|
||||
* [Limitations](#limitations)
|
||||
* [/etc/finit.conf](#etcfinitconf)
|
||||
* [/etc/finit.d](#etcfinitd)
|
||||
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
Finit can be configured using only the original `/etc/finit.conf` file
|
||||
or in combination with `/etc/finit.d/*.conf`. Useful for package-based
|
||||
Linux distributions -- each package can provide its own "script" file.
|
||||
|
||||
- `/etc/finit.conf`: main configuration file
|
||||
- `/etc/finit.d/*.conf`: snippets, usually one service per file
|
||||
|
||||
Not all configuration directives are available in `/etc/finit.d/*.conf`
|
||||
and some directives are only available at bootstrap, runlevel `S`, see
|
||||
the section [Limitations](#limitations) below for details.
|
||||
|
||||
To add a new service, simply drop a `.conf` file in `/etc/finit.d` and
|
||||
run `initctl reload`. (It is also possible to `SIGHUP` to PID 1, or
|
||||
call `finit q`, but that has been deprecated with the `initctl` tool).
|
||||
Finit monitors all known active `.conf` files, so if you want to force
|
||||
a restart of any service you can simply touch its corresponding `.conf`
|
||||
file in `/etc/finit.d` and call `initctl reload`. Finit handle any
|
||||
and all conditions and dependencies between services automatically.
|
||||
|
||||
It is also possible to drop `.conf` files in `/etc/finit.d/available/`
|
||||
and use `initctl enable` to enable a service `.conf` file. This may be
|
||||
useful in particular to Linux distributions that may want to install all
|
||||
files for a package and let the user decide when to enable a service.
|
||||
|
||||
On `initctl reload` the following is checked for all services:
|
||||
|
||||
- If a service's `.conf` file has been removed, or its conditions are no
|
||||
longer satisifed, the service is stopped.
|
||||
- If the file is modified, or a service it depends on has been reloaded,
|
||||
the service is reloaded (stopped and started).
|
||||
- If a new service is added it is automatically started — respecting
|
||||
runlevels and return values from any callbacks.
|
||||
|
||||
For more info on the different states of a service, see the separate
|
||||
document [Finit Services](service.md).
|
||||
|
||||
> When running <kbd>make install</kbd> no default `/etc/finit.conf` is
|
||||
> installed since system requirements differ too much. There are some
|
||||
> examples in the `contrib/` directory, which can be used as a base.
|
||||
|
||||
|
||||
Service Environment
|
||||
-------------------
|
||||
|
||||
Finit supports sourcing environment variables from `/etc/default/*`, or
|
||||
similar `--with-sysconfig=DIR`. This is a common pattern from SysV init
|
||||
scripts, where the start-stop script is a generic script for the given
|
||||
service, `foo`, and the options for the service are sourced from the
|
||||
file `/etc/default/foo`. Like this:
|
||||
|
||||
* `/etc/default/foo`:
|
||||
|
||||
FOO_OPTIONS=--extra-arg="bar" -s -x
|
||||
|
||||
* `/etc/finit.conf`:
|
||||
|
||||
service [2345] env:-/etc/default/foo foo -n $FOO_OPTIONS -- Example foo daemon
|
||||
|
||||
Here the service `foo` is started with `-n`, to make sure it runs in the
|
||||
foreground, and the with the options found in the environment file. With
|
||||
the `ps` command we can see that the process is started with:
|
||||
|
||||
foo -n --extra-arg=bar -s -x
|
||||
|
||||
> **Note:** the leading `-` determines if Finit should treat a missing
|
||||
> environment file as blocking the start of the service or not. When
|
||||
> `-` is used, a missing environment file does *not* block the start.
|
||||
|
||||
|
||||
Service Wrapper Scripts
|
||||
-----------------------
|
||||
|
||||
If your service requires to run additional commands, executed before the
|
||||
service is actually started, like the systemd `ExecStartPre`, you can
|
||||
use a wrapper shell script to start your service.
|
||||
|
||||
The Finit service `.conf` file can be put into `/etc/finit.d/available`,
|
||||
so you can control the service using `initctl`. Then use the path to
|
||||
the wrapper script in the Finit `.conf` service stanza. The following
|
||||
example employs a wrapper script in `/etc/start.d`.
|
||||
|
||||
**Example:**
|
||||
|
||||
* `/etc/finit.d/available/program.conf`:
|
||||
|
||||
service [235] <!> /etc/start.d/program -- Example Program
|
||||
|
||||
* `/etc/start.d/program:`
|
||||
|
||||
#!/bin/sh
|
||||
# Prepare the command line options
|
||||
OPTIONS="-u $(cat /etc/username)"
|
||||
|
||||
# Execute the program
|
||||
exec /usr/bin/program $OPTIONS
|
||||
|
||||
> **Note:** the example sets `<!>` to denote that it doesn't support
|
||||
> `SIGHUP`. That way Finit will stop/start the service
|
||||
> instead of sending SIGHUP at restart/reload events.
|
||||
|
||||
|
||||
Configuration File Syntax
|
||||
-------------------------
|
||||
|
||||
### Hostname
|
||||
|
||||
**Syntax:** `host <NAME>`, or `hostname <NAME>`
|
||||
|
||||
Set system hostname to NAME, unless `/etc/hostname` exists in which case
|
||||
the contents of that file is used.
|
||||
|
||||
Deprecated. We recommend using `/etc/hostname` instead.
|
||||
|
||||
> **Note:** only read and executed in runlevel S (bootstrap).
|
||||
|
||||
|
||||
### Kernel Modules
|
||||
|
||||
**Syntax:** `module <MODULE> [ARGS]`
|
||||
|
||||
Load a kernel module, with optional arguments. Similar to `insmod`
|
||||
command line tool.
|
||||
|
||||
Deprecated, there is both a `modules-load.so` and a `modprobe.so` plugin
|
||||
that can handle module loading better. The former supports loading from
|
||||
`/etc/modules-load.d/`, the latter uses kernel modinfo to automatically
|
||||
load (or coldplug) every required module. For hotplug we recommend the
|
||||
BusyBox mdev tool, add to `/etc/mdev.conf`:
|
||||
|
||||
$MODALIAS=.* root:root 0660 @modprobe -b "$MODALIAS"
|
||||
|
||||
> **Note:** only read and executed in runlevel S (bootstrap).
|
||||
|
||||
|
||||
### Networking
|
||||
|
||||
**Syntax:** `network <PATH>`
|
||||
|
||||
Script or program to bring up networking, with optional arguments.
|
||||
|
||||
Deprecated. We recommend using dedicated task/run stanzas per runlevel,
|
||||
or `/etc/network/interfaces` if you have a system with `ifupdown`, like
|
||||
Debian, Ubuntu, Linux Mint, or an embedded BusyBox system.
|
||||
|
||||
> **Note:** only read and executed in runlevel S (bootstrap).
|
||||
|
||||
|
||||
### Resource Limits
|
||||
|
||||
**Syntax:** `rlimit [hard|soft] RESOURCE <LIMIT|unlimited>`
|
||||
|
||||
Set the hard or soft limit for a resource, or both if that argument is
|
||||
omitted. `RESOURCE` is the lower-case `RLIMIT_` string constants from
|
||||
`setrlimit(2)`, without prefix. E.g. to set `RLIMIT_CPU`, use `cpu`.
|
||||
|
||||
LIMIT is an integer that depends on the resource being modified, see
|
||||
the man page, or the kernel `/proc/PID/limits` file, for details.
|
||||
Finit versions before v3.1 used `infinity` for `unlimited`, which is
|
||||
still supported, albeit deprecated.
|
||||
|
||||
# No process is allowed more than 8MB of address space
|
||||
rlimit hard as 8388608
|
||||
|
||||
# Core dumps may be arbitrarily large
|
||||
rlimit soft core infinity
|
||||
|
||||
# CPU limit for all services, soft & hard = 10 sec
|
||||
rlimit cpu 10
|
||||
|
||||
`rlimit` can be set globally, in `/etc/finit.conf`, or locally per
|
||||
each `/etc/finit.d/*.conf` read. I.e., a set of task/run/service
|
||||
stanzas can share the same rlimits if they are in the same .conf.
|
||||
|
||||
|
||||
### Runlevels
|
||||
|
||||
**Syntax:** `runlevel <N>`
|
||||
|
||||
Defines the system runlevel to go to after bootstrap (S) has completed.
|
||||
N is the runlevel number 0-9, where 6 is reserved for reboot and 0 for
|
||||
halt.
|
||||
|
||||
Default: 2
|
||||
|
||||
> **Note:** only read and executed in runlevel S (bootstrap).
|
||||
|
||||
|
||||
### One-shot Commands (sequence)
|
||||
|
||||
**Syntax:** `run [LVLS] <COND> /path/to/cmd ARGS -- Optional description`
|
||||
|
||||
One-shot command to run in sequence when entering a runlevel, with
|
||||
optional arguments and description.
|
||||
|
||||
`run` commands are guaranteed to be completed before running the next
|
||||
command. Highly useful if true serialization is needed.
|
||||
|
||||
> `<COND>` is described in the [Services](#services) section.
|
||||
|
||||
|
||||
### One-shot Commands (parallel)
|
||||
|
||||
**Syntax:** `task [LVLS] <COND> /path/to/cmd ARGS -- Optional description`
|
||||
|
||||
One-shot like 'run', but starts in parallel with the next command.
|
||||
|
||||
Both `run` and `task` commands are run in a shell, so pipes and
|
||||
redirects can be freely used:
|
||||
|
||||
task [s] echo "foo" | cat >/tmp/bar
|
||||
|
||||
> `<COND>` is described in the [Services](#services) section.
|
||||
|
||||
|
||||
### SysV Init Scripts
|
||||
|
||||
**Syntax:** `sysv [LVLS] <COND> /path/to/init-script -- Optional description`
|
||||
|
||||
Similar to `task` is the `sysv` stanza, which can be used to call SysV
|
||||
style scripts. The primary intention for this command is to be able to
|
||||
re-use much of existing setup and init scripts in Linux distributions.
|
||||
|
||||
When entering an allowed runlevel, Finit calls `init-script start`, when
|
||||
entering a disallowed runlevel, Finit calls `init-script stop`, and if
|
||||
the Finit .conf, where `sysv` stanza is declared, is modified, Finit
|
||||
calls `init-script restart` on `initctl reload`. Similar to how
|
||||
`service` stanzas work.
|
||||
|
||||
Forking services started with `sysv` scripts can be monitored by Finit
|
||||
by declaring the PID file to look for: `pid:!/path/to/pidfile.pid`.
|
||||
|
||||
> `<COND>` is described in the [Services](#services) section.
|
||||
|
||||
|
||||
### Services
|
||||
|
||||
**Syntax:** `service [LVLS] <COND> /path/to/daemon ARGS -- Optional description`
|
||||
|
||||
Service, or daemon, to be monitored and automatically restarted if it
|
||||
exits prematurely. Finit tries to restart services that die 10 times
|
||||
before giving up, then you have to `initctl restart NAME` it manually.
|
||||
|
||||
For daemons that support it, we recommend appending `--foreground`,
|
||||
`--no-background`, `-n`, `-F`, or similar command line argument to
|
||||
prevent them from forking off a sub-process in the background. This is
|
||||
the most reliable way to monitor a service.
|
||||
|
||||
However, not all daemons support running in the foreground, or they may
|
||||
start logging to the foreground as well, these are called forking
|
||||
services and are supported using the same syntax as forking `sysv`
|
||||
services, using the `pid:!/path/to/pidfile.pid` syntax.
|
||||
|
||||
**Example:**
|
||||
|
||||
In the case of `ospfd` (below), we omit the `-d` flag (daemonize) to
|
||||
prevent it from forking to the background:
|
||||
|
||||
service [2345] <pid/zebra> /sbin/ospfd -- OSPF daemon
|
||||
|
||||
`[2345]` denote the runlevels `ospfd` is allowed to run in, they are
|
||||
optional and default to level 2-5 if omitted.
|
||||
|
||||
`<...>` is the condition for starting `ospfd`. In this example Finit
|
||||
waits for another service, `zebra`, to have created its PID file in
|
||||
`/var/run/quagga/zebra.pid` before starting `ospfd`. Finit watches
|
||||
*all* files in `/var/run`, for each file named `*.pid`, or `*/pid`,
|
||||
Finit opens it and find the matching `NAME:ID` using the PID.
|
||||
|
||||
Some services do not maintain a PID file and rather than patching each
|
||||
application Finit provides a workaround. A `pid` keyword can be set
|
||||
to have Finit automatically create (when starting) and later remove
|
||||
(when stopping) the PID file. The file is created in the `/var/run`
|
||||
directory using the `basename(1)` of the service. The default can be
|
||||
modified with an optional `pid:`-argument:
|
||||
|
||||
pid[:[/path/to/]filename[.pid]]
|
||||
|
||||
For example, by adding `pid:/run/foo.pid` to the service `/sbin/bar`,
|
||||
that PID file will, not only be created and removed automatically, but
|
||||
also be used by the Finit condition subsystem. So a service/run/task
|
||||
can depend on `<pid/bar>`.
|
||||
|
||||
> For a detailed description of conditions, and how to debug them,
|
||||
> see the [Finit Conditions](conditions.md) document.
|
||||
|
||||
If a service should not be automatically started, it can be configured
|
||||
as manual with the optional `manual` argument. The service can then be
|
||||
started at any time by running `initctl start <service>`.
|
||||
|
||||
manual:yes
|
||||
|
||||
The name of a service, shown by the `initctl` tool, defaults to the
|
||||
basename of the service executable. It can be changed with the
|
||||
optional `name` argument:
|
||||
|
||||
name:<service-name>
|
||||
|
||||
When stopping a service (run/task/sysv/service), either manually or
|
||||
when moving to another runlevel, Finit starts by sending `SIGTERM`, to
|
||||
allow the process to shut down gracefully. If the process has not
|
||||
been collected within 3 seconds, Finit sends `SIGKILL`. To halt the
|
||||
process using a different signal, use the option `halt:SIGNAL`, e.g.,
|
||||
`halt:SIGPWR`. To change the delay between your halt signal and KILL,
|
||||
use the option `kill:SEC`, e.g., `kill:10` to wait 10 seconds before
|
||||
sending `SIGKILL`.
|
||||
|
||||
|
||||
### Run-parts Scripts
|
||||
|
||||
**Syntax:** `runparts <DIR>`
|
||||
|
||||
Call [run-parts(8)][] on `DIR` to run start scripts. All executable
|
||||
files, or scripts, in the directory are called, in alphabetic order.
|
||||
The scripts in this directory are executed at the very end of runlevel
|
||||
`S`, bootstrap.
|
||||
|
||||
It can be beneficial to use `S01name`, `S02othername`, etc. if there
|
||||
is a dependency order between the scripts. Symlinks to existing
|
||||
daemons can talso be used, but make sure they daemonize by default.
|
||||
|
||||
Similar to the `/etc/rc.local` shell script, make sure that all your
|
||||
services and programs either terminate or start in the background or
|
||||
you will block Finit.
|
||||
|
||||
> **Note:** only read and executed in runlevel S (bootstrap).
|
||||
|
||||
### Including Finit Configs
|
||||
|
||||
**Syntax:** `include <CONF>`
|
||||
|
||||
Include another configuration file. Absolute path required.
|
||||
|
||||
|
||||
### General Logging
|
||||
|
||||
**Syntax:** `log size:200k count:5`
|
||||
|
||||
Log rotation for run/task/services using the `log` sub-option with
|
||||
redirection to a log file. Global setting, applies to all services.
|
||||
|
||||
The size can be given as bytes, without a specifier, or in `k`, `M`,
|
||||
or `G`, e.g. `size:10M`, or `size:3G`. A value of `size:0` disables
|
||||
log rotation. The default is `200k`.
|
||||
|
||||
The count value is recommended to be between 1-5, with a default 5.
|
||||
Setting count to 0 means the logfile will be truncated when the MAX
|
||||
size limit is reached.
|
||||
|
||||
### TTYs and Consoles
|
||||
|
||||
**Syntax:** `tty [LVLS] <DEV> [BAUD] [noclear] [nowait] [nologin] [TERM]`
|
||||
`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`, or `console`, useful on embedded systems.
|
||||
|
||||
The default baud rate is 0, i.e., keep kernel default.
|
||||
|
||||
**Example:**
|
||||
|
||||
tty [12345] /dev/ttyAMA0 115200 noclear vt220
|
||||
|
||||
The second `tty` syntax variant is for using an external getty, like
|
||||
agetty or the BusyBox getty.
|
||||
|
||||
By default both variants *clear* the TTY and *wait* for the user to
|
||||
press enter before starting getty.
|
||||
|
||||
**Example:**
|
||||
|
||||
tty [12345] /sbin/getty -L 115200 /dev/ttyAMA0 vt100
|
||||
tty [12345] /sbin/agetty -L ttyAMA0 115200 vt100 nowait
|
||||
|
||||
The `noclear` option disables clearing the TTY after each session.
|
||||
Clearing the TTY when a user logs out is usually preferable.
|
||||
|
||||
The `nowait` option disables the `press Enter to activate console`
|
||||
message before actually starting the getty program. On small and
|
||||
embedded systems running multiple unused getty wastes both memory
|
||||
and CPU cycles, so `wait` is the preferred default.
|
||||
|
||||
The `nologin` option disables getty and `/bin/login`, and gives the
|
||||
user a root (login) shell on the given TTY `<DEV>` immediately.
|
||||
Needless to say, this is a rather insecure option, but can be very
|
||||
useful for developer builds, during board bringup, or similar.
|
||||
|
||||
Notice the ordering, the `TERM` option to the built-in getty must be
|
||||
the last argument.
|
||||
|
||||
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`. The speed
|
||||
can be omitted to keep the kernel default.
|
||||
|
||||
**Example:**
|
||||
|
||||
tty [12345] @console noclear vt220
|
||||
|
||||
On really bare bones systems Finit offers a fallback shell, which
|
||||
should not be enabled on production systems since. This because it
|
||||
may give a user root access without having to log in. However, for
|
||||
bringup and system debugging it can come in handy:
|
||||
|
||||
configure --enable-fallback-shell
|
||||
|
||||
One can also use the `service` stanza to start a stand-alone shell:
|
||||
|
||||
service [12345] /bin/sh -l
|
||||
|
||||
|
||||
### Non-privileged Services
|
||||
|
||||
Every `run`, `task`, or `service` can also list the privileges the
|
||||
`/path/to/cmd` should be executed with. Simply prefix the path with
|
||||
`[@USR[:GRP]]` like this:
|
||||
|
||||
run [2345] @joe:users logger "Hello world"
|
||||
|
||||
For multiple instances of the same command, e.g. a DHCP client or
|
||||
multiple web servers, add `:ID` somewhere between the `run`, `task`,
|
||||
`service` keyword and the command, like this:
|
||||
|
||||
service :80 [2345] httpd -f -h /http -p 80 -- Web server
|
||||
service :8080[2345] httpd -f -h /http -p 8080 -- Old web server
|
||||
|
||||
Without the `:ID` to the service the latter will overwrite the former
|
||||
and only the old web server would be started and supervised.
|
||||
|
||||
|
||||
### Redirecting Output
|
||||
|
||||
The `run`, `task`, and `service` stanzas also allow the keyword `log` to
|
||||
redirect `stderr` and `stdout` of the application to a file or syslog
|
||||
using the native `logit` tool. This is useful for programs that do not
|
||||
support syslog on their own, which is sometimes the case when running
|
||||
in the foreground.
|
||||
|
||||
The full syntax is:
|
||||
|
||||
log:/path/to/file
|
||||
log:prio:facility.level,tag:ident
|
||||
log:console
|
||||
log:null
|
||||
log
|
||||
|
||||
Default `prio` is `daemon.info` and default `tag` is the basename of the
|
||||
service or run/task command.
|
||||
|
||||
Log rotation is controlled using the global `log` setting.
|
||||
|
||||
**Example:**
|
||||
|
||||
service log:prio:user.warn,tag:ntpd /sbin/ntpd pool.ntp.org -- NTP daemon
|
||||
|
||||
Worth noting is that conditions is allowed for all these stanzas. For a
|
||||
detailed description, see the [Conditions](conditions.md) document.
|
||||
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
As of Finit v4 there are no limitations to where `.conf` settings can be
|
||||
placed. Except for the system/global `rlimit`, which can only be set
|
||||
from `/etc/finit.conf`, since it is the first `.conf` file Finit reads.
|
||||
|
||||
Originally, `/etc/finit.conf` was the only way to set up a Finit system.
|
||||
Today it is mainly used for bootstrap settings like system hostname,
|
||||
network bringup and system shutdown. These can now also be set in any
|
||||
`.conf` file in `/etc/finit.d`.
|
||||
|
||||
There is, however, nothing preventing you from having all configuration
|
||||
settings in `/etc/finit.conf`.
|
||||
|
||||
> **Note:** The `/etc/finit.d` directory was previously the default
|
||||
> Finit `runparts` directory. Finit no longer has a default
|
||||
> `runparts`, make sure to update your setup, or the finit
|
||||
> configuration, accordingly.
|
||||
|
||||
[run-parts(8)]: http://manpages.debian.org/cgi-bin/man.cgi?query=run-parts
|
||||
@@ -1,55 +0,0 @@
|
||||
Finit Signals
|
||||
=============
|
||||
|
||||
Finit is often used on embedded and small Linux systems with BusyBox.
|
||||
Though Finit comes with its own tools for (poweroff, halt, reboot), for
|
||||
compatibility with the existing BusyBox toolset the following signals
|
||||
have been adopted:
|
||||
|
||||
`SIGHUP`
|
||||
--------
|
||||
|
||||
Same effect as `finit q`, `init q`, or `initctl reload`, reloads all
|
||||
*.conf files in `/etc/finit.d/`
|
||||
|
||||
`SIGUSR1`
|
||||
---------
|
||||
|
||||
Calls shutdown hooks, including `HOOK_SHUTDOWN`, stopping all running
|
||||
processes, and unmounts all file systems. Then tells kernel to halt.
|
||||
Most people these days want `SIGUSR2` though.
|
||||
|
||||
SysV init and systemd use this to re-open their FIFO/D-Bus.
|
||||
|
||||
`SIGUSR2`
|
||||
---------
|
||||
|
||||
Like SIGUSR1, but tell kernel to power-off the system, if ACPI or
|
||||
similar exists to actually do this. If the kernel fails power-off,
|
||||
Finit falls back to halt.
|
||||
|
||||
SysV init N/A, systemd dumps its internal state to log.
|
||||
|
||||
`SIGTERM`
|
||||
---------
|
||||
|
||||
Like `SIGUSR1`, but tell kernel to reboot the system when done.
|
||||
|
||||
SysV init N/A, systemd rexecutes itself.
|
||||
|
||||
`SIGINT`
|
||||
--------
|
||||
|
||||
Sent from kernel when the CTRL-ALT-DEL key combo is pressed. SysV init
|
||||
and systemd default to reboot with `shutdown -r`.
|
||||
|
||||
Finit currently forwards this to `SIGTERM`.
|
||||
|
||||
`SIGPWR`
|
||||
--------
|
||||
|
||||
Sent from a power daemon, like `powstatd(8)`, on changes to the
|
||||
UPS status. Traditionally SysV init read /etc/powerstatus and
|
||||
acted on "OK", "FAIL", or "LOW" and then removed the file.
|
||||
Finit currently forwards this to `SIGUSR2`.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
Contributor Code of Conduct
|
||||
===========================
|
||||
# Contributor Code of Conduct
|
||||
|
||||
As contributors and maintainers of this project, and in the interest of
|
||||
fostering an open and welcoming community, we pledge to respect all
|
||||
@@ -66,6 +66,9 @@ how `git commit -s` is used to automatically add a `Signed-off-by`:
|
||||
Signed-off-by: Jane Doe <jane.doe@example.com>
|
||||
|
||||
|
||||
Another good *counter* example [is this][rambling] ...
|
||||
|
||||
|
||||
Code of Conduct
|
||||
---------------
|
||||
|
||||
@@ -76,4 +79,11 @@ 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]: CODE-OF-CONDUCT.md
|
||||
[rambling]: http://stopwritingramblingcommitmessages.com/
|
||||
[conduct]: https://github.com/troglobit/finit/blob/master/CODE-OF-CONDUCT.md
|
||||
|
||||
<!--
|
||||
-- Local Variables:
|
||||
-- mode: markdown
|
||||
-- End:
|
||||
-->
|
||||
@@ -0,0 +1,4 @@
|
||||
docsdir := @docdir@/docs
|
||||
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)
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
Goals of Finit
|
||||
==============
|
||||
|
||||
The intent of finit is to monitor not just processes, but to supervise
|
||||
an entire system and the behavior of certain processes that declare
|
||||
themselves to be finit compliant. Similar to launchd, the goal of
|
||||
finit is to be a replacement for:
|
||||
|
||||
* init
|
||||
* inetd
|
||||
* crond
|
||||
* watchdogd
|
||||
|
||||
A small and simple replacement, primarily for embedded systems, with a
|
||||
low dependency on external packages. A compliant software is one that
|
||||
can run as a damon in the foreground. If it can also touch its PID file
|
||||
after a reconfiguration (`initctl reload`), the Finit dependency system
|
||||
can also be used.
|
||||
|
||||
|
||||
Near Future
|
||||
-----------
|
||||
|
||||
* Merge UDP redirect service uredir as an UDP inetd variant
|
||||
* Add `finit.conf` support for UPS notification (SIGPWR) to start a task
|
||||
using, e.g. <sys/power/{ok,fail,low}> conditions. More info in sig.c
|
||||
* Add `finit.conf` support for ctrl-alt-delete (SIGINT) and kbrequest,
|
||||
i.e. KeyboardSignal, (SIGWINCH) behavior. Using conditions to a task,
|
||||
e.g, <sys/key/ctrlaltdel> and <sys/key/signal> like SIGPWR handling.
|
||||
* Cron/At support, see below
|
||||
* Write man pages for finit and `finit.conf`, steal from the excellent
|
||||
`pimd` man pages ...
|
||||
|
||||
|
||||
General
|
||||
-------
|
||||
|
||||
* Add support for timed shutdown in Finit, including cancelled shutdown,
|
||||
possibly using an at-job, see [crond section](#Crond) below
|
||||
* Add support for JSON output, or similar, from `initctl show`, e.g.
|
||||
`initctl show --json`
|
||||
* [Solaris SMF][] (Service Management Facility) has some interesting
|
||||
features that may be well worth looking into adopting:
|
||||
|
||||
svcs enable -rt svc:/network/ssh:default
|
||||
|
||||
That is: (r)esolve dependencies and only enable ssh (t)emporary
|
||||
in the default runlevel when networking is available.
|
||||
* `initctl add /sbin/service -n -- Service description`, for details
|
||||
see above [Solaris SMF][] featuer, issue #55 and issue #69,
|
||||
https://github.com/troglobit/finit/issues/69#issuecomment-287907610
|
||||
* Changing the name of a pidfile, `pid:[/path/]file.pid`, after a
|
||||
service has been started is not supported atm. The previous name will
|
||||
not be (never) removed and the new name will not be created until the
|
||||
process has been stopped and started again.
|
||||
* PID files created in subdirectories to `/run` is not supported right
|
||||
now inotify listeners should be automatically created (and removed)
|
||||
when a subdirectory is added (or removed).
|
||||
|
||||
[Solaris SMF]: http://www.oracle.com/technetwork/articles/servers-storage-admin/intro-smf-basics-s11-1729181.html
|
||||
|
||||
|
||||
Init
|
||||
----
|
||||
|
||||
Finit in itself is not SysV Init compatible, it doesn't use `/etc/rc.d`
|
||||
and `/etc/inet.d` scripts to boot the system. However, a plausible way
|
||||
to achieve compatibility would be to add a plugin to finit which reads
|
||||
`/etc/inittab` to be able to start standard Linux systems.
|
||||
|
||||
|
||||
Inetd
|
||||
-----
|
||||
|
||||
* Add support for throttling connections.
|
||||
* Optimize interface filtering by using socket filter. The functions
|
||||
`inet_*_peek()` and `inetd_is_allowed()` used for interace filtering
|
||||
should be possible to rewrite as socket filters.
|
||||
* Optimize HTTP/HTTPS inetd connections by adding basic support for the
|
||||
`inetd` variant `redir http/tcp@eth0 nowait [2345] 127.0.0.1:8080`,
|
||||
which would reduce the overhead of spawn the web server on each HTTP
|
||||
connection, yet still provide a means of filtering access per iface.
|
||||
|
||||
|
||||
Crond
|
||||
-----
|
||||
|
||||
Requirements are quite rudimentary, basic cron functionality, mainly
|
||||
system-level timed periodic tasks:
|
||||
|
||||
* Periodically run a task, in a matching runlevel
|
||||
* Optionally run as non-root (`crontab -e` as operator)
|
||||
|
||||
Proposed syntax:
|
||||
|
||||
# Crontab
|
||||
cron @SPEC [LVLS] /path/to/cmd [ARGS] -- Optional descr
|
||||
|
||||
# One-shot 'at' command
|
||||
at @YY-mm-ddTHH:MM [LVLS] /path/to/cmd [ARGS] -- Optional descr
|
||||
|
||||
Notice the ISO date in the `at` notation. The `cron @SPEC` could use
|
||||
are mo loose notation, e.g. `@hourly`, `@midnight`, `@daily`, `@weekly`,
|
||||
`@reboot`, etc. The runlevels is extra filtering sugar. E.g., if cron
|
||||
service is only allowed in runlevels two or three it will not start if
|
||||
system currently is in runlevel four.
|
||||
|
||||
To run a command as another user the `.conf` file must have a that
|
||||
owner. E.g., `/etc/finit.d/extra.conf` may be owned by operator and
|
||||
only hold `cron ...` lines.
|
||||
|
||||
What would be extremely useful is if `initctl`, or a homegrown `at`,
|
||||
could support the basic functionality of the `at` command directly from
|
||||
the shell -- that way setting up one-time jobs would not entail
|
||||
re-reading `/etc/finit.conf`
|
||||
|
||||
@@ -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. Remount `/` read-write if `/` is listed in `/etc/fstab` without `ro`
|
||||
12. Pivot root, or remount `/` read-write, depending on system type
|
||||
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
|
||||
@@ -29,8 +29,8 @@ optional plugins to enable. It depends on two external libraries:
|
||||
The configure script checks for all dependencies, including the correct
|
||||
version of the above mentioned libraries. Currently requried versions:
|
||||
|
||||
- libite v2.2.0
|
||||
- libuEv v2.2.0
|
||||
- libite v2.0.1
|
||||
- libuEv v2.1.0
|
||||
|
||||
|
||||
Configure
|
||||
@@ -38,16 +38,12 @@ Configure
|
||||
|
||||
Below are a few of the main switches to configure:
|
||||
|
||||
* `--prefix=..`: Usually you want to set this to `/usr`, default is the GNU
|
||||
default: `/usr/local`
|
||||
* `--disable-inetd`: Disable the built-in inetd server.
|
||||
|
||||
* `--exec-prefix=..`: This you want to set to the empty string, or `/`, to
|
||||
ensure the programs `finit` and `initctl` are installed to the proper
|
||||
locations. Linux expects an "init" in `/sbin`, default: `--prefix`
|
||||
|
||||
* `--sysconfdir=..`: follows `--prefix`, you likely want it to be `/etc`
|
||||
|
||||
* `--localstatedir=..`: follows `--prefix`, you likely want `/var`
|
||||
* `--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
|
||||
@@ -70,21 +66,22 @@ Example
|
||||
First, unpack the archive:
|
||||
|
||||
```shell
|
||||
$ tar xf finit-3.0.tar.xz
|
||||
$ cd finit-3.0/
|
||||
$ tar xf finit-3.0.tar.xz
|
||||
$ cd finit-3.0/
|
||||
```
|
||||
|
||||
Then configure, build and install:
|
||||
|
||||
```shell
|
||||
$ ./configure --prefix=/usr --exec-prefix= \
|
||||
--sysconfdir=/etc --localstatedir=/var \
|
||||
--with-heading="Alpine Linux 3.13" --with-hostname=alpine
|
||||
$ make
|
||||
.
|
||||
.
|
||||
.
|
||||
$ DESTDIR=/tmp/finit make install
|
||||
$ ./configure --enable-rw-rootfs --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
|
||||
$ make
|
||||
.
|
||||
.
|
||||
.
|
||||
$ DESTDIR=/tmp/finit make install
|
||||
```
|
||||
|
||||
In this example the [finit-3.0.tar.xz][1] archive is unpacked to the
|
||||
@@ -0,0 +1,38 @@
|
||||
Tips & Tricks with the kernel cmdline
|
||||
=====================================
|
||||
|
||||
This document summarizes the different boot parameters that can be
|
||||
passed on the Linux kernel command line. Not just limited to Finit.
|
||||
|
||||
* `debug`, or `--debug`
|
||||
Enable debug mode. The former syntax also enable kernel debug, and
|
||||
the latter only in Finit. Debug messages are printed to the console
|
||||
until a syslog daemon has been started.
|
||||
|
||||
* `init=/bin/sh`
|
||||
Bypass system default init and tell kernel to start a shell. Note,
|
||||
this shell is very limited and does not support signals and has no
|
||||
job control. Recommend using, and modifying, `rescue` mode instead.
|
||||
|
||||
* `panic=SEC`
|
||||
By default the kernel does not reboot after a kernel panic. This
|
||||
setting will cause a kernel reboot after SEC seconds.
|
||||
|
||||
* `quiet`
|
||||
Suppress kernel logging to console, except for warnings and errors.
|
||||
|
||||
* `rescue`
|
||||
Start Finit rescue mode; no network, no `fsck` of file systems in
|
||||
`/etc/fstab`, no `/etc/rc.local`, no `runparts`. The configuration
|
||||
is read from `/etc/rescue.conf`, can be modified by the operator.
|
||||
|
||||
* `single`, or `S`
|
||||
Single user mode, runlevel 1, in Finit. Useful to debug problems with
|
||||
the regular runlevel. All services and TTYs in `[1]` will be started,
|
||||
so a `tty [1] @console nologin` configuration presents you with a
|
||||
root console without login.
|
||||
|
||||
* `splash`
|
||||
Display Finit splash screen with progress at bootstrap and shutdown.
|
||||
|
||||
For more on kernel boot paramaters, see the man page `bootparam(7)`.
|
||||
@@ -17,8 +17,8 @@ Conditions are a new addition to Finit, introduced in v3, with the
|
||||
intention of providing a mechanism for common synchronization problems.
|
||||
For example:
|
||||
|
||||
- *"wait for service A to start before starting service B"*, or
|
||||
- *"wait for basic network access to be available"*
|
||||
- *"do not start this service until another process has started"*, or
|
||||
- *"do not starty until basic network access is available"*
|
||||
|
||||
Conditions are similar in syntax to declaring runlevels per service.
|
||||
They are specified within angle brackets `<>` and can be applied to any
|
||||
@@ -30,12 +30,14 @@ service to run.
|
||||
|
||||
### Example
|
||||
|
||||
service [2345] <pid/setupd,pid/zebra> /sbin/netd -- Network monitor
|
||||
```shell
|
||||
service [2345] <svc/sbin/setupd,svc/sbin/zebra> /sbin/netd -- Network monitor
|
||||
```
|
||||
|
||||
In this example the Network monitor daemon `netd` is not started until
|
||||
both the `pid/setupd` *and* `pid/zebra` conditions are satisfied. A
|
||||
`pid/` condition is satisfied by the corresponding service's PID file
|
||||
being created.
|
||||
both the `svc/sbin/setupd` *and* `svc/sbin/zebra` conditions are
|
||||
satisfied. An `svc` condition is satisfied by the corresponding
|
||||
service's PID file being created.
|
||||
|
||||
**NOTE:** Conditions also stop services when a condition is no longer
|
||||
asserted. I.e., if the Zebra process above stops or restarts, netd
|
||||
@@ -45,7 +47,17 @@ being created.
|
||||
Triggering
|
||||
----------
|
||||
|
||||
Conditions can only be triggered by built-in plugins.
|
||||
Conditions are triggered by built-in plugins, but can for debugging
|
||||
purposes also be controlled using the `cond set` and `cond clear`
|
||||
sub-commands to the `initctl` control tool:
|
||||
|
||||
* `initctl cond set your/cond/here`
|
||||
|
||||
To set a condition
|
||||
|
||||
* `initctl cond clear your/cond/here`
|
||||
|
||||
To clear a condition
|
||||
|
||||
Conditions retain their current state until the next reconfiguration or
|
||||
runlevel change. At that point all set conditions transition into the
|
||||
@@ -54,33 +66,32 @@ on this, see [Internals](#internals).) Thus, after a reconfiguration it
|
||||
is up to the "owner" of the condition to convey the new (or possibly
|
||||
unchanged) state of it.
|
||||
|
||||
> **Note:** For `pid/` conditions it is expected that services "touch"
|
||||
> or recreate their PID file on `SIGHUP`.
|
||||
|
||||
|
||||
Built-in Conditions
|
||||
-------------------
|
||||
|
||||
Finit comes with a `pidfile` and `netlink` plugin. When enabled, the
|
||||
`pidfile` plugin watches `/var/run/` (recursively) for PID files created
|
||||
by the monitored services, and sets a corresponding condition in the
|
||||
`pid/` namespace. Similarily, the `netlink` plugin provides basic
|
||||
conditions for when an interface is brought up/down and when a default
|
||||
route (gateway) is set, in the `net/` namespace.
|
||||
Finit is distributed with a `pidfile` and `netlink` plugin. If enabled,
|
||||
the `pidfile` plugin watches `/var/run/` for PID files created by the
|
||||
monitored services, and sets a corresponding condition in the `svc/`
|
||||
namespace. Similarily, the `netlink` plugin provides basic conditions
|
||||
for when an interface is brought up/down and when a default route
|
||||
(gateway) is set, in the `net/` namespace.
|
||||
|
||||
With the example listed above, finit does not start the `/sbin/netd`
|
||||
daemon until `setupd` and `zebra` has started *and* created their PID
|
||||
files. Which they do when they have completed their initial set up and
|
||||
are ready to receive signals.
|
||||
|
||||
Finit expects monitored services to touch their PID files, i.e. update
|
||||
the mtime, when they reload their configuration files after a `SIGHUP`.
|
||||
Some services do not support `SIGHUP` and are instead restarted, which
|
||||
is a crude but effective way to have the PID file touched (re-created).
|
||||
The full path to the dependency is needed by finit to match the PID file
|
||||
to a monitored process. Finit expects monitored services to touch their
|
||||
PID files, i.e. update the mtime, when they reload their configuration
|
||||
files after a `SIGHUP`. Some services do not support `SIGHUP` and are
|
||||
instead restarted, which is a crude but effective way to have the PID
|
||||
file touched (re-created).
|
||||
|
||||
Built-in conditions:
|
||||
|
||||
- `pid/<SERVICE>`
|
||||
- `svc/<PATH>`
|
||||
- `net/route/default`
|
||||
- `net/<IFNAME>/exist`
|
||||
- `net/<IFNAME>/up`
|
||||
@@ -91,39 +102,6 @@ Built-in conditions:
|
||||
difference is that `running` tells if the NIC has link.
|
||||
|
||||
|
||||
Composition
|
||||
-----------
|
||||
|
||||
The `pid/` conditions are generated by the Finit `pidfile.so` plugin and
|
||||
composed from a service's `name:` and `:id`. By default the basename of
|
||||
the daemon and the empty string.
|
||||
|
||||
| **service** | **condition** |
|
||||
|----------------------------------------------------|------------------|
|
||||
| /sbin/foo | pid/foo |
|
||||
| /sbin/bar -p /run/baz.pid | pid/bar |
|
||||
| name:lxc :foo lxc-start -n foo -p /run/lxc/foo.pid | pid/lxc:foo |
|
||||
| /usr/bin/dbus-daemon | pid/dbus-daemon |
|
||||
| :222 dropbear -p 222 | pid/dropbear:222 |
|
||||
|
||||
The condition is asserted when `pidfile.so` receives an inotify event
|
||||
for a file matching `/run/*.pid`, `/run/**/*.pid`, or `/run/**/pid`,
|
||||
which contains the PID of the service Finit has started.
|
||||
|
||||
When Finit configuration files are changed and the `initctl reload`
|
||||
command is called, it is expected of services to touch their PID files
|
||||
for Finit to reassert their conditions.
|
||||
|
||||
Daemons that don't create PID files, or fail to touch them on reload,
|
||||
can be worked around by using the `pid:/path/to/file.pid` syntax in
|
||||
the service stanza for the daemon. It is far from optimal since any
|
||||
synchronization of depending services may fail due to the daemon not
|
||||
having reinitialized/created their IPC sockets, or similar.
|
||||
|
||||
> **Note:** in versions of Finit prior to v4, the PID conditions were
|
||||
> called 'svc' conditions, and they were far more complex.
|
||||
|
||||
|
||||
Debugging
|
||||
---------
|
||||
|
||||
@@ -138,11 +116,11 @@ conditions that are not satisfied. Listed as `off` below.
|
||||
**Example:**
|
||||
|
||||
```shell
|
||||
~ # initctl cond show
|
||||
PID IDENT STATUS CONDITION (+ ON, ~ FLUX, - OFF)
|
||||
=======================================================================
|
||||
1419 /sbin/netd on <+pid/setupd,+pid/zebra>
|
||||
0 /sbin/udhcpc off <-net/vlan1/exist>
|
||||
~ # initctl cond show
|
||||
PID Service Status Condition (+ on, ~ flux, - off)
|
||||
===============================================================================
|
||||
1419 /sbin/netd on <+svc/sbin/setupd,+svc/sbin/zebra>
|
||||
0 /sbin/udhcpc off <-net/vlan1/exist>
|
||||
```
|
||||
|
||||
Here we can see that `netd` is allowed to run since both its conditions
|
||||
@@ -154,26 +132,24 @@ To fake interface `vlan1` suddenly appearing, and test what happens to
|
||||
`udhcpc` we can enable debug mode and assert the condition, like this:
|
||||
|
||||
```shell
|
||||
~ # initctl debug
|
||||
~ # mkdir -p /var/run/finit/cond/net/vlan1
|
||||
~ # cp /var/run/finit/cond /var/run/finit/cond/net/vlan1/exist
|
||||
~ # initctl debug
|
||||
~ # initctl cond set net/vlan1/exist
|
||||
```
|
||||
|
||||
Then watch the console for the debug messages and then check the output
|
||||
from `initctl cond show` again. The client will likely have failed to
|
||||
start, but at least the condition is now satisfied.
|
||||
from `initctl cond show` again. (The client will likely have failed to
|
||||
start, but at least the condition is now satisfied.)
|
||||
|
||||
There is also the `initctl cond dump` command, which dumps all known
|
||||
conditions, their current status, and their origin.
|
||||
conditions and their current status.
|
||||
|
||||
|
||||
Internals
|
||||
---------
|
||||
|
||||
As shown previously, conditions are implemented as simple files in the
|
||||
file system, in the `/var/run/finit/cond/` sub-directory. The files
|
||||
are created, updated, and removed by condition plugins. To debug them,
|
||||
see the previous section.
|
||||
Conditions are implemented as simple files in the file system, in the
|
||||
`/var/run/finit/cond/` sub-directory. Use the `initctl cond set/clear`
|
||||
commands to add/remove files in this hierarchy.
|
||||
|
||||
A condition is always in one of three states:
|
||||
|
||||
+462
@@ -0,0 +1,462 @@
|
||||
Configuration
|
||||
=============
|
||||
|
||||
* [Introduction](#introduction)
|
||||
* [Service Wrapper Scripts](#service-wrapper-scripts)
|
||||
* [Syntax](#syntax)
|
||||
* [Limitations](#limitations)
|
||||
* [/etc/finit.conf](#etcfinitconf)
|
||||
* [/etc/finit.d](#etcfinitd)
|
||||
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
Finit can be configured using only the original `/etc/finit.conf` file
|
||||
or in combination with `/etc/finit.d/*.conf`. Finit 3 can even start a
|
||||
system using only `/etc/finit.d/*.conf`, highly useful for package-based
|
||||
Linux distributions -- each package can provide its own "script" file.
|
||||
|
||||
- `/etc/finit.conf`: main configuration file
|
||||
- `/etc/finit.d/*.conf`: snippets, usually one service per file
|
||||
|
||||
Not all configuration directives are available in `/etc/finit.d/*.conf`
|
||||
and some directives are only available at bootstrap, runlevel `S`, see
|
||||
the section [Limitations](#limitations) below for details.
|
||||
|
||||
To add a new service, simply drop a `.conf` file in `/etc/finit.d` and
|
||||
run `initctl reload`. (It is also possible to `SIGHUP` to PID 1, or
|
||||
call `finit q`, but that has been deprecated with the `initctl` tool).
|
||||
Finit monitors all known active `.conf` files, so if you want to force
|
||||
a restart of any service you can simply touch its corresponding `.conf`
|
||||
file in `/etc/finit.d` and call `initctl reload`. Finit handle any
|
||||
and all conditions and dependencies between services automatically.
|
||||
|
||||
It is also possible to drop `.conf` files in `/etc/finit.d/available/`
|
||||
and use `initctl enable` to enable a service `.conf` file. This may be
|
||||
useful in particular to Linux distributions that may want to install all
|
||||
files for a package and let the user decide when to enable a service.
|
||||
|
||||
On `initctl reload` the following is checked for all services:
|
||||
|
||||
- If a service's `.conf` file has been removed, or its conditions are no
|
||||
longer satisifed, the service is stopped.
|
||||
- If the file is modified, or a service it depends on has been reloaded,
|
||||
the service is reloaded (stopped and started).
|
||||
- If a new service is added it is automatically started — respecting
|
||||
runlevels and return values from any callbacks.
|
||||
|
||||
For more info on the different states of a service, see the separate
|
||||
document [Finit Services](service.md).
|
||||
|
||||
|
||||
Service Wrapper Scripts
|
||||
-----------------------
|
||||
|
||||
If your service requires to run additional commands, executed before the
|
||||
service is actually started, like the systemd `ExecStartPre`, you can
|
||||
use a wrapper shell script to start your service.
|
||||
|
||||
The Finit service `.conf` file can be put into `/etc/finit.d/available`,
|
||||
so you can control the service using `initctl`. Then use the path to
|
||||
the wrapper script in the Finit `.conf` service stanza. The following
|
||||
example employs a wrapper script in `/etc/start.d`.
|
||||
|
||||
**Example:**
|
||||
|
||||
* `/etc/finit.d/available/program.conf`:
|
||||
```conf
|
||||
service [235] <!> /etc/start.d/program -- Example Program
|
||||
```
|
||||
|
||||
* `/etc/start.d/program:`
|
||||
```shell
|
||||
#!/bin/sh
|
||||
|
||||
# Prepare the command line options
|
||||
OPTIONS="-u $(cat /etc/username)"
|
||||
|
||||
# Execute the program
|
||||
exec /usr/bin/program $OPTIONS
|
||||
```
|
||||
|
||||
**Note:**, that the example sets `<!>` to denote that it doesn't support
|
||||
`SIGHUP`. That way Finit will stop/start such the service instead of
|
||||
sending SIGHUP at restart/reload.
|
||||
|
||||
|
||||
Syntax
|
||||
------
|
||||
|
||||
* `host <NAME>`, or `hostname <NAME>`
|
||||
Set system hostname to NAME, unless `/etc/hostname` exists in which
|
||||
case the contents of that file is used.
|
||||
|
||||
* `module <MODULE> [ARGS]`
|
||||
Load a kernel module, with optional arguments
|
||||
|
||||
* `network <PATH>`
|
||||
Script or program to bring up networking, with optional arguments
|
||||
|
||||
* `cgroup <NAME> cpuset:SPEC cpu:SPEC mem:SPEC`
|
||||
Create a control group for resource limiting services using cgroups.
|
||||
Unlike `rlimit` this setting defines a common group to be selected for
|
||||
any set of run/task/services using the `group` directive (below).
|
||||
|
||||
A cpuset for a cgroup can be the traditional list of CPU cores to
|
||||
assign to the group, or a range that Finit will use to dynamically
|
||||
allocate cores based on the amount available. The range values can be
|
||||
either in absolute form or percent.
|
||||
|
||||
```shell
|
||||
cgroup first cpuset:1
|
||||
```
|
||||
|
||||
To create a cgroup with one exclusive CPU:
|
||||
|
||||
```shell
|
||||
cgroup single cpuset:[1,1]
|
||||
```
|
||||
|
||||
To create cgroup that uses at most two shared CPUs:
|
||||
|
||||
```shell
|
||||
cgroup uptotwo cpuset:[,2]
|
||||
```
|
||||
|
||||
To create cgroup with at least two shared CPUs:
|
||||
|
||||
```shell
|
||||
cgroup dual cpuset:[2,]
|
||||
```
|
||||
|
||||
To create cgroup with at least one CPU and at most half of all
|
||||
available CPUs:
|
||||
|
||||
```shell
|
||||
cgroup greedy cpuset:[1,50%]
|
||||
```
|
||||
|
||||
|
||||
* `group <NAME>`
|
||||
All subsequent `service`, `task`, or `run` directives are executed in the
|
||||
given control group `NAME`, which must be defined prior to this line. If
|
||||
`NAME` does not yet exist the default group `default` is used.
|
||||
|
||||
When separate Finit `.conf` files are used for services the default group
|
||||
is reset for each `.conf` file read.
|
||||
|
||||
* `rlimit [hard|soft] RESOURCE <LIMIT|unlimited>` Set the hard or soft
|
||||
limit for a resource, or both if that argument is omitted. `RESOURCE`
|
||||
is the lower-case `RLIMIT_` string constants from `setrlimit(2)`,
|
||||
without the prefix. E.g. to set `RLIMIT_CPU`, use `cpu`.
|
||||
|
||||
LIMIT is an integer that depends on the resource being modified, see
|
||||
the man page, or the kernel `/proc/PID/limits` file, for details.
|
||||
Finit versions before v3.1 used `infinity` for `unlimited`, which is
|
||||
still supported, albeit deprecated.
|
||||
|
||||
```shell
|
||||
# No process is allowed more than 8MB of address space
|
||||
rlimit hard as 8388608
|
||||
|
||||
# Core dumps may be arbitrarily large
|
||||
rlimit soft core infinity
|
||||
|
||||
# CPU limit for all services, soft & hard = 10 sec
|
||||
rlimit cpu 10
|
||||
```
|
||||
|
||||
`rlimit` can be set globally, in `/etc/finit.conf`, or locally for
|
||||
a set of task/run/services, in `/etc/finit.d/*.conf`.
|
||||
|
||||
* `runlevel <N>`
|
||||
N is the runlevel number 1-9, where 6 is reserved for reboot.
|
||||
Default is 2.
|
||||
|
||||
* `run [LVLS] <COND> /path/to/cmd ARGS -- Optional description`
|
||||
One-shot command to run in sequence when entering a runlevel, with
|
||||
optional arguments and description.
|
||||
|
||||
`run` commands are guaranteed to be completed before running the next
|
||||
command. Highly useful if true serialization is needed.
|
||||
|
||||
* `task [LVLS] <COND> /path/to/cmd ARGS -- Optional description`
|
||||
One-shot like 'run', but starts in parallel with the next command.
|
||||
|
||||
Both `run` and `task` commands are run in a shell, so pipes and
|
||||
redirects can be freely used:
|
||||
|
||||
```shell
|
||||
task [s] echo "foo" | cat >/tmp/bar
|
||||
```
|
||||
|
||||
* `service [LVLS] <COND> /path/to/daemon ARGS -- Optional description`
|
||||
Service, or daemon, to be monitored and automatically restarted if it
|
||||
exits prematurely. Please note that you often need to provide a
|
||||
`--foreground` or `--no-background` argument to most daemons to
|
||||
prevent them from forking off a sub-process in the background.
|
||||
|
||||
```shell
|
||||
service [2345] <svc/sbin/zebra> /sbin/ospfd -- OSPF daemon
|
||||
```
|
||||
|
||||
The `[2345]` is the runlevels `ospfd` is allowed to run in, they are
|
||||
optional and default to level 2-5 if left out.
|
||||
|
||||
The `<...>` is the condition for starting `ospfd`. In this example
|
||||
Finit waits for another service, `/sbin/zebra`, to have created its
|
||||
PID file in `/var/run/zebra.pid` before starting `ospfd`.
|
||||
|
||||
Some services do not maintain a PID file and rather than patching each
|
||||
application Finit provides a workaround. A `pid` keyword can be set
|
||||
to have Finit automatically create (when starting) and later remove
|
||||
(when stopping) the PID file. The file is created in the `/var/run`
|
||||
directory using the `basename(1)` of the service. The default can be
|
||||
modified with an optional argument:
|
||||
|
||||
pid[:[/path/to/]filename[.pid]]
|
||||
|
||||
For example, by adding `pid:/run/foo.pid` to the service `bar` that
|
||||
PID file will, not only be created and removed automatically, but also
|
||||
be used by the Finit condition subsystem. So another service/run/task
|
||||
can depend on `<svc/foo>`.
|
||||
|
||||
If a service `bar` *does* maintain a PID file, but using `foo.pid`, we
|
||||
can inform Finit of this by simplly prepending an `!` to the argument.
|
||||
|
||||
pid:!/run/foo.pid
|
||||
|
||||
Here Finit will *not* create/remove/touch the PID file, only use it
|
||||
for the condition handling instead of the default PID file name.
|
||||
|
||||
For a detailed description of conditions, and how to debug them, see
|
||||
the [Finit Conditions](conditions.md) document.
|
||||
|
||||
If a service should not be automatically started, it can be configured
|
||||
as manual with the optional `manual` argument. The service can then be
|
||||
started at any time by running `initctl start <service>`.
|
||||
|
||||
manual:yes
|
||||
|
||||
The name of a service, shown by the `initctl` tool, defaults to the
|
||||
basename of the service executable. It can be changed with the
|
||||
optional `name` argument:
|
||||
|
||||
name:<service-name>
|
||||
|
||||
* `inetd service/proto[@iflist] <wait|nowait> [LVLS] /path/to/daemon args`
|
||||
Launch a daemon when a client initiates a connection on an Internet
|
||||
port. Available services are listed in the UNIX `/etc/services` file.
|
||||
Finit can filter access to from a list of interfaces, `@iflist`, per
|
||||
inetd service as well as listen to custom ports.
|
||||
|
||||
```shell
|
||||
inetd ftp/tcp nowait @root /usr/sbin/uftpd -i -f
|
||||
inetd tftp/udp wait @root /usr/sbin/uftpd -i -t
|
||||
```
|
||||
|
||||
The following example listens to port 2323 for telnet connections and
|
||||
only allows clients connecting from `eth0`:
|
||||
|
||||
```shell
|
||||
inetd 2323/tcp@eth0 nowait [2345] /sbin/telnetd -i -F
|
||||
```
|
||||
|
||||
The interface list, `@iflist`, is of the format `@iface,!iface,iface`,
|
||||
where a single `!` means to deny access. Notice how interfaces are
|
||||
comma separated with no spaces.
|
||||
|
||||
The `inetd` directive can also have ` -- Optional Description`, only
|
||||
Finit does not output this text on the console when launching inetd
|
||||
services. Instead this text is sent to syslog and also shown by the
|
||||
`initctl` tool. More on inetd below.
|
||||
|
||||
* `runparts <DIR>`
|
||||
Call [run-parts(8)][] on `DIR` to run start scripts. All executable
|
||||
files, or scripts, in the directory are called, in alphabetic order.
|
||||
The scripts in this directory are executed at the very end of runlevel
|
||||
`S`, bootstrap.
|
||||
|
||||
It can be beneficial to use `S01name`, `S02othername`, etc. if there
|
||||
is a dependency order between the scripts. Symlinks to existing
|
||||
daemons can talso be used, but make sure they daemonize by default.
|
||||
|
||||
Similar to the `/etc/rc.local` shell script, make sure that all your
|
||||
services and programs either terminate or start in the background or
|
||||
you will block Finit.
|
||||
|
||||
* `include <CONF>`
|
||||
Include another configuration file. Absolute path required.
|
||||
|
||||
* `log size:200k count:5`
|
||||
|
||||
Log rotation for run/task/services using the `log` sub-option with
|
||||
redirection to a log file. Global setting, applies to all services.
|
||||
|
||||
The size can be given as bytes, without a specifier, or in `k`, `M`,
|
||||
or `G`, e.g. `size:10M`, or `size:3G`. A value of `size:0` disables
|
||||
log rotation. The default is `200k`.
|
||||
|
||||
The count value is recommended to be between 1-5, with a default 5.
|
||||
Setting count to 0 means the logfile will be truncated when the MAX
|
||||
size limit is reached.
|
||||
|
||||
* `tty [LVLS] <DEV> [BAUD] [noclear] [nowait] [nologin] [TERM]`
|
||||
`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`.
|
||||
|
||||
**Example:**
|
||||
```conf
|
||||
tty [12345] /dev/ttyAMA0 115200 noclear vt220
|
||||
```
|
||||
|
||||
The second `tty` syntax variant is for using an external getty, like
|
||||
agetty or the BusyBox getty.
|
||||
|
||||
By default both variants *clear* the TTY and *wait* for the user to
|
||||
press enter before starting getty.
|
||||
|
||||
**Example:**
|
||||
```conf
|
||||
tty [12345] /sbin/getty -L 115200 /dev/ttyAMA0 vt100
|
||||
tty [12345] /sbin/agetty -L ttyAMA0 115200 vt100 nowait
|
||||
```
|
||||
|
||||
The `noclear` option disables clearing the TTY after each session.
|
||||
Clearing the TTY when a user logs out is usually preferable.
|
||||
|
||||
The `nowait` option disables the `press Enter to activate console`
|
||||
message before actually starting the getty program. On small and
|
||||
embedded systems running multiple unused getty wastes both memory
|
||||
and CPU cycles, so `wait` is the preferred default.
|
||||
|
||||
The `nologin` option disables getty and `/bin/login`, and gives the
|
||||
user a root (login) shell on the given TTY `<DEV>` immediately.
|
||||
Needless to say, this is a rather insecure option, but can be very
|
||||
useful for developer builds, during board bringup, or similar.
|
||||
|
||||
Notice the ordering, the `TERM` option to the built-in getty must be
|
||||
the last argument.
|
||||
|
||||
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`.
|
||||
|
||||
**Example:**
|
||||
```conf
|
||||
tty [12345] @console 115200 noclear vt220
|
||||
```
|
||||
|
||||
On really bare bones systems Finit offers a fallback shell, which
|
||||
should not be enabled on production systems since. This because it
|
||||
may give a user root access without having to log in. However, for
|
||||
bringup and system debugging it can come in handy:
|
||||
|
||||
```shell
|
||||
configure --enable-fallback-shell
|
||||
```
|
||||
|
||||
One can also use the `service` stanza to start a stand-alone shell:
|
||||
|
||||
```conf
|
||||
service [12345] /bin/sh -l
|
||||
```
|
||||
|
||||
When running <kbd>make install</kbd> no default `/etc/finit.conf` will
|
||||
be installed since system requirements differ too much. Try out the
|
||||
Debian 6.0 example `/usr/share/doc/finit/finit.conf` configuration that
|
||||
is capable of service monitoring SSH, sysklogd, gdm and getty!
|
||||
|
||||
Every `run`, `task`, `service`, or `inetd` can also list the privileges
|
||||
the `/path/to/cmd` should be executed with. Simply prefix the path with
|
||||
`[@USR[:GRP]]` like this:
|
||||
|
||||
```shell
|
||||
run [2345] @joe:users /usr/bin/logger "Hello world"
|
||||
```
|
||||
|
||||
For multiple instances of the same command, e.g. a DHCP client or
|
||||
multiple web servers, add `:ID` somewhere between the `run`, `task`,
|
||||
`service` keyword and the command, like this:
|
||||
|
||||
```shell
|
||||
service :1 [2345] /sbin/httpd -f -h /http -p 80 -- Web server
|
||||
service :2 [2345] /sbin/httpd -f -h /http -p 8080 -- Old web server
|
||||
```
|
||||
|
||||
Without the `:ID` to the service the latter will overwrite the former
|
||||
and only the old web server would be started and supervised.
|
||||
|
||||
The `run`, `task`, `service`, or `inetd` stanzas also allow the keyword
|
||||
`log` to redirect `stderr` and `stdout` of the application to a file or
|
||||
syslog using the native `logit` tool. The full syntax is:
|
||||
|
||||
log:/path/to/file
|
||||
log:prio:facility.level,tag:ident
|
||||
log:console
|
||||
log:null
|
||||
log
|
||||
|
||||
Default `prio` is `daemon.info` and default `tag` is the basename of the
|
||||
service or run/task command.
|
||||
|
||||
Log rotation is controlled using the global `log` setting.
|
||||
|
||||
**Example:**
|
||||
|
||||
service log:prio:user.warn,tag:ntpd /sbin/ntpd pool.ntp.org -- NTP daemon
|
||||
|
||||
Worth noting is that conditions is allowed for all these stanzas. For a
|
||||
detailed description, see the [Conditions](conditions.md) document.
|
||||
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
To understand the limitations of `finit.conf` vs `finit.d` it is useful
|
||||
to picture the different phases of the system: bootstrap, runtime, and
|
||||
shutdown.
|
||||
|
||||
### /etc/finit.conf
|
||||
|
||||
This file used to be the only way to set up and boot a Finit system.
|
||||
Today it is mainly used for pre-runtime settings like system hostname,
|
||||
network bringup and shutdown:
|
||||
|
||||
- `host`, only at bootstrap, (runlevel `S`)
|
||||
- `mknod`, only at bootstrap
|
||||
- `network`, only at bootstrap
|
||||
- `runparts`, only at bootstrap
|
||||
- `include`
|
||||
- `log`, global setting
|
||||
- `shutdown`
|
||||
- `runlevel`, only at bootstrap
|
||||
- ... and all configuration stanzas from `/etc/finit.d` below
|
||||
|
||||
### /etc/finit.d
|
||||
|
||||
Support for per-service `.conf` files in `/etc/finit.d` was added in
|
||||
v3.0 to handle changes of the system configuration at runtime. As of
|
||||
v3.1 `finit.conf` is also handled at runtime, except of course for any
|
||||
stanza that only runs at bootstrap. However, a `/etc/finit.d/*.conf`
|
||||
does *not support* the above `finit.conf` settings described above, only
|
||||
the following:
|
||||
|
||||
- `module`, but only at bootstrap
|
||||
- `service`
|
||||
- `task`
|
||||
- `run`
|
||||
- `inetd`
|
||||
- `rlimit`
|
||||
- `tty`
|
||||
|
||||
**NOTE:** The `/etc/finit.d` directory was previously the default Finit
|
||||
`runparts` directory. Finit no longer has a default `runparts`, make
|
||||
sure to update your setup, or the finit configuration, accordingly.
|
||||
|
||||
[run-parts(8)]: http://manpages.debian.org/cgi-bin/man.cgi?query=run-parts
|
||||
@@ -13,13 +13,13 @@ By default Finit uses the following directories for configuration files:
|
||||
```
|
||||
|
||||
To enable a service one simply drops a small configuration file in the
|
||||
`/etc/finit.d/` directory. This practice works with systems that
|
||||
`/etc/finit.d/` directory. This practice works will with systems that
|
||||
keep disabled services elsewhere, or generates them as needed from some
|
||||
other tool.
|
||||
|
||||
Distributions, however, may want a clearer separation of enabled and
|
||||
Disitributions, however, may want a clearer separation of enabled and
|
||||
available (installed but not enabled) services. They may even want to
|
||||
customize the directories used, for brand labeling or uniformity.
|
||||
customize the directories used, for brand labling or uniformity.
|
||||
|
||||
To that end Finit allows for a sub-directory `/etc/finit.d/available/`
|
||||
where installed but disabled services can reside. Adding a symlink to a
|
||||
@@ -34,9 +34,6 @@ build time:
|
||||
./configure --with-rcsd=/etc/init.d --with-config=/etc/init.d/init.conf
|
||||
```
|
||||
|
||||
> **Note:** remember `--prefix` et al as well, the default is likely
|
||||
> *not* what you want. See the [build docs][1] for details.
|
||||
|
||||
The resulting directory structure is depicted below. Please notice how
|
||||
`/etc/finit.conf` now resides in the same sub-directory as a non-symlink
|
||||
`/etc/init.d/init.conf`:
|
||||
@@ -45,10 +42,10 @@ The resulting directory structure is depicted below. Please notice how
|
||||
/etc/
|
||||
|-- init.d/
|
||||
| |-- available/ -- Regular (disabled) services
|
||||
| | |-- httpd.conf
|
||||
| | |-- ntpd.conf
|
||||
| | `-- sshd.conf
|
||||
| |-- sshd.conf -- Symlink to available/sshd.conf
|
||||
| | |-- httpd.conf
|
||||
| | |-- ntpd.conf
|
||||
| | `-- sshd.conf
|
||||
| |-- sshd.conf -- Symlink to available/sshd.conf
|
||||
| `- init.conf -- Bootstrap tasks and services
|
||||
:
|
||||
```
|
||||
@@ -76,4 +73,3 @@ requires the `available/` sub-directory. Any non-symlink in the parent
|
||||
directory, here `/etc/init.d/`, will be considered a system override by
|
||||
`initctl`.
|
||||
|
||||
[1]: build.md#configure
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
Internet Super Server
|
||||
=====================
|
||||
|
||||
Inetd
|
||||
-----
|
||||
|
||||
A built-in *Internet Super Server* support was added in Finit v1.12 and
|
||||
v1.13, along with an internal `time` inetd service, RFC 868 (rdate).
|
||||
The latter is supplied as a plugin to illustrate how simple it is to
|
||||
extend finit with more internal inetd services. Today more built-in
|
||||
services are available.
|
||||
|
||||
> Please note, not all UNIX daemons are prepared to run as inetd services.
|
||||
> In the example below `sshd` also need the command line argument `-i`.
|
||||
|
||||
The inetd support in finit is quite advanced. Not only does it launch
|
||||
services on demand, it can do so on custom ports and also filter inbound
|
||||
traffic using a poor man's [TCP wrappers][]. The syntax is very similar
|
||||
to the traditional `/etc/inetd.conf`, yet keeping with the style of
|
||||
Finit:
|
||||
|
||||
```shell
|
||||
# Launch SSH on demand, in runlevels 2-5 as root
|
||||
inetd ssh/tcp nowait [2345] @root:root /usr/sbin/sshd -i
|
||||
```
|
||||
|
||||
A more advanced example is listed below, please note the *incompatible
|
||||
syntax change* that was made between Finit v1.12 and v1.13 to support
|
||||
deny filters:
|
||||
|
||||
```shell
|
||||
# Start sshd if inbound connection on eth0, port 222, or
|
||||
# inbound on eth1, port 22. Ignore on other interfaces.
|
||||
inetd 222/tcp@eth0 nowait [2345] /usr/sbin/sshd -i
|
||||
inetd ssh/tcp@eth1,eth1 nowait [2345] /usr/sbin/sshd -i
|
||||
```
|
||||
|
||||
If `eth0` is your Internet interface you may want to avoid using the
|
||||
default port. To run ssh on port 222, and all others on port 22:
|
||||
|
||||
```shell
|
||||
inetd 222/tcp@eth0 nowait [2345] /usr/sbin/sshd -i
|
||||
inetd ssh/tcp@*,!eth0 nowait [2345] /usr/sbin/sshd -i
|
||||
```
|
||||
|
||||
Compared to Finit v1.12 you must *explicitly deny* access from `eth0`!
|
||||
|
||||
To protect against looping attacks, the inetd server will refuse UDP
|
||||
service if the reply port corresponds to any internal service. Similar
|
||||
to how the FreeBSD inetd operates.
|
||||
|
||||
|
||||
**Internal Services**
|
||||
|
||||
Like the original `inetd`, Finit has a few standard services built-in.
|
||||
They are realized as plugins to provide a simple means of testing the
|
||||
inetd functionality stand-alone. But this also provides both a useful
|
||||
network testing/availability, as well as a rudimentary time server for
|
||||
`rdate` clients.
|
||||
|
||||
- echo
|
||||
- chargen
|
||||
- daytime
|
||||
- discard
|
||||
- time
|
||||
|
||||
For security reasons they are all disabled by default and have to be
|
||||
enabled with both the `configure` script and a special `inetd` stanza in
|
||||
the `finit.conf` or `finit.d/*.conf` like this:
|
||||
|
||||
```shell
|
||||
inetd echo/udp wait [2345] internal
|
||||
inetd echo/tcp nowait [2345] internal
|
||||
inetd chargen/udp wait [2345] internal
|
||||
inetd chargen/tcp nowait [2345] internal
|
||||
inetd daytime/udp wait [2345] internal
|
||||
inetd daytime/tcp nowait [2345] internal
|
||||
inetd discard/udp wait [2345] internal
|
||||
inetd discard/tcp nowait [2345] internal
|
||||
inetd time/udp wait [2345] internal
|
||||
inetd time/tcp nowait [2345] internal
|
||||
```
|
||||
|
||||
Then call `rdate` from a remote machine (or use localhost):
|
||||
|
||||
```shell
|
||||
rdate -p <IP>
|
||||
rdate -up <IP>
|
||||
```
|
||||
|
||||
Or `echoping` to reach the echo service:
|
||||
|
||||
```shell
|
||||
echoping -v <IP>
|
||||
echoping -uv <IP>
|
||||
```
|
||||
|
||||
Or `echoping -d` to reach the discard service:
|
||||
|
||||
```shell
|
||||
echoping -dv <IP>
|
||||
echoping -duv <IP>
|
||||
```
|
||||
|
||||
Or `echoping -c` to reach the chargen service:
|
||||
|
||||
```shell
|
||||
echoping -cv <IP>
|
||||
echoping -cuv <IP>
|
||||
```
|
||||
|
||||
If you use `time/udp` you must use the standard rdate implementation and
|
||||
then call it with `rdate -up` to connect using UDP. Without the `-p`
|
||||
argument rdate will try to set the system clock. Please note that rdate
|
||||
has been deprecated by the NTP protocol and this plugin should only be
|
||||
used for testing or environments where NTP for some reason is blocked.
|
||||
Also, remember the UNIX year 2038 bug, or in the case of RFC 868 (and
|
||||
some NTP implementations), year 2036!
|
||||
|
||||
**Note:** There is currently no verification that the same port is used
|
||||
more than once. So a standard `inetd http/tcp` service will clash
|
||||
with an ssh entry for the same port `inetd 80/tcp` …
|
||||
|
||||
|
||||
[TCP Wrappers]: https://en.wikipedia.org/wiki/TCP_Wrapper
|
||||
@@ -8,7 +8,7 @@ Hooks & Plugins
|
||||
* [Shutdown Hooks](#shutdown-hooks)
|
||||
|
||||
Finit can be extended to add general functionality in the form of I/O
|
||||
monitors, or hook plugins.
|
||||
monitors, built-in inetd services, or hook plugins.
|
||||
|
||||
The following sections detail existing plugins and hook points. For
|
||||
more information, see the plugins listed below.
|
||||
@@ -34,11 +34,18 @@ For your convenience a set of *optional* plugins are available:
|
||||
* *dbus.so*: Setup and start system message bus, D-Bus, at boot.
|
||||
_Optional plugin._
|
||||
|
||||
* *hotplug.so*: Setup and start either udev or mdev hotplug daemon, if
|
||||
available.
|
||||
* *echo.so*: RFC 862 plugin. Start as inetd service, like time below.
|
||||
|
||||
* *chargen.so*: RFC 864 plugin. Start as inetd service, like time below.
|
||||
|
||||
* *daytime.so*: RFC 867 plugin. Start as inetd service, like time below.
|
||||
|
||||
* *discard.so*: RFC 863 plugin. Start as inetd service, like time below.
|
||||
|
||||
* *rtc.so*: Restore and save system clock from/to RTC on boot/halt.
|
||||
|
||||
* *initctl.so*: Extends finit with a traditional `initctl` functionality.
|
||||
|
||||
* *modules-load.so*: Scans /etc/modules-load.d for modules to modprobe.
|
||||
|
||||
* *netlink.so*: Listens to Linux kernel Netlink events for gateway and
|
||||
@@ -49,6 +56,9 @@ For your convenience a set of *optional* plugins are available:
|
||||
* *resolvconf.so*: Setup necessary files for `resolvconf` at startup.
|
||||
_Optional plugin._
|
||||
|
||||
* *time.so*: RFC 868 (rdate) plugin. Start as inetd service. Useful
|
||||
for testing inetd filtering — BusyBox has an rdate (TCP) client.
|
||||
|
||||
* *tty.so*: Watches `/dev`, using inotify, for new device nodes (TTY's)
|
||||
to start/stop getty consoles on them on demand. Useful when plugging
|
||||
in a usb2serial converter to login to your embedded device.
|
||||
@@ -100,7 +110,7 @@ Hooks
|
||||
* `HOOK_SHUTDOWN`: Called at shutdown/reboot, right before all
|
||||
services are sent `SIGTERM`
|
||||
|
||||
Plugins like `tty.so` extend finit by acting on events, they are called
|
||||
I/O plugins and are called from the finit main loop when `poll()`
|
||||
detects an event. See the source code for `plugins/*.c` for more help
|
||||
and ideas.
|
||||
Plugins like `initctl.so` and `tty.so` extend finit by acting on events,
|
||||
they are called I/O plugins and are called from the finit main loop when
|
||||
`poll()` detects an event. See the source code for `plugins/*.c` for
|
||||
more help and ideas.
|
||||
@@ -0,0 +1,36 @@
|
||||
Finit Signals
|
||||
=============
|
||||
|
||||
Finit is often used on embedded and small Linux systems with BusyBox.
|
||||
Though Finit comes with its own tools for (poweroff, halt, reboot), for
|
||||
compatibility with the existing BusyBox toolset the following signals
|
||||
have been adopted:
|
||||
|
||||
* `SIGHUP`
|
||||
Same effect as `finit q`, `init q`, or `initctl reload`, reloads all
|
||||
*.conf files in `/etc/finit.d/`
|
||||
* `SIGUSR1`
|
||||
Calls shutdown hooks, including `HOOK_SHUTDOWN`, stopping all running
|
||||
processes, and unmounts all file systems. Then tells kernel to halt.
|
||||
Most people these days want `SIGUSR2` though.
|
||||
|
||||
SysV init and systemd use this to re-open their FIFO/D-Bus.
|
||||
* `SIGUSR2`
|
||||
Like SIGUSR1, but tell kernel to power-off the system, if ACPI
|
||||
or similar exists to actually do this. If the kernel fails
|
||||
power-off, Finit falls back to halt.
|
||||
|
||||
SysV init N/A, systemd dumps its internal state to log.
|
||||
* `SIGTERM`
|
||||
Like `SIGUSR1`, but tell kernel to reboot the system when done.
|
||||
|
||||
SysV init N/A, systemd rexecutes itself.
|
||||
* `SIGINT`
|
||||
Sent from kernel when the CTRL-ALT-DEL key combo is pressed.
|
||||
SysV init and systemd default to reboot with `shutdown -r`.
|
||||
Finit currently forwards this to `SIGTERM`.
|
||||
* `SIGPWR`
|
||||
Sent from a power daemon, like `powstatd(8)`, on changes to the
|
||||
UPS status. Traditionally SysV init read /etc/powerstatus and
|
||||
acted on "OK", "FAIL", or "LOW" and then removed the file.
|
||||
Finit currently forwards this to `SIGUSR2`.
|
||||
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
+42
-6
@@ -7,7 +7,7 @@ AM_CPPFLAGS += $(lite_CFLAGS)
|
||||
|
||||
if STATIC
|
||||
noinst_LTLIBRARIES = libplug.la
|
||||
libplug_la_SOURCES = bootmisc.c modprobe.c rtc.c pidfile.c procps.c tty.c urandom.c
|
||||
libplug_la_SOURCES = bootmisc.c rtc.c initctl.c pidfile.c procps.c tty.c urandom.c
|
||||
|
||||
if BUILD_ALSA_UTILS_PLUGIN
|
||||
libplug_la_SOURCES += alsa-utils.c
|
||||
@@ -17,8 +17,26 @@ if BUILD_DBUS_PLUGIN
|
||||
libplug_la_SOURCES += dbus.c
|
||||
endif
|
||||
|
||||
if BUILD_HOTPLUG_PLUGIN
|
||||
libplug_la_SOURCES += hotplug.c
|
||||
if INETD
|
||||
if BUILD_INETD_ECHO_PLUGIN
|
||||
libplug_la_SOURCES += echo.c
|
||||
endif
|
||||
|
||||
if BUILD_INETD_CHARGEN_PLUGIN
|
||||
libplug_la_SOURCES += chargen.c
|
||||
endif
|
||||
|
||||
if BUILD_INETD_DAYTIME_PLUGIN
|
||||
libplug_la_SOURCES += daytime.c
|
||||
endif
|
||||
|
||||
if BUILD_INETD_DISCARD_PLUGIN
|
||||
libplug_la_SOURCES += discard.c
|
||||
endif
|
||||
|
||||
if BUILD_INETD_TIME_PLUGIN
|
||||
libplug_la_SOURCES += time.c
|
||||
endif
|
||||
endif
|
||||
|
||||
if BUILD_MODULES_LOAD_PLUGIN
|
||||
@@ -34,7 +52,7 @@ libplug_la_SOURCES += resolvconf.c
|
||||
endif
|
||||
|
||||
else
|
||||
pkglib_LTLIBRARIES = bootmisc.la modprobe.la rtc.la pidfile.la procps.la tty.la urandom.la
|
||||
pkglib_LTLIBRARIES = bootmisc.la rtc.la initctl.la pidfile.la procps.la tty.la urandom.la
|
||||
|
||||
if BUILD_ALSA_UTILS_PLUGIN
|
||||
pkglib_LTLIBRARIES += alsa-utils.la
|
||||
@@ -44,8 +62,26 @@ if BUILD_DBUS_PLUGIN
|
||||
pkglib_LTLIBRARIES += dbus.la
|
||||
endif
|
||||
|
||||
if BUILD_HOTPLUG_PLUGIN
|
||||
pkglib_LTLIBRARIES += hotplug.la
|
||||
if INETD
|
||||
if BUILD_INETD_ECHO_PLUGIN
|
||||
pkglib_LTLIBRARIES += echo.la
|
||||
endif
|
||||
|
||||
if BUILD_INETD_CHARGEN_PLUGIN
|
||||
pkglib_LTLIBRARIES += chargen.la
|
||||
endif
|
||||
|
||||
if BUILD_INETD_DAYTIME_PLUGIN
|
||||
pkglib_LTLIBRARIES += daytime.la
|
||||
endif
|
||||
|
||||
if BUILD_INETD_DISCARD_PLUGIN
|
||||
pkglib_LTLIBRARIES += discard.la
|
||||
endif
|
||||
|
||||
if BUILD_INETD_TIME_PLUGIN
|
||||
pkglib_LTLIBRARIES += time.la
|
||||
endif
|
||||
endif
|
||||
|
||||
if BUILD_MODULES_LOAD_PLUGIN
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Save and restore ALSA sound settings using alsactl
|
||||
*
|
||||
* Copyright (c) 2012-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
* Copyright (c) 2012-2016 Joachim Nilsson <troglobit@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+6
-14
@@ -1,6 +1,6 @@
|
||||
/* Setup necessary system files for, e.g. UTMP (tracking logins)
|
||||
*
|
||||
* Copyright (c) 2012-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
* Copyright (c) 2012-2016 Joachim Nilsson <troglobit@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "finit.h"
|
||||
#include "helpers.h"
|
||||
#include "plugin.h"
|
||||
#include "util.h"
|
||||
#include "utmp-api.h"
|
||||
|
||||
static int is_tmpfs(char *path)
|
||||
@@ -117,10 +116,8 @@ static void setup(void *arg)
|
||||
_d("System with new /run tmpfs ...");
|
||||
makedir("/run/lock", 1777);
|
||||
symlink("/run/lock", "/var/lock");
|
||||
symlink("/dev/shm", "/run/shm");
|
||||
|
||||
/* compat only, should really be set up by OS/dist */
|
||||
symlink("/run", "/var/run");
|
||||
symlink("/dev/shm", "/run/shm");
|
||||
} else {
|
||||
makedir("/var/lock", 1777);
|
||||
makedir("/var/run", 0755);
|
||||
@@ -145,12 +142,10 @@ static void setup(void *arg)
|
||||
/*
|
||||
* UTMP actually needs multiple db files
|
||||
*/
|
||||
if (has_utmp()) {
|
||||
create("/var/run/utmp", 0644, 0, gid); /* Currently logged in */
|
||||
create("/var/log/wtmp", 0644, 0, gid); /* Login history */
|
||||
create("/var/log/btmp", 0600, 0, gid); /* Failed logins */
|
||||
create("/var/log/lastlog", 0644, 0, gid);
|
||||
}
|
||||
create("/var/run/utmp", 0644, 0, gid); /* Currently logged in */
|
||||
create("/var/log/wtmp", 0644, 0, gid); /* Login history */
|
||||
create("/var/log/btmp", 0600, 0, gid); /* Failed logins */
|
||||
create("/var/log/lastlog", 0644, 0, gid);
|
||||
|
||||
/* Set BOOT_TIME UTMP entry */
|
||||
utmp_set_boot();
|
||||
@@ -167,8 +162,6 @@ static void setup(void *arg)
|
||||
makedir("/var/run/pluto", 0755); /* Needed by Openswan */
|
||||
makedir("/var/run/quagga", 0755); /* Needed by Quagga */
|
||||
makedir("/var/log/quagga", 0755); /* Needed by Quagga */
|
||||
makedir("/var/run/frr", 0755); /* Needed by FRR */
|
||||
makedir("/var/log/frr", 0755); /* Needed by FRR */
|
||||
makedir("/var/run/sshd", 01755); /* OpenSSH */
|
||||
|
||||
gid = getgroup("tty");
|
||||
@@ -198,7 +191,6 @@ static plugin_t plugin = {
|
||||
.hook[HOOK_BASEFS_UP] = {
|
||||
.cb = setup
|
||||
},
|
||||
.depends = { "pidfile" },
|
||||
};
|
||||
|
||||
PLUGIN_INIT(plugin_init)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user