Compare commits

..
1 Commits
Author SHA1 Message Date
Joachim Nilsson 44137806e4 Basic support for cpuset cgroup config and process assignment
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-05-14 10:18:45 +02:00
357 changed files with 8245 additions and 26161 deletions
-3
View File
@@ -1,3 +0,0 @@
# These are supported funding model platforms
github: [troglobit]
-12
View File
@@ -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.
-69
View File
@@ -1,69 +0,0 @@
name: Bob the Builder
# Run on all branches, including all pull requests, except the 'dev'
# branch since that's where we run Coverity Scan (limited tokens/day)
on:
push:
branches:
- '**'
- '!dev'
pull_request:
branches:
- '**'
jobs:
build:
# Verify we can build on latest Ubuntu with both gcc and clang
name: ${{ matrix.compiler }}
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [gcc, clang]
fail-fast: false
env:
CC: ${{ matrix.compiler }}
steps:
- name: Install dependencies
run: |
sudo apt-get -y update
sudo apt-get -y install pkg-config tree jq libuev-dev libite-dev
- uses: actions/checkout@v4
- name: Static Finit
run: |
./autogen.sh
./configure --prefix= --enable-static
make -j3 V=1
- name: Regular Finit
run: |
./configure --prefix=/usr --exec-prefix= --sysconfdir=/etc --localstatedir=/var \
--enable-x11-common-plugin --enable-testserv-plugin --with-watchdog \
--with-keventd
make -j3 clean
make -j3 V=1
- name: Install to /tmp
run: |
DESTDIR=/tmp make install-strip
tree /tmp || true
- name: Check dependencies
run: |
ldd /tmp/sbin/finit
size /tmp/sbin/finit
ldd /tmp/sbin/initctl
size /tmp/sbin/initctl
ldd /tmp/sbin/reboot
size /tmp/sbin/reboot
- name: Verify starting and showing usage text
run: |
sudo /tmp/sbin/finit -h
sudo /tmp/sbin/initctl -h
- name: Enable unprivileged userns (unshare)
run: |
sudo sysctl kernel.apparmor_restrict_unprivileged_userns=0
- name: Run Unit Tests
run: |
make check || (cat test/test-suite.log; false)
- name: Upload Test Results
uses: actions/upload-artifact@v4
with:
name: finit-test-${{ matrix.compiler }}
path: test/*.log
-88
View File
@@ -1,88 +0,0 @@
name: Coverity Scan
on:
push:
branches:
- 'dev'
workflow_dispatch:
env:
PROJECT_NAME: finit
CONTACT_EMAIL: troglobit@gmail.com
COVERITY_NAME: troglobit-finit
COVERITY_PROJ: troglobit%2Ffinit
jobs:
coverity:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Fetch latest Coverity Scan MD5
id: var
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
run: |
wget -q https://scan.coverity.com/download/cxx/linux64 \
--post-data "token=$TOKEN&project=${COVERITY_PROJ}&md5=1" \
-O coverity-latest.tar.gz.md5
echo "md5=$(cat coverity-latest.tar.gz.md5)" | tee -a $GITHUB_OUTPUT
- uses: actions/cache@v4
id: cache
with:
path: coverity-latest.tar.gz
key: ${{ runner.os }}-coverity-${{ steps.var.outputs.md5 }}
restore-keys: |
${{ runner.os }}-coverity-${{ steps.var.outputs.md5 }}
${{ runner.os }}-coverity-
${{ runner.os }}-coverity
- name: Download Coverity Scan
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
run: |
if [ ! -f coverity-latest.tar.gz ]; then
wget -q https://scan.coverity.com/download/cxx/linux64 \
--post-data "token=$TOKEN&project=${COVERITY_PROJ}" \
-O coverity-latest.tar.gz
else
echo "Latest Coverity Scan available from cache :-)"
md5sum coverity-latest.tar.gz
fi
mkdir coverity
tar xzf coverity-latest.tar.gz --strip 1 -C coverity
- name: Install dependencies
run: |
sudo apt-get -y update
sudo apt-get -y install pkg-config
wget https://github.com/troglobit/libuev/releases/download/v2.4.0/libuev-2.4.0.tar.xz
wget https://github.com/troglobit/libite/releases/download/v2.5.2/libite-2.5.2.tar.gz
tar xf libuev-2.4.0.tar.xz
tar xf libite-2.5.2.tar.gz
(cd libuev-2.4.0 && ./configure --prefix=/usr && make && sudo make install-strip)
(cd libite-2.5.2 && ./configure --prefix=/usr && make && sudo make install-strip)
sudo ldconfig
- name: Configure
run: |
./autogen.sh
./configure --prefix= --enable-x11-common-plugin --with-watchdog --with-keventd
- name: Build
run: |
export PATH=`pwd`/coverity/bin:$PATH
cov-build --dir cov-int make
- name: Submit results to Coverity Scan
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
run: |
tar czvf ${PROJECT_NAME}.tgz cov-int
curl \
--form project=${COVERITY_NAME} \
--form token=$TOKEN \
--form email=${CONTACT_EMAIL} \
--form file=@${PROJECT_NAME}.tgz \
--form version=trunk \
--form description="${PROJECT_NAME} $(git rev-parse HEAD)" \
https://scan.coverity.com/builds?project=${COVERITY_PROJ}
- name: Upload build.log
uses: actions/upload-artifact@v4
with:
name: coverity-build.log
path: cov-int/build-log.txt
-62
View File
@@ -1,62 +0,0 @@
name: Release General
on:
push:
tags:
- '[0-9]+.[0-9]+*'
jobs:
release:
name: Build and upload release tarball
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
env:
MAKEFLAGS: -j3
steps:
- uses: actions/checkout@v4
- name: Installing dependencies ...
run: |
sudo apt-get -y update
sudo apt-get -y install pkg-config jq libuev-dev libite-dev
- name: Setting release variables ...
id: build
run: |
ver=${GITHUB_REF#refs/tags/}
echo "ver=${ver}" >> $GITHUB_OUTPUT
if echo $ver | grep -qE '^[0-9]+\.[0-9]+(\.[0-9]+)?(-alpha|-beta|-rc)[0-9]*$'; then
echo "pre=true" >> $GITHUB_OUTPUT
else
echo "pre=false" >> $GITHUB_OUTPUT
fi
if echo $ver | grep -qE '^[0-9.]+\.[0-9.]+(\.[0-9]+)?$'; then
echo "latest=true" >> $GITHUB_OUTPUT
else
echo "latest=false" >> $GITHUB_OUTPUT
fi
- name: Creating Makefiles ...
run: |
./autogen.sh
./configure --prefix=/usr --exec-prefix= --sysconfdir=/etc --localstatedir=/var \
--enable-x11-common-plugin --enable-testserv-plugin --with-watchdog \
--with-keventd
- name: Enable unprivileged userns (unshare)
run: |
sudo sysctl kernel.apparmor_restrict_unprivileged_userns=0
- name: Build release ...
run: |
make release || (cat test/test-suite.log; false)
ls -lF ../
mkdir -p artifacts/
mv ../*.tar.* artifacts/
- name: Extract ChangeLog entry ...
run: |
awk '/-----*/{if (x == 1) exit; x=1;next}x' ChangeLog.md \
|head -n -1 > release.md
cat release.md
- uses: ncipollo/release-action@v1
with:
name: Finit v${{ github.ref_name }}
prerelease: ${{ steps.build.outputs.pre }}
makeLatest: ${{ steps.build.outputs.latest }}
bodyFile: "release.md"
artifacts: "artifacts/*"
-51
View File
@@ -1,51 +0,0 @@
name: Weekly Distcheck
# Verify that `make distcheck` works as intended: all tests pass, and
# any new files are distributed in the tarballs
on:
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:
jobs:
schedule:
runs-on: ubuntu-latest
outputs:
run: ${{ steps.check.outputs.run }}
steps:
- uses: actions/checkout@v4
- name: Check for any commits since last week
id: schedule
run: |
commits="$(git log --format=%H --since='1 week ago')"
if [ -n "$commits" ]; then
echo "run=true" >> $GITHUB_OUTPUT
else
echo "run=false" >> $GITHUB_OUTPUT
fi
distcheck:
needs: schedule
if: ${{ needs.schedule.outputs.run == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: |
sudo apt-get -y update
sudo apt-get -y install pkg-config jq libuev-dev libite-dev
- uses: actions/checkout@v4
- name: Base run
run: |
./autogen.sh
./configure --prefix=/usr --exec-prefix= --sysconfdir=/etc --localstatedir=/var
make -j9 V=1
- name: Install to /tmp
run: |
DESTDIR=/tmp make install-strip
- name: Enable unprivileged userns (unshare)
run: |
sudo sysctl kernel.apparmor_restrict_unprivileged_userns=0
- name: Check dist tarball
run: |
ver=$(/tmp/sbin/initctl -V | awk '/Finit.*/ {print $2;}')
dir=finit-$ver/_build/sub
make -j1 distcheck || (cat $dir/test/test-suite.log; false)
-12
View File
@@ -9,14 +9,11 @@ GSYMS
GTAGS GTAGS
# GNU configure and build system # GNU configure and build system
/aux
/.deps /.deps
/autom4te.cache /autom4te.cache
/aclocal.m4 /aclocal.m4
/ar-lib /ar-lib
/backup/
/compile /compile
/config.cache
/config.h /config.h
/config.mk /config.mk
/config.guess /config.guess
@@ -34,12 +31,6 @@ GTAGS
/Makefile.in /Makefile.in
/stamp-h1 /stamp-h1
/test-driver
/test-suite.log
# Misc
/.gdb_history
# TroglOS build system # TroglOS build system
/.config /.config
/.stamp /.stamp
@@ -49,6 +40,3 @@ GTAGS
/.autoconf /.autoconf
/.automake /.automake
/.built /.built
# VS Code user settings
.vscode
-7
View File
@@ -1,7 +0,0 @@
# GNU Global .conf file, see /etc/gtags/gtags.conf for details.
default:\
:tc=default@/etc/gtags/gtags.conf:\
:tc=common:
common:\
:skip=tags,TAGS,ID,y.tab.c,y.tab.h,gtags.files,cscope.files,cscope.out,cscope.po.out,cscope.in.out,,{arch}/,autom4te.cache/,*.orig,*.rej,*.bak,*~,#*#,*.swp,*.tmp,*_flymake.*,*_flymake,*.o,*.a,*.so,*.lo,*.zip,*.gz,*.bz2,*.xz,*.lzh,*.Z,*.tgz,*.min.js,*min.css,sysroot/:
+59
View File
@@ -0,0 +1,59 @@
# Travis CI integration -- https://travis-ci.org/troglobit/finit
# Defaults to GNU GCC and autotools: ./configure && make && make test
language: c
# Use docker for quicker builds, it now allows https://docs.travis-ci.com/user/apt/
sudo: false
# Use non-docker builds atm. to install libuEv and libite from source
#sudo: true
# Test build with both GCC and Clang (LLVM)
# - clang
compiler:
- gcc
env:
global:
# 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:
apt:
packages:
- tree
coverity_scan:
project:
name: "troglobit/finit"
description: "finit | Fast & Extensible init for Linux"
notification_email: troglobit@gmail.com
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.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
- PKG_CONFIG_PATH=/tmp/lib/pkgconfig ./configure --prefix=/tmp --disable-inetd --enable-static
- make clean
- make V=1 -j5
- 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
- make install-strip
- tree /tmp
- ldd /tmp/sbin/finit
- size /tmp/sbin/finit
- size /tmp/sbin/initctl
- size /tmp/sbin/reboot
- LD_LIBRARY_PATH=/tmp/lib /tmp/sbin/initctl -h
+1 -3
View File
@@ -1,12 +1,10 @@
Current Maintainer(s): Current Maintainer(s):
* Joachim Wiberg <troglobit@gmail.com> * Joachim Nilsson <troglobit@gmail.com>
Major Contributors: Major Contributors:
* Tobias Waldekranz <tobias@waldekranz.com> * Tobias Waldekranz <tobias@waldekranz.com>
* Mattias Walström <mattias.walstrom@westermo.se> * Mattias Walström <mattias.walstrom@westermo.se>
* Jonas Johansson <jonas.johansson@westermo.se> * Jonas Johansson <jonas.johansson@westermo.se>
* Jacques de Laval <jacques@de-laval.se>
* Magnus Malm <magnusmalm@gmail.com>
Original Author(s): Original Author(s):
* Claudio Matsuoka <cmatsuoka@gmail.com> * Claudio Matsuoka <cmatsuoka@gmail.com>
+68 -1091
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,5 +1,5 @@
Copyright (c) 2008-2010 Claudio Matsuoka <cmatsuoka@gmail.com> Copyright (c) 2008-2010 Claudio Matsuoka <cmatsuoka@gmail.com>
Copyright (c) 2008-2024 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 Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
+6 -17
View File
@@ -1,28 +1,23 @@
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4
SUBDIRS = man plugins src system test tmpfiles.d SUBDIRS = plugins src
doc_DATA = README.md LICENSE contrib/finit.conf doc_DATA = README.md LICENSE contrib/finit.conf
EXTRA_DIST = README.md LICENSE ChangeLog.md contrib/finit.conf EXTRA_DIST = README.md LICENSE ChangeLog.md contrib/finit.conf
if CONTRIB if CONTRIB
SUBDIRS += contrib SUBDIRS += contrib
endif endif
if DOC if DOCS
SUBDIRS += doc SUBDIRS += docs
endif endif
if BASH
bashdir = $(BASH_DIR)
dist_bash_DATA = initctl
endif
# Compat hook # Compat hook
install-dev: install-dev:
@make -C src install-pkgincludeHEADERS @make -C src install-pkgincludeHEADERS
# Target to run when building a release # Target to run when building a release
release: distcheck release: distcheck
@for file in $(DIST_ARCHIVES); do \ @for file in $(DIST_ARCHIVES); do \
md5sum $$file > ../$$file.md5; \ md5sum $$file > ../$$file.md5; \
sha256sum $$file > ../$$file.sha256; \
done done
@mv $(DIST_ARCHIVES) ../ @mv $(DIST_ARCHIVES) ../
@echo @echo
@@ -30,11 +25,5 @@ release: distcheck
@echo "=================================================================" @echo "================================================================="
@for file in $(DIST_ARCHIVES); do \ @for file in $(DIST_ARCHIVES); do \
printf "$$file \tDistribution tarball\n"; \ printf "$$file \tDistribution tarball\n"; \
printf "$$file.md5\t"; cat ../$$file.md5 | cut -f1 -d' '; \ printf "$$file.md5\t"; cat ../$$file.md5 | cut -f1 -d' '; \
printf "$$file.sha256\t"; cat ../$$file.sha256 | cut -f1 -d' '; \
done done
DISTCHECK_CONFIGURE_FLAGS = --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
--enable-testserv-plugin --enable-x11-common-plugin \
--with-watchdog --with-keventd --with-fstab=/etc/fstab \
--with-bash-completion-dir=no
+204 -383
View File
@@ -1,73 +1,42 @@
[![License Badge][]][License] [![GitHub Status][]][GitHub] [![Coverity Status][]][Coverity Scan]
<img align="right" src="img/finit3.png" alt="Finit: Fast Init"> <img align="right" src="img/finit3.png" alt="Finit: Fast Init">
* [Introduction](#introduction) * [Introduction](#introduction)
* [Features](#features) * [Features](#features)
* [Bootstrap](docs/bootstrap.md#bootstrap)
* [Runlevels](#runlevels) * [Runlevels](#runlevels)
* [Syntax](doc/config.md#syntax) * [Syntax](docs/config.md#syntax)
* [Inetd](docs/inetd.md#inetd)
* [Runparts & /etc/rc.local](#runparts--etcrclocal) * [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) * [Rebooting & Halting](#rebooting--halting)
* [Commands & Status](#commands--status) * [Commands & Status](#commands--status)
* [Tips & Tricks with the kernel cmdline](doc/cmdline.md) * [Tips & Tricks with the kernel cmdline](docs/cmdline.md)
* [Building](doc/build.md#building) * [Building](docs/build.md#building)
* [Running](doc/build.md#running) * [Running](docs/build.md#running)
* [Recovery](doc/build.md#recovery) * [Recovery](docs/build.md#recovery)
* [Debugging](doc/build.md#debugging) * [Debugging](docs/build.md#debugging)
* [Requirements](#requirements) * [Requirements](#requirements)
* [Origin & References](#origin--references) * [Origin & References](#origin--references)
Introduction Introduction
------------ ------------
[![License Badge][]][License] [![Travis Status]][Travis] [![Coverity Status]][Coverity Scan]
Fast init for Linux systems. Reverse engineered from the [EeePC Finit is a simple alternative to [SysV init][4] and [systemd][6]. It
fastinit][] 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 …"
![Alpine screenshot](img/alpine-screenshot2.png)
*Figure 1: Screenshot of Finit booting [Alpine Linux (HowTo)](https://github.com/troglobit/finit/tree/master/contrib/alpine).*
Features include:
* Runlevels, defined per service
* One-shot tasks, services (daemons), or [SysV init][4] start/stop scripts
* Runparts and `/etc/rc.local` support
* Process supervision similar to [systemd][]
* Sourcing environment files
* Conditions for network/process/custom dependencies
* Readiness notification; PID files (native) for synchronizing system
startup, support for systemd [sd_notify()][], or [s6 style][] too
* Limited support for [tmpfiles.d(5)][] (no aging, attributes, or subvolumes)
* Pre/Post script actions
* Rudimentary [templating support](doc/config.md#templating)
* Tooling to enable/disable services
* Built-in getty
* Built-in watchdog, with support for hand-over to [watchdogd](https://troglobit.com/watchdogd.html)
* Built-in support for Debian/BusyBox `/etc/network/interfaces`
* Cgroups v2, both configuration and monitoring in `initctl top`
* Plugin support for customization
* Proper rescue mode with bundled `sulogin` for protected maintenance shell
* Integration with [watchdogd][] for full system supervision
* Logging to kernel ring buffer before `syslogd` has started, see the
recommended [sysklogd][] project for complete logging integration
and how to log to the kernel ring buffer from scripts using `logger`
Focus is on small and embedded systems, although Finit is fully usable Focus is on small and embedded systems, although Finit is fully usable
on server and desktop systems as well. For working examples, see the on server and desktop systems as well. For working examples, see the
[contrib/](contrib/) section with tutorials for the following Linux [contrib/](contrib/) section with tutorials for:
distributions:
* [Void Linux](contrib/void/), * [Alpine Linux](contrib/alpine/),
* [Alpine Linux](contrib/alpine/), and * [Debian GNU/Linux](contrib/debian/), and
* [Debian GNU/Linux](contrib/debian/), also works on Ubuntu/Linux Mint * [Void Linux](contrib/void/)
> [!NOTE] ![Alpine screenshot](img/alpine-screenshot.png)
> Support for various Linux distributions does not mean Finit installs The screenshot shows [Alpine Linux](https://www.alpinelinux.org/).
> easily on all architectures. The bundled install scripts are examples
> for standard installations, tested on amd64 (x86_64) systems. Custom
> setups, e.g., for embedded systems, can be found in the following
> [Buildroot][] based examples: [myLinux][], [Infix][], or the plain
> [br2-finit-demo](https://github.com/troglobit/br2-finit-demo).
Example Example
@@ -76,90 +45,83 @@ Example
This example `/etc/finit.conf` can also be split up in multiple `.conf` This example `/etc/finit.conf` can also be split up in multiple `.conf`
files in `/etc/finit.d`. Available, but not yet enabled, services can files in `/etc/finit.d`. Available, but not yet enabled, services can
be placed in `/etc/finit.d/available` and enabled by an operator using be placed in `/etc/finit.d/available` and enabled by an operator using
the [initctl](#commands--status) tool. See the above mentioned Linux the [initctl](#commands--status) tool.
distributions, or [myLinux][].
> [!TIP]
> As of Finit v4.4, `.conf` lines can be broken up using the standard
> UNIX continuation character (`\`), trailing comments are now also
> supported. The latter means you need to escape any hashes used in
> directives and descriptions (`\#`). For more on this and examples,
> see the [finit.conf(5)][] manual or [doc/config.md](doc/config.md).
```ApacheConf ```ApacheConf
# Fallback if /etc/hostname is missing # Fallback if /etc/hostname is missing
host default host default
# Runlevel to start after bootstrap, 'S', default: 2 # Runlevel to start after bootstrap, 'S', default: 2
#runlevel 2 runlevel 2
# Support for setting global environment variables, using foo=bar syntax
# be careful though with variables like PATH, SHELL, LOGNAME, etc.
#PATH=/usr/bin:/bin:/usr/sbin:/sbin
# Max file size for each log file: 100 kiB, rotate max 4 copies: # Max file size for each log file: 100 kiB, rotate max 4 copies:
# log => log.1 => log.2.gz => log.3.gz => log.4.gz # log => log.1 => log.2.gz => log.3.gz => log.4.gz
log size=100k count=4 log size=100k count=4
# Services to be monitored and respawned as needed # Services to be monitored and respawned as needed
service [S12345] env:-/etc/conf.d/watchdog watchdog $WATCHDOG_OPTS $WATCHDOG_DEV -- System watchdog daemon service [S12345] /sbin/watchdogd -L -f -- System watchdog daemon
service [S12345] env:-/etc/conf.d/syslog syslogd -n $SYSLOGD_OPTS -- System log daemon service [S12345] /sbin/syslogd -n -b 3 -D -- System log daemon
service [S12345] <pid/syslogd> env:-/etc/conf.d/klogd klogd -n $KLOGD_OPTS -- Kernel log daemon service [S12345] /sbin/klogd -n -- Kernel log daemon
service [2345] env:-/etc/conf.d/lldpd lldpd -d $LLDPD_OPTS -- LLDP daemon (IEEE 802.1ab) 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 # 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 # 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 # log file is rotated with the above settings. The condition declares
# a dependency on a system default route (gateway) to be set. A single # a dependency on a system default route (gateway) to be set. A single
# <!> at the beginning means ntpd does not respect SIGHUP for restart. # <!> 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 # For multiple instances of the same service, add :ID somewhere between
# the service/run/task keyword and the command. # the service/run/task keyword and the command.
service :80 [2345] merecat -n -p 80 /var/www -- Web server service :1 [2345] /sbin/merecat -n -p 80 /var/www -- Web server
service :8080 [2345] merecat -n -p 8080 /var/www -- Old 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 # Alternative method instead of below runparts, can also use /etc/rc.local
#sysv [S] /etc/init.d/keyboard-setup -- Setting up preliminary keymap #task [S] /etc/init.d/keyboard-setup start -- Setting up preliminary keymap
#sysv [S] /etc/init.d/acpid -- Starting ACPI Daemon #task [S] /etc/init.d/acpid start -- Starting ACPI Daemon
#task [S] /etc/init.d/kbd -- Preparing console #task [S] /etc/init.d/kbd start -- Preparing console
# Hidden from boot progress, using empty `--` description # Inetd services to start on demand, with alternate ports and filtering
#sysv [S] /etc/init.d/keyboard-setup -- inetd ftp/tcp nowait [2345] /sbin/in.ftpd -- FTP daemon
#sysv [S] /etc/init.d/acpid -- inetd tftp/udp wait [2345] /sbin/in.tftpd -- TFTP daemon
#task [S] /etc/init.d/kbd -- 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 # Run start scripts from this directory
# runparts /etc/start.d # runparts /etc/start.d
# Virtual consoles run BusyBox getty, keep kernel default speed # Virtual consoles run BusyBox getty
tty [12345] /sbin/getty -L 0 /dev/tty1 linux nowait noclear tty [12345] /sbin/getty -L 115200 /dev/tty1 linux
tty [2345] /sbin/getty -L 0 /dev/tty2 linux nowait noclear tty [12345] /sbin/getty -L 115200 /dev/tty2 linux
tty [2345] /sbin/getty -L 0 /dev/tty3 linux nowait noclear tty [12345] /sbin/getty -L 115200 /dev/tty3 linux
# Use built-in getty for serial port and USB serial # Use built-in getty for serial port and USB serial
#tty [12345] /dev/ttyAMA0 noclear nowait tty [12345] /dev/ttyAMA0 115200 noclear nowait
#tty [12345] /dev/ttyUSB0 noclear tty [12345] /dev/ttyUSB0 115200 noclear
# Just give me a shell, I need to debug this embedded system! # Just give me a shell, I need to debug this embedded system!
#tty [12345] console noclear nologin tty [12345] @console noclear nologin
``` ```
The `service` stanza, as well as `task`, `run` and others are described The `service` stanza, as well as `task`, `run`, `inetd` and others are
in full in [doc/config.md](doc/config.md). Here's a quick overview of described in full in [docs/config.md](docs/config.md). Here's a quick
some of the most common components needed to start a UNIX daemon: 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 service [LVLS] <COND> /path/to/daemon ARGS -- Some text
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
| | | | | | | `---------- Optional description | | | | | `-- Optional description
| | | | | | `------------------ Daemon arguments | | | | `---------- Daemon arguments
| | | | | `------------------------- Path to daemon | | | `-------------------------- Path to daemon
| | | | `---------------------------------------------------- Optional env. file | | `--------------------------------- Optional conditions
| | | `-------------------------------------------------------- Redirect output to log | `---------------------------------------- Optional Runlevels
| | `--------------------------------------------------------------- Optional conditions `------------------------------------------------ Monitored application
| `---------------------------------------------------------------------- Optional Runlevels
`------------------------------------------------------------------------------ Monitored application
``` ```
Some components are optional: runlevel(s), condition(s) and description, Some components are optional: runlevel(s), condition(s) and description,
@@ -168,18 +130,18 @@ advanced uses as well:
service /usr/sbin/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 the most common conditions is to wait for basic networking to become
available: available:
service <net/route/default> nginx -- High performance 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 Here is another example where we instruct Finit to not start BusyBox
`ntpd` until `syslogd` has started properly. Finit waits for `syslogd` `ntpd` until `syslogd` has started properly. Finit waits for `syslogd`
to create its PID file, by default `/var/run/syslogd.pid`. to create its PID file, by default `/var/run/syslogd.pid`.
service [2345] log <!pid/syslogd> ntpd -n -N -p pool.ntp.org service [2345] log <svc/sbin/syslogd> /usr/sbin/ntpd -n -N -p pool.ntp.org
service [S12345] syslogd -n -- Syslog daemon service [S12345] /sbin/syslogd -n -- Syslog daemon
Notice the `log` keyword, BusyBox `ntpd` uses `stderr` for logging when Notice the `log` keyword, BusyBox `ntpd` uses `stderr` for logging when
run in the foreground. With `log` Finit redirects `stdout` + `stderr` run in the foreground. With `log` Finit redirects `stdout` + `stderr`
@@ -188,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 A service, or task, can have multiple dependencies listed. Here we wait
for *both* `syslogd` to have started and basic networking to be up: 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 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. and as soon as it comes back up again `ntpd` is restarted automatically.
@@ -207,6 +169,26 @@ Features
Start, monitor and restart services should they fail. 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** **Getty**
Finit supports external getty but also comes with a limited built-in Finit supports external getty but also comes with a limited built-in
@@ -215,9 +197,9 @@ waits for user input before handing over to `/bin/login`, which is
responsible for handling the actual authentication. responsible for handling the actual authentication.
```conf ```conf
tty [12345] /dev/tty1 nowait linux tty [12345] /dev/tty1 38400 nowait linux
tty [12345] /dev/ttyAMA0 noclear vt100 tty [12345] /dev/ttyAMA0 115200 noclear vt100
tty [12345] /sbin/getty -L /dev/ttyAMA0 vt100 tty [12345] /sbin/getty -L 115200 /dev/ttyAMA0 vt100
``` ```
Users of embedded systems may want to enable automatic serial console Users of embedded systems may want to enable automatic serial console
@@ -226,19 +208,19 @@ system uses `ttyS0`, `ttyAMA0`, `ttyMXC0`, or anything else. Finit
figures it out by querying sysfs: `/sys/class/tty/console/active`. figures it out by querying sysfs: `/sys/class/tty/console/active`.
```conf ```conf
tty [12345] @console linux noclear tty [12345] @console 115200 linux noclear
``` ```
Notice the optional `noclear`, `nowait`, and `nologin` flags. The Notice the optional `noclear`, `nowait`, and `nologin` flags. The
latter is for skipping the login process entirely. For more information, 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** **Runlevels**
Support for SysV init-style [runlevels][5] is available, in the same Support for SysV init-style [runlevels][5] is available, in the same
minimal style as everything else in Finit. The `[2345]` syntax can be 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 Reserved runlevels are 0 and 6, halt and reboot, respectively just like
SysV init. Runlevel 1 can be configured freely, but is recommended to SysV init. Runlevel 1 can be configured freely, but is recommended to
@@ -247,49 +229,11 @@ networking here. The configured `runlevel NUM` from `/etc/finit.conf`
is what Finit changes to after bootstrap, unless 'single' (or 'S') is is what Finit changes to after bootstrap, unless 'single' (or 'S') is
given on the kernel cmdline, in which case runlevel 1 is started. given on the kernel cmdline, in which case runlevel 1 is started.
All services in runlevel S) are started first, followed by the desired All services in runlevel S(0) are started first, followed by the desired
run-time runlevel. Run tasks in runlevel S can be started in sequence run-time runlevel. Run tasks in runlevel S can be started in sequence
by using `run [S] cmd`. Changing runlevels at runtime is done like any by using `run [S] cmd`. Changing runlevels at runtime is done like any
other init, e.g. <kbd>init 4</kbd>, but also using the more advanced other init, e.g. <kbd>init 4</kbd>, but also using the more advanced
[`initctl`](#commands--status) tool. `intictl` tool.
**Conditions**
As mentioned previously, Finit has an advanced dependency system to
handle synchronization, called [conditions](doc/conditions.md). It can
be used in many ways; depend on another service, network availability,
etc.
One *really cool* example useful for embedded systems is to run certain
scripts if a board has a certain feature encoded in its device tree. At
bootstrap we run the following `ident` script:
```sh
#!/bin/sh
conddir=/var/run/finit/cond/hw/model
dtmodel=/sys/firmware/devicetree/base/model
if ! test -e $dtmodel; then
exit 0
fi
model=$(cat $dtmodel | tr "[A-Z] " "[a-z]-")
mkdir -p $conddir && ln -s ../../reconf $conddir/$model
```
Provided the device tree node exists, and is a string, we can then use
the condition `<hw/model/foo>` when starting other scripts. Here is an
example:
```
run [S] /path/to/ident --
task [2] <hw/model/foo> /path/to/foo-init -- Initializing Foo board
```
> [!TIP]
> Notice the trick with an empty description to hide the call to `ident`
> in the Finit progress output.
**Plugins** **Plugins**
@@ -306,74 +250,34 @@ Capabilities:
Hook into the boot at predefined points to extend Finit Hook into the boot at predefined points to extend Finit
- **I/O** - **I/O**
Listen to external events and control Finit behavior/services 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` 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 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. 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/` Finit prior to v3.0 showed the progress at boot: plugins and modules
registering any changes to `.conf` files. To activate a change the user being loaded, run/tasks/services being started, etc. By default Finit
must call `initctl reload`, which reloads all modified files, stops any is now silent, but progress can still be enabled at build-time using:
removed services, starts new ones, and restarts any modified ones. If the
command line arguments of a service have changed, the process will be
terminated and then started again with the updated arguments. If the arguments
have not been modified and the process supports SIGHUP, the process will
receive a SIGHUP rather than being terminated and started.
For some use-cases the extra step of calling `initctl reload` creates an configure --enable-progress
unnecessary overhead, which can be removed at build-time using:
configure --enable-auto-reload or at boot from the kernel cmdline using the boot parameter `splash`:
```shell
append="init=/sbin/finit splash"
```
**Cgroups** For a really nice boot, add `quiet` as well. This silences the output
from the kernel, leaving only warnings and errors. For other kernel
Finit supports cgroups v2 and comes with the following default groups in command line parameters, see [docs/build.md](docs/build.md#recovery).
which services and user sessions are placed in:
/sys/fs/cgroup
|-- init/ # cpu.weight:100
|-- system/ # cpu.weight:9800
`-- user/ # cpu.weight:100
Finit itself and its helper scripts and services are placed in the
top-level leaf-node group `init/`, which also is _reserved_.
All run/task/service/sysv processes are placed in their own sub-group
in `system/`. The name of each sub-group is taken from the respective
`.conf` file from `/etc/finit.d`.
All getty/tty processes are placed in their own sub-group in `user/`.
The name of each sub-group is taken from the username.
A fourth group also exists, the `root` group. It is also _reserved_ and
primarily intended for RT tasks. If you have RT tasks they need to be
declared as such in their service stanza like this:
service [...] <...> cgroup.root /path/to/foo args -- description
or
cgroup.root
service [...] <...> /path/to/foo args -- description
service [...] <...> /path/to/bar args -- description
See [doc/config.md](doc/config.md#cgroups) for more information, e.g.,
how to configure per-group limits.
The `initctl` tool has three commands to help debug and optimize the
setup and monitoring of cgroups. See the `ps`, `top`, and `cgroup`
commands for details.
> [!NOTE]
> Systems that do not support cgroups, specifically version 2, are
> automatically detected. On such systems the above functionality is
> disabled early at boot.
Runparts & /etc/rc.local Runparts & /etc/rc.local
@@ -395,33 +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`. 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 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 end of the boot, before calling the `HOOK_SYSTEM_UP`. See more on hooks
in [doc/plugins.md](doc/plugins.md#hooks). in [docs/plugins.md](docs/plugins.md#hooks), and about the system bootstrap
in [docs/bootstrap.md](docs/bootstrap.md).
### Limitations
It is not possible to call Finit via signals or use `initctl` in any
runparts or `/etc/rc.local` script. This because Finit is single
threaded and is calling these scripts in a blocking fashion at the end
of runlevel S, at which point the event loop has not yet been started.
The event loop is the whole thing which Finit is built around, except
for runlevel S, which remains a slow procession through a lot of set up,
with a few hooks and blocking call outs to external scripts.
However, not all `initctl` commands are prohibited. Supported commands:
- `inictl cond`: only operate of files in `/run/finit/cond`
- `initctl enable/disable`: enabled run/task/service is activated on
the runlevel change from S to 2
- `initctl touch/show/create/delete/list`: `create`, provided the
non-interactive mode is used, again changes take effect in the
runlevel change directly after bootstrap
- `initctl -f reboot/poweroff/halt`: provided the `-f` flag is used to
force direct kernel commands
**Example:** you can set a `usr/` condition in `/etc/rc.local` and have
a service/task in runlevel 2 depend on it to execute.
Runlevels Runlevels
@@ -442,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: `task`, or `tty`, add `[NNN]` to your `/etc/finit.conf`, like this:
``` ```
service [S12345] syslogd -n -x -- System log daemon service [S12345] /sbin/syslogd -n -x -- System log daemon
run [S] /etc/init.d/acpid start -- Starting ACPI Daemon run [S] /etc/init.d/acpid start -- Starting ACPI Daemon
task [S] /etc/init.d/kbd start -- Preparing console task [S] /etc/init.d/kbd start -- Preparing console
service [S12345] <pid/syslogd> klogd -n -x -- Kernel log daemon service [S12345] /sbin/klogd -n -x -- Kernel log daemon
tty [12345] /dev/tty1 tty [12345] /dev/tty1
tty [2] /dev/tty2 tty [2] /dev/tty2
@@ -492,159 +371,105 @@ Rebooting & Halting
Traditionally, rebooting and halting a UNIX system is done by changing Traditionally, rebooting and halting a UNIX system is done by changing
its runlevel. Finit comes with its own tooling providing: `shutdown`, its runlevel. Finit comes with its own tooling providing: `shutdown`,
`reboot`, `poweroff`, and `suspend`, but also the `initctl` tool, `reboot`, `poweroff`, and `suspend`, but also the traditional `init` and
detailed in the next section. `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 For compatibility reasons Finit listens to the same set of signals as
BusyBox init. This is not 100% compatible with SysV init, but clearly BusyBox init. This is not 100% compatible with SysV init, but clearly
the more common combination for Finit. For more details, see 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 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 services, called `initctl`. Unlike `telinit` the `initctl` tool does
not return until the given command has fully completed. not return until the given command has fully completed.
``` ```shell
~ $ initctl -h
Usage: initctl [OPTIONS] [COMMAND] Usage: initctl [OPTIONS] [COMMAND]
Options: Options:
-b, --batch Batch mode, no screen size probing
-c, --create Create missing paths (and files) as needed
-f, --force Ignore missing files and arguments, never prompt
-h, --help This help text
-j, --json JSON output in 'status' and 'cond' commands
-1, --once Only one lap in commands like 'top'
-p, --plain Use plain table headings, no ctrl chars
-q, --quiet Silent, only return status of command
-t, --no-heading Skip table headings
-v, --verbose Verbose output -v, --verbose Verbose output
-V, --version Show program version -h, --help This help text
Commands: Commands:
debug Toggle Finit (daemon) debug debug Toggle Finit (daemon) debug
help This help text help This help text
version Show program version version Show Finit version
ls | list List all .conf in /etc/finit.d list List all .conf in /etc/finit.d/
create <CONF> Create .conf in /etc/finit.d/available enable <CONF> Enable .conf in /etc/finit.d/available/
delete <CONF> Delete .conf in /etc/finit.d/available disable <CONF> Disable .conf in /etc/finit.d/[enabled/]
show <CONF> Show .conf in /etc/finit.d/available touch <CONF> Mark .conf in /etc/finit.d/ for reload
edit <CONF> Edit .conf in /etc/finit.d/available reload Reload *.conf in /etc/finit.d/ (activates changes)
touch <CONF> Change .conf in /etc/finit.d/available
enable <CONF> Enable .conf in /etc/finit.d/available cond set <COND> Set (assert) condition => +COND
disable <CONF> Disable .conf in /etc/finit.d/enabled cond clear <COND> Clear (deassert) condition => -COND
reload Reload *.conf in /etc/finit.d (activate changes) cond show Show condition status
cond dump Dump all conditions and their status
cond set <COND> Set (assert) user-defined conditions +usr/COND
cond get <COND> Get status of user-defined condition, see $? and -v
cond clear <COND> Clear (deassert) user-defined conditions -usr/COND
cond status Show condition status, default cond command
cond dump [TYPE] Dump all, or a type of, conditions and their status
log [NAME] Show ten last Finit, or NAME, messages from syslog log [NAME] Show ten last Finit, or NAME, messages from syslog
start <NAME>[:ID] Start service by name, with optional ID start <JOB|NAME>[:ID] Start service by job# or name, with optional ID
stop <NAME>[:ID] Stop/Pause a running service by name stop <JOB|NAME>[:ID] Stop/Pause a running service by job# or name
reload <NAME>[:ID] Reload service as if .conf changed (SIGHUP or restart) restart <JOB|NAME>[:ID] Restart (stop/start) service by job# or name
This allows restart of run/tasks that have already run status <JOB|NAME>[:ID] Show service status, by job# or name
Note: Finit .conf file(s) are *not* reloaded! status | show Show status of services, default command
restart <NAME>[:ID] Restart (stop/start) service by name
signal <NAME>[:ID] <S> Send signal S to service by name, with optional ID
ident [NAME] Show matching identities for NAME, or all
status <NAME>[:ID] Show service status, by name
status Show status of services, default command
cgroup List cgroup config overview
ps List processes based on cgroups
top Show top-like listing based on cgroups
plugins List installed plugins
runlevel [0-9] Show or set runlevel: 0 halt, 6 reboot runlevel [0-9] Show or set runlevel: 0 halt, 6 reboot
reboot Reboot system reboot Reboot system
halt Halt system halt Halt system
poweroff Halt and power off system poweroff Halt and power off system
suspend Suspend system
utmp show Raw dump of UTMP/WTMP db utmp show Raw dump of UTMP/WTMP db
``` ```
For services *not* supporting `SIGHUP` the `<!>` notation in the .conf 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 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. these will also affect how a service is maintained.
> [!NOTE] **Note:** even though it is possible to start services not belonging in
> Even though it is possible to start services not belonging in the the current runlevel these services will not be respawned automatically
> current runlevel these services will not be respawned automatically by by Finit if they exit (crash). Hence, if the runlevel is 2, the below
> Finit if they exit (crash). Hence, if the runlevel is 2, the below Dropbear SSH service will not be restarted if it is killed or exits.
> Dropbear SSH service will not be restarted if it is killed or exits.
The `status` command is the default, it displays a quick overview of all ```shell
monitored run/task/services. Here we call `initctl -p`, suitable for ~ $ initctl status -v
scripting and documentation: 1 running 476 [S12345] /sbin/watchdog -T 16 -t 2 -F /dev/watchdog
2 running 477 [S12345] /sbin/syslogd -n -b 3 -D
``` 3 running 478 [S12345] /sbin/klogd -n
alpine:~# initctl -p 4:1 inetd 0 [2345] internal time allow *:37,!eth0
PID IDENT STATUS RUNLEVELS DESCRIPTION 4:2 inetd 0 [2345] internal time allow eth0:3737
====================================================================== 5:1 inetd 0 [2345] /sbin/telnetd allow *:23 deny eth0,eth1
1506 acpid running [---2345----] ACPI daemon 5:2 inetd 0 [2345] /sbin/telnetd allow eth0:2323,eth2:2323,eth1:2323
1509 crond running [---2345----] Cron daemon 6:1 inetd 0 [345] /sbin/dropbear allow eth0:222
1489 dropbear running [---2345----] Dropbear SSH daemon 6:2 inetd 0 [345] /sbin/dropbear allow *:22 deny eth0
1511 klogd running [S-12345----] Kernel log daemon
1512 ntpd running [---2345----] NTP daemon
1473 syslogd running [S-12345----] Syslog daemon
alpine:~# initctl -pv
PID IDENT STATUS RUNLEVELS COMMAND
======================================================================
1506 acpid running [---2345----] acpid -f
1509 crond running [---2345----] crond -f -S $CRON_OPTS
1489 dropbear running [---2345----] dropbear -R -F $DROPBEAR_OPTS
1511 klogd running [S-12345----] klogd -n $KLOGD_OPTS
1512 ntpd running [---2345----] ntpd -n $NTPD_OPTS
1473 syslogd running [S-12345----] syslogd -n
```
The environment variables to each of the services above are read from,
in the case of Alpine Linux, `/etc/conf.d/`. Other distributions may
have other directories, e.g., Debian use `/etc/default/`.
The `status` command takes an optional `NAME:ID` argument. Here we
check the status of `dropbear`, which only has one instance in this
system:
```
alpine:~# initctl -p status dropbear
Status : running
Identity : dropbear
Description : Dropbear SSH daemon
Origin : /etc/finit.d/enabled/dropbear.conf
Environment : -/etc/conf.d/dropbear
Condition(s):
Command : dropbear -R -F $DROPBEAR_OPTS
PID file : !/run/dropbear.pid
PID : 1485
User : root
Group : root
Uptime : 2 hour 46 min 56 sec
Runlevels : [---2345----]
Memory : 1.2M
CGroup : /system/dropbear cpu 0 [100, max] mem [--.--, max]
|- 1485 dropbear -R -F
|- 2634 dropbear -R -F
|- 2635 ash
`- 2652 initctl -p status dropbear
Apr 8 12:19:49 alpine authpriv.info dropbear[1485]: Not backgrounding
Apr 8 12:37:45 alpine authpriv.info dropbear[2300]: Child connection from 192.168.121.1:47834
Apr 8 12:37:46 alpine authpriv.notice dropbear[2300]: Password auth succeeded for 'root' from 192.168.121.1:47834
Apr 8 12:37:46 alpine authpriv.info dropbear[2300]: Exit (root) from <192.168.121.1:47834>: Disconnect received
Apr 8 15:02:11 alpine authpriv.info dropbear[2634]: Child connection from 192.168.121.1:48576
Apr 8 15:02:12 alpine authpriv.notice dropbear[2634]: Password auth succeeded for 'root' from 192.168.121.1:48576
``` ```
@@ -665,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`: the following one-shot task early in your `/etc/finit.conf`:
```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` Finit has a built-in Getty for TTYs, but requires a working `/bin/login`
@@ -674,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 For a fully operational system `/var`, `/run` and `/tmp` must be set up
properly in `/etc/fstab` -- which is iterated over at boot. 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 Origin & References
------------------- -------------------
@@ -682,43 +510,36 @@ This project is based on the [original finit][] by [Claudio Matsuoka][]
which was reverse engineered from syscalls of the [EeePC fastinit][] — which was reverse engineered from syscalls of the [EeePC fastinit][] —
"gaps filled with frog DNA …" "gaps filled with frog DNA …"
Finit is developed and maintained by [Joachim Wiberg][] at [GitHub][6]. Finit is developed and maintained by [Joachim Nilsson][] at [GitHub][].
Please file bug reports, clone it, or send pull requests for bug fixes Please file bug reports, clone it, or send pull requests for bug fixes
and proposed extensions. and proposed extensions.
[1]: https://en.wikipedia.org/wiki/Process_supervision [1]: https://en.wikipedia.org/wiki/Process_supervision
[2]: https://cr.yp.to/daemontools.html [2]: http://cr.yp.to/daemontools.html
[3]: https://smarden.org/runit/ [3]: http://smarden.org/runit/
[4]: https://en.wikipedia.org/wiki/Init [4]: http://en.wikipedia.org/wiki/Init
[5]: https://en.wikipedia.org/wiki/Runlevel [5]: http://en.wikipedia.org/wiki/Runlevel
[6]: https://github.com/troglobit/finit [6]: https://www.freedesktop.org/wiki/Software/systemd/
[9]: https://github.com/troglobit/troglos
[RFC862]: https://tools.ietf.org/html/rfc862 [RFC862]: https://tools.ietf.org/html/rfc862
[RFC863]: https://tools.ietf.org/html/rfc863 [RFC863]: https://tools.ietf.org/html/rfc863
[RFC864]: https://tools.ietf.org/html/rfc864 [RFC864]: https://tools.ietf.org/html/rfc864
[RFC867]: https://tools.ietf.org/html/rfc867 [RFC867]: https://tools.ietf.org/html/rfc867
[RFC868]: https://tools.ietf.org/html/rfc868 [RFC868]: https://tools.ietf.org/html/rfc868
[init]: https://en.wikipedia.org/wiki/Init [init]: http://en.wikipedia.org/wiki/Init
[upstart]: https://upstart.ubuntu.com/ [upstart]: http://upstart.ubuntu.com/
[systemd]: https://www.freedesktop.org/wiki/Software/systemd/ [systemd]: http://www.freedesktop.org/wiki/Software/systemd/
[openrc]: https://www.gentoo.org/proj/en/base/openrc/ [openrc]: http://www.gentoo.org/proj/en/base/openrc/
[sd_notify()]: https://www.freedesktop.org/software/systemd/man/sd_notify.html [run-parts(8)]: http://manpages.debian.org/cgi-bin/man.cgi?query=run-parts
[s6 style]: https://skarnet.org/software/s6/notifywhenup.html
[run-parts(8)]: https://manpages.debian.org/cgi-bin/man.cgi?query=run-parts
[tmpfiles.d(5)]: https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html
[original finit]: http://helllabs.org/finit/ [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 [Claudio Matsuoka]: https://github.com/cmatsuoka
[Joachim Wiberg]: https://troglobit.com [Joachim Nilsson]: http://troglobit.com
[Buildroot]: https://buildroot.org [GitHub]: https://github.com/troglobit/finit
[Infix]: https://kernelkit.github.io
[finit.conf(5)]: https://man.troglobit.com/man5/finit.conf.5.html
[License]: https://en.wikipedia.org/wiki/MIT_License [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
[myLinux]: https://github.com/troglobit/myLinux/ [Travis]: https://travis-ci.org/troglobit/finit
[watchdogd]: https://github.com/troglobit/watchdogd/ [Travis Status]: https://travis-ci.org/troglobit/finit.png?branch=master
[sysklogd]: https://github.com/troglobit/sysklogd/
[GitHub]: https://github.com/troglobit/finit/actions/workflows/build.yml/
[GitHub Status]: https://github.com/troglobit/finit/actions/workflows/build.yml/badge.svg
[Coverity Scan]: https://scan.coverity.com/projects/3545 [Coverity Scan]: https://scan.coverity.com/projects/3545
[Coverity Status]: https://scan.coverity.com/projects/3545/badge.svg [Coverity Status]: https://scan.coverity.com/projects/3545/badge.svg
-7
View File
@@ -1,7 +0,0 @@
#!/bin/sh
# Run test suite with the correct configure params
make distclean
./configure --prefix=/usr --exec-prefix= --sysconfdir=/etc --localstatedir=/var \
--enable-x11-common-plugin --with-watchdog --with-keventd
make -j17 clean check
+113 -255
View File
@@ -1,30 +1,26 @@
AC_INIT([Finit], [4.12], [https://github.com/troglobit/finit/issues], AC_INIT(Finit, 3.2-rc1, https://github.com/troglobit/finit/issues, finit, http://troglobit.com/finit.html)
[finit], [https://troglobit.com/projects/finit/]) AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz subdir-objects])
AC_CONFIG_AUX_DIR(aux)
AM_INIT_AUTOMAKE([1.11 foreign dist-xz subdir-objects])
AM_SILENT_RULES([yes]) AM_SILENT_RULES([yes])
AC_CONFIG_SRCDIR([src/finit.c]) AC_CONFIG_SRCDIR([src/finit.c])
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADER([config.h])
AC_CONFIG_FILES([Makefile AC_CONFIG_FILES([Makefile
contrib/Makefile contrib/Makefile
contrib/alpine/Makefile contrib/alpine/finit.d/Makefile contrib/alpine/finit.d/available/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/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 contrib/void/Makefile contrib/void/finit.d/Makefile contrib/void/finit.d/available/Makefile
doc/Makefile docs/Makefile
man/Makefile
plugins/Makefile plugins/Makefile
src/Makefile src/Makefile])
system/Makefile system/10-hotplug.conf
test/test.env test/Makefile
test/lib/Makefile test/src/Makefile
tmpfiles.d/Makefile])
# Older versions of autoconf (<2.58) do not have AC_CONFIG_MACRO_DIR() # Older versions of autoconf (<2.58) do not have AC_CONFIG_MACRO_DIR()
#m4_include([m4/plugin.m4]) #m4_include([m4/plugin.m4])
#m4_include([m4/expand.m4]) #m4_include([m4/expand.m4])
AC_CONFIG_MACRO_DIR([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 # Handle building plugins either as dynamically loadable, or built-in
LT_INIT([shared disable-static dlopen aix-soname=both disable-fast-install]) LT_INIT([shared disable-static dlopen aix-soname=both disable-fast-install])
@@ -35,234 +31,178 @@ AC_PROG_INSTALL
AC_PROG_MKDIR_P AC_PROG_MKDIR_P
# Configuration. # Configuration.
AC_CHECK_HEADERS([termios.h sys/ioctl.h mntent.h sys/sysmacros.h]) AC_HEADER_STDC
AC_CHECK_FUNCS([strstr getopt getmntent getmntent_r]) AC_CHECK_HEADERS([fstaby.h termios.h])
AC_CHECK_FUNCS([strstr getopt getfsenty])
# Check for uint[8,16,32]_t # Check for uint[8,16,32]_t
AC_TYPE_UINT8_T AC_TYPE_UINT8_T
AC_TYPE_UINT16_T AC_TYPE_UINT16_T
AC_TYPE_UINT32_T AC_TYPE_UINT32_T
# Check for pkg-config first, warn if it's not installed
PKG_PROG_PKG_CONFIG
# Check for required libraries # Check for required libraries
PKG_CHECK_MODULES([uev], [libuev >= 2.2.0]) 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 # Check for configured Finit features
AC_ARG_ENABLE(auto_reload, AC_ARG_ENABLE(emergency_shell,
AS_HELP_STRING([--enable-auto-reload], [Automatic reload on any .conf change]),,[ AS_HELP_STRING([--enable-emergency-shell], [Experimental emergency fallback at boot.
enable_auto_reload=no]) Use only for debugging very early boot problems with Finit]),,[
enable_emergency_shell=no])
AC_ARG_ENABLE(kernel_cmdline, AC_ARG_ENABLE(fallback_shell,
AS_HELP_STRING([--enable-kernel-cmdline], [Parse init args from /proc/cmdline (don't use!)]),,[ AS_HELP_STRING([--enable-fallback-shell], [Start a shell if no TTYs can start]),,[
enable_kernel_cmdline=no]) enable_fallback_shell=no])
AC_ARG_ENABLE(fastboot, AC_ARG_ENABLE(rw-rootfs,
AS_HELP_STRING([--enable-fastboot], [Skip fsck check on filesystems listed in /etc/fstab]),,[ AS_HELP_STRING([--enable-rw-rootfs], [Remount / R/W at boot, usually not for embedded]),,[
enable_fastboot=no]) enable_rw_rootfs=no])
AC_ARG_ENABLE(fsckfix, AC_ARG_ENABLE(progress,
AS_HELP_STRING([--enable-fsckfix], [Run fsck fix mode (options: -yf) on filesystems listed in /etc/fstab]),,[ AS_HELP_STRING([--enable-progress], [Pre Finit v3 bootup progress and heading]),,[
enable_fsckfix=no]) enable_progress=no])
AC_ARG_ENABLE(cgroup, AC_ARG_ENABLE(watchdog,
AS_HELP_STRING([--disable-cgroup], [Disable cgroup v2 support, default: autodetect from /sys/fs/cgroup]),,[ AS_HELP_STRING([--enable-watchdog], [Enable built-in watchdog, uses /dev/watchdog]),,[
enable_cgroup=yes]) enable_watchdog=no])
AC_ARG_ENABLE(redirect, AC_ARG_ENABLE(redirect,
AS_HELP_STRING([--disable-redirect], [Disable redirection of service output to /dev/null]),,[ AS_HELP_STRING([--enable-redirect], [Redirect service output to /dev/null, default: no]),,[
enable_redirect=yes]) enable_redirect_output=no])
AC_ARG_ENABLE(kernel_logging, AC_ARG_ENABLE(inetd,
AS_HELP_STRING([--disable-kernel-logging], [Disable kernel logging to console (use 'quiet' instead!]),,[ AS_HELP_STRING([--disable-inetd], [Disable built-in inetd super server, default enabled]),,[
enable_kernel_logging=yes]) enable_inetd=yes])
AC_ARG_ENABLE(logrotate, AC_ARG_ENABLE(logrotate,
AS_HELP_STRING([--disable-logrotate], [Disable built-in rotation of /var/log/wtmp]),,[ AS_HELP_STRING([--disable-logrotate], [Disable built-in rotation of /var/log/wtmp, default enabled]),,[
enable_logrotate=yes]) enable_logrotate=yes])
AC_ARG_ENABLE(doc, AC_ARG_ENABLE(docs,
AS_HELP_STRING([--disable-doc], [Disable build and install of doc/ section]),,[ AS_HELP_STRING([--disable-docs], [Disable build and install of docs section]),,[
enable_doc=yes]) enable_docs=yes])
AC_ARG_ENABLE(contrib, AC_ARG_ENABLE(contrib,
AS_HELP_STRING([--disable-contrib], [Disable build and install of contrib section]),,[ AS_HELP_STRING([--disable-contrib], [Disable build and install of contrib section]),,[
enable_contrib=yes]) enable_contrib=yes])
AC_ARG_ENABLE([rescue],
AS_HELP_STRING([--disable-rescue], [Disable potentially unsafe rescue mode]),,
[enable_rescue=yes])
# Check for extra plugins to enable # Check for extra plugins to enable
AC_ARG_ENABLE(all_plugins, enable_all_plugins=auto
AS_HELP_STRING([--enable-all-plugins], [Enable all plugins, default: auto]),
enable_all_plugins=$enableval, enable_all_plugins=auto)
AC_PLUGIN([alsa-utils], [no], [Save and restore ALSA sound settings using alsactl]) 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([dbus], [no], [Setup and start system message bus, D-Bus])
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([modules-load], [no], [Scans /etc/modules-load.d for modules to load])
AC_PLUGIN([modprobe], [no], [Coldplug modules using modalias magic])
AC_PLUGIN([resolvconf], [no], [Setup necessary files for resolvconf]) AC_PLUGIN([resolvconf], [no], [Setup necessary files for resolvconf])
AC_PLUGIN([x11-common], [no], [Console setup (for X)]) AC_PLUGIN([x11-common], [no], [Console setup (for X)])
AC_PLUGIN([netlink], [yes], [Basic netlink plugin for IFUP/IFDN and GW events. Can be replaced with externally built plugin that links with libnl or similar.]) AC_PLUGIN([netlink], [yes], [Basic netlink plugin for IFUP/IFDN and GW events. Can be replaced with externally built plugin that links with libnl or similar.])
AC_PLUGIN([hook-scripts], [no], [Trigger script execution from hook points])
AC_PLUGIN([hotplug], [yes], [Start udevd or mdev kernel event datamon])
AC_PLUGIN([rtc], [yes], [Save and restore RTC using hwclock])
AC_PLUGIN([tty], [yes], [Automatically activate new TTYs, e.g. USB-to-serial])
AC_PLUGIN([urandom], [yes], [Setup and save random seed at boot/shutdown])
AC_PLUGIN([testserv], [no], [Test plugin to start test serv daemon])
# Check for extra arguments or packages # Check for extra arguments or packages
AC_ARG_WITH([bash-completion-dir],
AS_HELP_STRING([--with-bash-completion-dir[=PATH]], [Directory to install Bash completion, default: auto]),
[bash_dir=$withval], [bash_dir=yes])
AC_ARG_WITH(fstab,
AS_HELP_STRING([--with-fstab=FILE], [System default fstab, default $sysconfdir/fstab]),
[fstab=$withval], [fstab=yes])
AC_ARG_WITH(heading, AC_ARG_WITH(heading,
AS_HELP_STRING([--with-heading=GREET], [Heading for boot progress. Default: PRETTY_NAME from /etc/os-release, fallback to "Finit vX.YY"]), 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, AC_ARG_WITH(config,
AS_HELP_STRING([--with-config=CONFIG], [Finit bootstrap config file, default /etc/finit.conf]), 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, AC_ARG_WITH(rcsd,
AS_HELP_STRING([--with-rcsd=DIR], [Finit rcS.d/ directory, default /etc/finit.d]), 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, AC_ARG_WITH(rc-local,
AS_HELP_STRING([--with-rc-local=FILE], [SysV init /etc/rc.local file, default /etc/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, AC_ARG_WITH(console,
AS_HELP_STRING([--with-sysconfig=DIR], [System environment directory, sourced by .conf files, default /etc/default & /etc/conf.d]), AS_HELP_STRING([--with-console=DEV], [Console to use, default: /dev/console]),
[sysconfig=$withval], [sysconfig=default]) [console=$withval], [console=/dev/console])
AC_ARG_WITH(group,
AS_HELP_STRING([--with-group=NAME], [Group for /run/finit/socket (initctl), default: root]),
[group=$withval], [group=root])
AC_ARG_WITH(hostname, AC_ARG_WITH(hostname,
AS_HELP_STRING([--with-hostname=NAME], [If /etc/hostname is missing, default: noname]), 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, AC_ARG_WITH(runlevel,
AS_HELP_STRING([--with-runlevel=N], [Runlevel to switch to after bootstrap [1-9], default: 2]), 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, 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]), 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])
AC_ARG_WITH(keventd,
AS_HELP_STRING([--with-keventd], [Enable built-in keventd, default: no]),, [with_keventd=no])
AC_ARG_WITH(sulogin,
AS_HELP_STRING([--with-sulogin@<:@=USER@:>@], [Enable built-in sulogin, optional USER to request password for (default root), default: no.]),[sulogin=$withval],[with_sulogin=no])
AC_ARG_WITH(watchdog,
AS_HELP_STRING([--with-watchdog@<:@=DEV@:>@], [Enable built-in watchdog, default: /dev/watchdog]),
[watchdog=$withval], [with_watchdog=no watchdog=])
AC_ARG_WITH(hook-scripts-path,
AS_HELP_STRING([--with-hook-scripts-path=DIR], [Base directory for hook scripts, default $libexecdir/finit/hook]),
[hook_scripts_path=$withval], [hook_scripts_path=yes])
AC_ARG_WITH(plugin-path,
AS_HELP_STRING([--with-plugin-path=DIR], [Search path for external plugins, default /usr/lib/finit/plugins:/usr/local/lib/finit/plugins]),
[plugin_path=$withval], [plugin_path=yes])
AC_ARG_WITH(rtc-date,
AS_HELP_STRING([--with-rtc-date=DATE], [If RTC date/time is too old, restore to DATE, format "YYYY-MM-DD HH:MM:SS", default "2000-01-01 00:00:00"]),
[rtc_date=$withval], [rtc_date=no])
AC_ARG_WITH(rtc-file,
AS_HELP_STRING([--with-rtc-file=FILE], [If RTC is missing, save and restore system clock from this file, default: no]),
[rtc_file=$withval], [rtc_file=no])
### Enable features ########################################################################### ### Enable features ###########################################################################
# Create config.h from selected features and fallback defaults # Create config.h from selected features and fallback defautls
AS_IF([test "x$enable_auto_reload" = "xyes"], [ AS_IF([test "x$enable_emergency_shell" = "xyes"], [
AC_DEFINE(AUTO_RELOAD, 1, [Finit automatically does `initctl reload` on any .conf change])]) AC_DEFINE(EMERGENCY_SHELL, 1, [Fork off init and let PID 1 wait and start /bin/sh if init crashes.])])
AS_IF([test "x$enable_kernel_cmdline" = "xyes"], [ AS_IF([test "x$enable_fallback_shell" = "xyes"], [
AC_DEFINE(KERNEL_CMDLINE, 1, [Dumpster diving after init args from /proc/cmdline])]) AC_DEFINE(FALLBACK_SHELL, 1, [Start /bin/sh on console if no TTYs.])])
AS_IF([test "x$enable_kernel_logging" = "xyes"], [ AS_IF([test "x$enable_rw_rootfs" = "xyes"], [
AC_DEFINE(KERNEL_LOGGING, 1, [Keep kernel warn/err logs to console])]) AC_DEFINE(REMOUNT_ROOTFS, 1, [Remount / as rw at boot])])
AS_IF([test "x$enable_cgroup" = "xyes"], [ AS_IF([test "x$enable_progress" = "xyes"], [
AC_DEFINE(CGROUP2_ENABLED, 1, [Autodetect cgroup v2 support from /sys/fs/cgroup])]) 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_fastboot" = "xyes"], [ AS_IF([test "x$enable_watchdog" = "xyes"], [
AC_DEFINE(FAST_BOOT, 1, [Skip fsck check on filesystems listed in /etc/fstab])]) AC_DEFINE(BUILTIN_WATCHDOG, 1, [Enable built-in watchdog, kicks on /dev/watchdog])])
AS_IF([test "x$enable_fsckfix" = "xyes"], [
AC_DEFINE(FSCK_FIX, 1, [Run fsck fix mode (options: -yf) on filesystems listed in /etc/fstab])])
AS_IF([test "x$enable_redirect" = "xyes"], [ AS_IF([test "x$enable_redirect" = "xyes"], [
AC_DEFINE(REDIRECT_OUTPUT, 1, [Enable redirection of service output to /dev/null])]) AC_DEFINE(REDIRECT_OUTPUT, 1, [Enable redirection of service output to /dev/null])])
### Disable features ########################################################################### ### Disable features ###########################################################################
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"], [ AS_IF([test "x$enable_logrotate" != "xno"], [
AC_DEFINE(LOGROTATE_ENABLED, 1, [Enable built-in rotation of /var/log/wtmp et al.])]) AC_DEFINE(LOGROTATE_ENABLED, 1, [Enable built-in rotation of /var/log/wtmp et al.])])
AS_IF([test "x$enable_rescue" != "xno"], [
AC_DEFINE([RESCUE_MODE], 1, [Define to enable support for rescue mode.])])
AM_CONDITIONAL(LOGROTATE, [test "x$enable_logrotate" = "xyes"])
### With features ############################################################################## ### With features ##############################################################################
AS_IF([test "x$bash_dir" = "xyes"], [ AS_IF([test "x$with_fifo" != "xno"], [
PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0], AS_IF([test "x$fifo" = "xyes"], [
[BASH_DIR="$(pkg-config --variable=completionsdir bash-completion)"], fifo='$localstatedir/run/initctl'])])
[BASH_DIR="$datadir/bash-completion/completions"])], [ AC_EXPAND_DIR(fifo_path, "$fifo")
BASH_DIR="$bash_dir"]) AC_DEFINE_UNQUOTED(FINIT_FIFO, "$fifo_path", [FIFO for old style init/telinit client programs])
AS_IF([test "x$with_fstab" != "xno"], [
AS_IF([test "x$fstab" = "xyes"], [fstab=$sysconfdir/fstab])
AC_EXPAND_DIR(fstab_path, "$fstab")
AC_DEFINE_UNQUOTED(FINIT_FSTAB, "$fstab_path", [Built-in default: /etc/fstab])],[
AC_DEFINE_UNQUOTED(FINIT_FSTAB, NULL, [No built-in default fstab])])
AS_IF([test "x$with_config" != "xno"], [ AS_IF([test "x$with_config" != "xno"], [
AS_IF([test "x$conf" = "xyes"], [ AS_IF([test "x$config" = "xyes"], [
conf=$sysconfdir/finit.conf])]) conf=$sysconfdir/finit.conf])])
AC_EXPAND_DIR(conf_path, "$conf") AC_EXPAND_DIR(conf_path, "$conf")
AC_DEFINE_UNQUOTED(FINIT_CONF, "$conf_path", [Main Finit configuration file, default /etc/finit.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$with_rcsd" != "xno"], [
AS_IF([test "x$rcsd" = "xyes"], [ AS_IF([test "x$rcsd" = "xyes"], [
rcsd=$sysconfdir/finit.d])]) rcsd=$sysconfdir/finit.d])])
AC_EXPAND_DIR(rcsd_path, "$rcsd") AC_EXPAND_DIR(rcsd_path, "$rcsd")
AC_DEFINE_UNQUOTED(FINIT_RCSD, "$rcsd_path", [Finit rcS.d/, default /etc/finit.d]) 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$with_rc_local" != "xno"], [
AS_IF([test "x$rclocal" = "xyes"], [rclocal=$sysconfdir/rc.local]) AS_IF([test "x$rclocal" = "xyes"], [
AC_EXPAND_DIR(rclocal_path, "$rclocal") rclocal=$sysconfdir/rc.local])])
AC_DEFINE_UNQUOTED(FINIT_RC_LOCAL, "$rclocal_path", [Compat SysV /etc/rc.local file to run last at boot.])]) 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$with_heading" != "xno"], [
AS_IF([test "x$heading" = "xyes"], [heading=""]) AS_IF([test "x$heading" = "xyes"], [
AC_DEFINE_UNQUOTED(INIT_OSHEADING, "$heading", [Displayed by Finit at boot, defaults to /etc/os-release PRETTY_NAME])]) heading="$PACKAGE_NAME v$PACKAGE_VERSION"])])
AC_DEFINE_UNQUOTED(INIT_HEADING, "$heading", [Displayed by Finit at boot])
AS_IF([test "x$with_group" != "xno"], [ AS_IF([test "x$with_console" != "xno"], [
AS_IF([test "x$group" = "xyes"], [ AS_IF([test "x$console" = "xyes"], [
group=root])]) console=/dev/console])])
AC_DEFINE_UNQUOTED(DEFGROUP, "$group", [For /run/finit/socket]) AC_DEFINE_UNQUOTED(CONSOLE, "$console", [Default console to use])
AS_IF([test "x$with_hostname" != "xno"], [ AS_IF([test "x$with_hostname" != "xno"], [
AS_IF([test "x$hostname" = "xyes"], [ AS_IF([test "x$hostname" = "xyes"], [
@@ -271,8 +211,7 @@ AC_DEFINE_UNQUOTED(DEFHOST, "$hostname", [For /etc/hostname])
AS_IF([test "x$with_runlevel" != "xno"], [ AS_IF([test "x$with_runlevel" != "xno"], [
AS_IF([test "x$runlevel" = "xyes"], [ AS_IF([test "x$runlevel" = "xyes"], [
runlevel=2 AC_DEFINE_UNQUOTED(RUNLEVEL, 2, [Default runlevel to start after S])])
AC_DEFINE_UNQUOTED(RUNLEVEL, $runlevel, [Default runlevel to start after S])])
AC_DEFINE_UNQUOTED(RUNLEVEL, $runlevel, [Runlevel to start after S])]) AC_DEFINE_UNQUOTED(RUNLEVEL, $runlevel, [Runlevel to start after S])])
AS_IF([test "x$with_random_seed" != "xno"], [ AS_IF([test "x$with_random_seed" != "xno"], [
@@ -281,96 +220,25 @@ AS_IF([test "x$with_random_seed" != "xno"], [
AC_EXPAND_DIR(random_path, "$random_seed") AC_EXPAND_DIR(random_path, "$random_seed")
AC_DEFINE_UNQUOTED(RANDOMSEED, "$random_path", [Improve random at boot by seeding it with sth from before.])]) AC_DEFINE_UNQUOTED(RANDOMSEED, "$random_path", [Improve random at boot by seeding it with sth from before.])])
AS_IF([test "x$rtc_date" != "xno"], [
AC_DEFINE_UNQUOTED(RTC_TIMESTAMP_CUSTOM, "$rtc_date", [Custom RTC restore date, default: 2000-01-01 00:00])], [
rtc_date=""])
AS_IF([test "x$rtc_file" != "xno"], [
AS_IF([test "x$rtc_file" = "xyes"], [
rtc_file=/var/lib/misc/rtc])
AC_EXPAND_DIR(rtcfile_path, "$rtc_file")
AC_DEFINE_UNQUOTED(RTC_FILE, "$rtcfile_path", [Save and restore system time from this file if /dev/rtc is missing.])],[
AC_DEFINE_UNQUOTED(RTC_FILE, NULL)])
AS_IF([test "x$with_keventd" != "xno"], [with_keventd=yes])
AS_IF([test "x$with_sulogin" != "xno"], [
AS_IF([test "x$sulogin" = "xyes"], [
sulogin=root])
with_sulogin=yes
AC_DEFINE_UNQUOTED(SULOGIN_USER, "$sulogin", [Built-in sulogin user, default: root])], [
sulogin=])
AS_IF([test "x$with_watchdog" != "xno"], [
AS_IF([test "x$watchdog" = "xyes"], [
watchdog=/dev/watchdog])
with_watchdog=yes
AC_DEFINE_UNQUOTED(WDT_DEVNODE, "$watchdog", [Built-in watchdog device node])], [
watchdog=])
AS_IF([test "x$enable_hook_scripts_plugin" != "xno"], [
AS_IF([test "x$hook_scripts_path" = "xyes"], [hook_scripts_path=$libexecdir/finit/hook])
AC_EXPAND_DIR(hook_scripts_path, "$hook_scripts_path")
AC_DEFINE_UNQUOTED(PLUGIN_HOOK_SCRIPTS_PATH, "$hook_scripts_path", [Built-in default: $libexecdir/finit])])
AS_IF([test "x$with_plugin_path" != "xno"], [
AS_IF([test "x$plugin_path" = "xyes"], [plugin_path=/usr/lib/finit/plugins:/usr/local/lib/finit/plugins])
AC_EXPAND_DIR(plugin_path, "$plugin_path")
AC_DEFINE_UNQUOTED(EXTERNAL_PLUGIN_PATH, "$plugin_path", [Built-in default: /usr/lib/finit/plugins:/usr/local/lib/finit/plugins])])
# Control build with automake flags # Control build with automake flags
AM_CONDITIONAL(BASH, [test "x$bash_dir" != "xno"]) AM_CONDITIONAL(STATIC, [test "x$enable_static" = "xyes"])
AM_CONDITIONAL(STATIC, [test "x$enable_static" = "xyes"]) AM_CONDITIONAL(INETD, [test "x$enable_inetd" = "xyes"])
AM_CONDITIONAL(KEVENTD, [test "x$with_keventd" != "xno"]) AM_CONDITIONAL(WATCHDOGD, [test "x$enable_watchdog" = "xyes"])
AM_CONDITIONAL(SULOGIN, [test "x$with_sulogin" != "xno"]) AM_CONDITIONAL(DOCS, [test "x$enable_docs" = "xyes"])
AM_CONDITIONAL(WATCHDOGD, [test "x$with_watchdog" != "xno"])
AM_CONDITIONAL(DOC, [test "x$enable_doc" = "xyes"])
AM_CONDITIONAL(CONTRIB, [test "x$enable_contrib" = "xyes"]) AM_CONDITIONAL(CONTRIB, [test "x$enable_contrib" = "xyes"])
AM_CONDITIONAL(TESTSERV, [test "x$enable_testserv_plugin" = "xyes"])
# Workaround for as-of-yet unreleased runstatedir support, planned for
# autoconf 2.70, which some major distros have backported.
AS_IF([test -z "$runstatedir"], runstatedir="$localstatedir/run")
AC_SUBST(runstatedir)
# Override default libdir, used for plugins and rescue.conf # Override default libdir, used for plugins and rescue.conf
pkglibdir=$libdir/finit pkglibdir=$libdir/finit
AC_SUBST(pkglibexecdir) AC_SUBST(pkglibexecdir)
AC_EXPAND_DIR(pkglibexecdir, "$libexecdir/finit") AC_EXPAND_DIR(pkglibexecdir, "$libexecdir/finit")
AC_DEFINE_UNQUOTED(FINIT_EXECPATH_, "$pkglibexecdir", [Finit libexec path]) AC_DEFINE_UNQUOTED(FINIT_LIBPATH_, "$pkglibexecdir", [Finit libexec path])
AC_EXPAND_DIR(finit_runpath, "$runstatedir/finit/system")
AC_DEFINE_UNQUOTED(FINIT_RUNPATH_, "$finit_runpath", [Finit runtime dynamic system services])
AC_EXPAND_DIR(plugin_path, "$pkglibdir/plugins") AC_EXPAND_DIR(plugin_path, "$libdir/finit/plugins")
AC_SUBST(plugin_path) AC_SUBST(plugin_path)
AC_DEFINE_UNQUOTED(PLUGIN_PATH, "$plugin_path", [Finit plugin path]) AC_DEFINE_UNQUOTED(PLUGIN_PATH, "$plugin_path", [Finit plugin path])
AC_EXPAND_DIR(tmpfiles_path, "$libdir/tmpfiles.d") AC_EXPAND_DIR(rescue_conf, "$libdir/finit/rescue.conf")
AC_SUBST(tmpfiles_path)
AC_DEFINE_UNQUOTED(TMPFILES_PATH_, "$tmpfiles_path", [Main tmpfiles.d/, override in /etc])
AC_EXPAND_DIR(finit_tmpfiles, "$pkglibdir/tmpfiles.d")
AC_SUBST(finit_tmpfiles)
AC_DEFINE_UNQUOTED(FINIT_TMPFILES, "$finit_tmpfiles", [Finit tmpfiles.d/ .conf path])
AC_EXPAND_DIR(system_path, "$pkglibdir/system")
AC_SUBST(system_path)
AC_DEFINE_UNQUOTED(FINIT_SYSPATH_, "$system_path", [Static services, previously generated at runtime by plugins])
AC_EXPAND_DIR(rescue_conf, "$pkglibdir/rescue.conf")
AC_DEFINE_UNQUOTED(RESCUE_CONF, "$rescue_conf", [Finit rescue mode .conf]) AC_DEFINE_UNQUOTED(RESCUE_CONF, "$rescue_conf", [Finit rescue mode .conf])
AC_EXPAND_DIR(sample_conf, "$pkglibdir/sample.conf")
AC_DEFINE_UNQUOTED(SAMPLE_CONF, "$sample_conf", [Finit sameple.conf for initctl create])
AC_EXPAND_DIR(bash_completion_dir, "$BASH_DIR")
AC_SUBST(BASH_DIR, "$bash_completion_dir")
AS_IF([test "$heading" = ""], [heading="<DEFAULT>"])
AS_IF([test "$heading" = "no"], [heading="<NONE>"])
RTC_DATE=$rtc_date
AS_IF([test "$rtc_date" = ""], [RTC_DATE="<DEFAULT>"])
AS_IF([test "$rtc_date" = "no"], [RTC_DATE="<DEFAULT>"])
# Generate all files # Generate all files
AC_OUTPUT AC_OUTPUT
@@ -379,17 +247,14 @@ cat <<EOF
------------------ Summary ------------------ ------------------ Summary ------------------
$PACKAGE_NAME version $PACKAGE_VERSION $PACKAGE_NAME version $PACKAGE_VERSION
Prefix................: $(eval echo $prefix) Prefix................: $prefix
Exec prefix...........: $(eval echo $exec_prefix)
Libdir................: $(eval echo $libdir)
Sysconfdir............: `eval echo $sysconfdir` Sysconfdir............: `eval echo $sysconfdir`
Localstatedir.........: `eval echo $localstatedir` Localstatedir.........: `eval echo $localstatedir`
Default fstab.........: `eval echo $fstab` FIFO path.............: $fifo_path
Finit config file.....: $conf_path Finit config file.....: $conf_path
Finit config.d path...: $rcsd_path Finit config.d path...: $rcsd_path
Finit plugin path.....: $plugin_path Finit plugin path.....: $plugin_path
Compat rc.local path..: `eval echo $rclocal` Compat rc.local path..: $rclocal_path
System environment....: ${sysconfig_path:-${sysconfig}}
Random seed path......: $random_path Random seed path......: $random_path
C Compiler............: $CC $CFLAGS $CPPFLAGS $LDFLAGS $LIBS C Compiler............: $CC $CFLAGS $CPPFLAGS $LDFLAGS $LIBS
Linker................: $LD $LLDP_LDFLAGS $LLDP_BIN_LDFLAGS $LDFLAGS $LIBS Linker................: $LD $LLDP_LDFLAGS $LLDP_BIN_LDFLAGS $LDFLAGS $LIBS
@@ -397,26 +262,19 @@ cat <<EOF
Behavior: Behavior:
Boot heading..........: $heading Boot heading..........: $heading
Plugins...............: $plugins Plugins...............: $plugins
RTC restore date......: $RTC_DATE
RTC fallback file.....: $rtc_file
Optional features: Optional features:
Install doc/..........: $enable_doc Install docs/.........: $enable_docs
Install contrib/......: $enable_contrib Install contrib/......: $enable_contrib
Bash completion.......: $bash_completion_dir Built-in inetd........: $enable_inetd
Built-in keventd......: $with_keventd Built-in watchdogd....: $enable_watchdog
Built-in sulogin......: $with_sulogin $sulogin
Built-in watchdogd....: $with_watchdog $watchdog
Built-in logrotate....: $enable_logrotate Built-in logrotate....: $enable_logrotate
Use cgroup v2.........: $enable_cgroup Emergency shell.......: $enable_emergency_shell
Parse kernel cmdline..: $enable_kernel_cmdline Fallback shell........: $enable_fallback_shell
Keep kernel logging...: $enable_kernel_logging Remount / RW at boot..: $enable_rw_rootfs
Skip fsck check.......: $enable_fastboot Traditional progress..: $enable_progress
Run fsck fix mode.....: $enable_fsckfix Default console dev...: $console
Redirect output.......: $enable_redirect
Rescue mode...........: $enable_rescue
Default hostname......: $hostname Default hostname......: $hostname
Default group.........: $group
Default runlevel......: $runlevel Default runlevel......: $runlevel
------------- Compiler version -------------- ------------- Compiler version --------------
+1 -1
View File
@@ -1,5 +1,5 @@
SUBDIRS = finit.d SUBDIRS = finit.d
docsdir := @docdir@/contrib/alpine docsdir := @docdir@/contrib/alpine
docs_DATA = README.md finit.conf build.sh install.sh rc.local docs_DATA = README.md finit.conf alpine-release build.sh install.sh rc.local
EXTRA_DIST = $(docs_DATA) EXTRA_DIST = $(docs_DATA)
+2 -5
View File
@@ -1,8 +1,5 @@
HowTo: Finit on Alpine Linux 3.4...3.19 HowTo: Finit on Alpine Linux 3.4-3.6
======================================= ====================================
> [!TIP]
> https://troglobit.com/post/2021-02-12-alpine-linux-with-finit/
HowTo use Finit to boot an [Alpine Linux][] system. It is assumed that HowTo use Finit to boot an [Alpine Linux][] system. It is assumed that
the user has already installed make, a compiler, C library header files, the user has already installed make, a compiler, C library header files,
+1
View File
@@ -0,0 +1 @@
3.6.2
+7 -5
View File
@@ -14,11 +14,12 @@ fi
# The plugins are optional, but you may need D-Bus and X11 if you want # 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. # to run X-Window, the other configure flags are however required.
PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig ./configure \ PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig ./configure \
--prefix=/usr --exec-prefix= \ --enable-rw-rootfs --enable-progress \
--sysconfdir=/etc --localstatedir=/var \ --enable-dbus-plugin --enable-x11-common-plugin \
--enable-dbus-plugin --enable-x11-common-plugin \ --enable-alsa-utils-plugin --enable-inetd-echo-plugin \
--enable-alsa-utils-plugin --without-watchdog \ --enable-inetd-chargen-plugin --enable-inetd-daytime-plugin \
--with-keventd --with-sulogin --enable-inetd-discard-plugin --enable-inetd-time-plugin \
--with-heading="Alpine Linux 3.6" --with-hostname=alpine
echo echo
echo "*** Building ..." echo "*** Building ..."
@@ -35,3 +36,4 @@ fi
echo echo
echo "*** Done" echo "*** Done"
echo echo
+1 -17
View File
@@ -5,22 +5,6 @@
# Default is 2 # Default is 2
#runlevel 2 #runlevel 2
# Top-level cgroups and their default settings. All groups mandatory
# but more can be added, max 8 groups in total currently. The cgroup
# 'root' is also available, reserved for RT processes. Settings are
# as-is, only one shorthand 'mem.' exists, other than that it's the
# cgroup v2 controller default names.
#cgroup init cpu.weight:100
#cgroup user cpu.weight:100
#cgroup system cpu.weight:9700
# Task to run if ctrl-alt-del is pressed. This condition is asserted by
# Finit upon receiving SIGINT (from the kernel).
#task <sys/key/ctrlaltdel> [12345789] initctl reboot -- Rebooting system
# Task to run if the kernel gets a power fail condition is pressed.
# Asserted by Finit upon receiving SIGPWR (from the kernel).
#task <sys/pwr/fail> [12345789] initctl poweroff -- Shutting down system
## Bootstrap services and tasks ## Bootstrap services and tasks
# Can be listed here or in /etc/finit.d/*.conf # Can be listed here or in /etc/finit.d/*.conf
+13 -8
View File
@@ -1,22 +1,27 @@
SUBDIRS = available SUBDIRS = available
docsdir := @docdir@/contrib/alpine/finit.d docsdir := @docdir@/contrib/alpine/finit.d
d_LINKS = acpid.conf crond.conf dropbear.conf getty.conf \ d_LINKS = dropbear.conf getty.conf keymap.conf modules.conf klogd.conf \
keymap.conf modules.conf ntpd.conf syslogd.conf syslogd.conf
install-exec-hook: install-exec-hook:
@$(MKDIR_P) $(DESTDIR)$(docsdir)/available @$(MKDIR_P) $(DESTDIR)$(docsdir)/available
@$(MKDIR_P) $(DESTDIR)$(docsdir)/enabled
@for file in $(d_LINKS); do \ @for file in $(d_LINKS); do \
lnk=$(DESTDIR)$(docsdir)/enabled/$$file; \ lnk=$(DESTDIR)$(docsdir)/$$file; \
src=available/$$file; \ src=available/$$file; \
rm -f $$lnk; \ if [ -L $$lnk ]; then \
$(LN_S) ../$$src $$lnk; \ echo "Skipping $$lnk exists."; \
else \
$(LN_S) $$src $$lnk; \
fi; \
done done
uninstall-hook: uninstall-hook:
@for file in $(d_LINKS); do \ @for file in $(d_LINKS); do \
lnk=$(DESTDIR)$(docsdir)/enabled/$$file; \ lnk=$(DESTDIR)$(docsdir)/$$file; \
src=available/$$file; \ src=available/$$file; \
$(RM) -f $$lnk; \ if [ "`readlink $$lnk`" != "$$src" ]; then \
continue; \
fi; \
$(RM) $$lnk; \
done done
+2 -2
View File
@@ -1,4 +1,4 @@
docsdir := @docdir@/contrib/alpine/finit.d/available docsdir := @docdir@/contrib/alpine/finit.d/available
docs_DATA = acpid.conf crond.conf dropbear.conf getty.conf keymap.conf \ docs_DATA = acpid.conf crond.conf dropbear.conf getty.conf keymap.conf \
lxdm.conf modules.conf ntpd.conf syslogd.conf watchdog.conf lxdm.conf modules.conf ntpd.conf klogd.conf syslogd.conf
EXTRA_DIST = $(docs_DATA) EXTRA_DIST = $(docs_DATA)
+1 -1
View File
@@ -1,3 +1,3 @@
# Handle PWR button to shutdown/reboot -- useful in Qemu (virt-manager) # Handle PWR button to shutdown/reboot -- useful in Qemu (virt-manager)
# Depends on syslogd having started. Redirect any output to log. # 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
View File
@@ -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 # 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
+3 -4
View File
@@ -1,5 +1,4 @@
# Consoles to start getty on when system is up # Consoles to start getty on when system is up
tty [12345] /dev/ttyS0 noclear tty /dev/tty1 noclear nowait
tty [12345] /dev/tty1 noclear nowait tty /dev/tty2 noclear nowait
tty [2345] /dev/tty2 noclear nowait tty /dev/tty3 noclear nowait
tty [2345] /dev/tty3 noclear nowait
+1 -1
View File
@@ -1,2 +1,2 @@
# Oneshot task to run once at bootstrap # 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
@@ -0,0 +1,2 @@
# Start klogd as soon as possible, should always run
service [S12345] /sbin/klogd -n -- Kernel log daemon
+1 -1
View File
@@ -1 +1 @@
service [2345] lxdm -- Lightweight Login Manager service [2345] /usr/sbin/lxdm -- Lightweight Login Manager
@@ -1,7 +1,6 @@
## Linux kernel modules to load ## Linux kernel modules to load
#module fbcon #module fbcon
#module button module button
#module evdev module evdev
#module mousedev module mousedev
#module 8139cp module 8139cp
#module softdog
+2 -2
View File
@@ -1,2 +1,2 @@
# Busybox ntpd has no option to use syslog when running in foreground # Silly 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 service [2345] log <svc/sbin/syslogd> /usr/sbin/ntpd -n -N -p pool.ntp.org -- NTP daemon
@@ -1,4 +1,2 @@
# Start syslogd as soon as possible, should always run # Start syslogd as soon as possible, should always run
# Start klogd as soon as possible, but after syslogd service [S12345] /sbin/syslogd -n -- Syslog daemon
service [S12345] env:-/etc/conf.d/syslog syslogd -n $SYSLOGD_OPTS -- Syslog daemon
service [S12345] <pid/syslogd> env:-/etc/conf.d/klogd klogd -n $KLOGD_OPTS -- Kernel log daemon
@@ -1 +0,0 @@
service [S123456789] env:-/etc/conf.d/watchdog watchdog $WATCHDOG_OPTS $WATCHDOG_DEV -- System watchdog
+1
View File
@@ -0,0 +1 @@
available/dropbear.conf
+1
View File
@@ -0,0 +1 @@
available/getty.conf
+1
View File
@@ -0,0 +1 @@
available/keymap.conf
+1
View File
@@ -0,0 +1 @@
available/klogd.conf
+1
View File
@@ -0,0 +1 @@
available/modules.conf
+1
View File
@@ -0,0 +1 @@
available/syslogd.conf
+28 -40
View File
@@ -1,63 +1,51 @@
#!/bin/sh #!/bin/sh
if [ "$(id -u)" != "0" ]; then if [ "x`id -u`" != "x0" ]; then
printf "\n\e[1m*** This script must run as root\e[0m\n\n" echo
echo "*** This script must run as root"
echo
exit 1 exit 1
fi fi
# shellcheck disable=SC3037,SC3045,SC2154
yorn()
{
printf "\e[1m> %s (y/N)?\e[0m " "$*"
read -rn1 yorn
echo
if [ "$yorn" = "y" ] || [ "$yorn" = "Y" ]; then
return 0
fi
return 1
}
# Adjust base directory # Adjust base directory
if grep -q contrib/alpine Makefile 2>/dev/null; then if [ -e alpine-release ]; then
cd ../.. cd ../..
fi elif [ ! -e autogen.sh ]; then
echo "*** Please run this script from the Finit base directory."
if [ ! -e configure.ac ]; then
printf "\n\e[1m*** Please run this script from the Finit base directory.\e[0m\n"
exit 1 exit 1
fi fi
printf "\n\e[1mInstall Finit on Alpine Linux\n" echo
printf "========================================================================\e[0m\n" echo "*** Install Finit on Alpine Linux"
printf "/sbin/finit - PID 1\n" echo "========================================================================"
printf "/lib/finit/plugins/* - All enabled Finit plugins\n" echo "/sbin/finit - PID 1"
printf "/etc/finit.conf - Finit configuration file\n" echo "/lib/finit/plugins/* - All enabled Finit plugins"
printf "/etc/finit.d/ - Finit services\n" echo "/etc/finit.conf - Finit configuration file"
echo "/etc/finit.d/ - Finit services"
echo
read -p "Do you want to continue (y/N)? " yorn
if yorn "Do you want to continue"; then if [ "x$yorn" = "xy" -o "x$yorn" = "xY" ]; then
printf "\n\e[1m*** Installing Finit files ...\e[0m\n" echo
echo "*** Installing Finit files ..."
make install make install
cd /usr/share/doc/finit/contrib/alpine || exit 1 cd `dirname $0`
for file in finit.conf rc.local; do for file in finit.conf rc.local; do
install -vbD $file /etc/$file install -vbD $file /etc/$file
done done
cp -va finit.d /etc/ cp -va finit.d /etc/
if yorn "Install Finit as the system default Init"; then read -p "*** Install Finit as the system default Init (y/N)? " yorn
printf "\e[1m*** Updating /sbin/init symlink --> finit ...\e[0m\n" if [ "x$yorn" = "xy" -o "x$yorn" = "xY" ]; then
cd /sbin || exit 1 echo "*** Updating /sbin/init symlink --> finit ..."
cd /sbin
rm init rm init
ln -s finit init ln -s finit init
rm halt shutdown suspend
ln -s reboot halt
ln -s reboot shutdown
ln -s reboot suspend
fi fi
printf "\n\e[1m*** Done\e[0m\n" echo "*** Done"
echo echo
else else
printf "\n\e[1m*** Aborting install.\e[0m\n\n" echo
echo "*** Aborting install."
echo
fi fi
+1 -1
View File
@@ -4,5 +4,5 @@
# #
# Each line is run in sequence. # Each line is run in sequence.
# #
# NOTE: Remember to set the executable bit! # NOTE: Remeber to set the executable bit!
# #
-39
View File
@@ -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
+2 -2
View File
@@ -1,4 +1,4 @@
SUBDIRS = finit.d SUBDIRS = finit.d grub.d
docsdir := @docdir@/contrib/debian docsdir := @docdir@/contrib/debian
docs_DATA = README.md finit.conf build.sh install.sh docs_DATA = README.md finit.conf os-release build.sh install.sh
EXTRA_DIST = $(docs_DATA) EXTRA_DIST = $(docs_DATA)
+7 -22
View File
@@ -20,44 +20,29 @@ tools pre-systemd work as intended.
root@debian:~# apt install initscripts console-setup root@debian:~# apt install initscripts console-setup
> [!TIP]
> As of Debian 11 (Bullseye), libuev and libite are part of the main
> section of Debian. So just install the -dev packages :)
The following script can then be used to configure, build, install and The following script can then be used to configure, build, install and
set up your system to run Finit: set up your system to run Finit:
user@debian:~/finit$ contrib/debian/build.sh user@debian:~/finit$ contrib/debian/build.sh
However, since `/sbin/init` already exists on your system, the script However, since `/sbin/init` already exists on your system, the script
creates another entry in your GRUB config by updating `$SUPPORTED_INITS` creates another entry in your GRUB config, in `/etc/grub.d/40_custom`,
in `/etc/grub.d/10_inux` and run `update-grub`. On reboot you will find where `init=/sbin/finit` is added to your kernel line. It is of course
a (finit) entry in the "Advanced options for Debian GNU/Linux" section. also possible to change the default init to Finit, if you do you can
It is of course also possible to change the default init to Finit: remove the custom Grub entry:
user@debian:~/finit# cd /sbin user@debian:~/finit# cd /sbin
user@debian:/sbin# sudo mv init oldinit user@debian:/sbin# sudo rm init
user@debian:/sbin# sudo ln -s finit init user@debian:/sbin# sudo ln -s finit init
Before rebooting, check the default [/etc/finit.conf](finit.conf) and Before rebooting, check the default [/etc/finit.conf](finit.conf) and
`/etc/finit.d/*.conf` files. The build + install script above provides `/etc/finit.d/*.conf` files. The build + install script above provides
a few sample `.conf` files. See `initctl ls` after boot for a list of a few sample `.conf` files. See `initctl list` after boot for a list of
enabled and available services, you can then use `enable` and `disable` enabled and available services.
comands to `initctl`, followed by `reload` to activate your changes.
You can also use a standard [/etc/rc.local](rc.local) for one-shot tasks You can also use a standard [/etc/rc.local](rc.local) for one-shot tasks
and initialization like keyboard language etc. and initialization like keyboard language etc.
> [!NOTE]
> For the X Window system, you may need to `sudo apt install elogind`
> (Bullseye and later), followed by `initctl reload` to activate it (it
> is enabled by default), and logout/login again. The elogind daemon
> ensures a regular non-root user can start and interact with an X
> session, otherwise keyboard and mouse won't work. When you're happy,
> you can enable the lightdm.conf, change the default runlevel to 3, and
> presto! you have a desktop again.
Have fun! Have fun!
/Joachim ツ /Joachim ツ
+11 -6
View File
@@ -21,12 +21,14 @@ echo
# The plugins are optional, but you may need D-Bus and X11 if you want # 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. # to run X-Window, the other configure flags are however required.
./configure \ ./configure \
--prefix=/usr --exec-prefix= \ --enable-rw-rootfs --enable-progress \
--sysconfdir=/etc --localstatedir=/var \ --enable-dbus-plugin --enable-x11-common-plugin \
--enable-dbus-plugin --enable-x11-common-plugin \ --enable-alsa-utils-plugin --enable-inetd-echo-plugin \
--enable-alsa-utils-plugin --with-keventd \ --enable-inetd-chargen-plugin --enable-inetd-daytime-plugin \
--with-random-seed=/var/lib/urandom/random-seed --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 if [ $? -ne 0 ]; then
echo echo
@@ -59,3 +61,6 @@ else
echo "*** Use 'sudo contrib/debian/install.sh' later to install Finit" echo "*** Use 'sudo contrib/debian/install.sh' later to install Finit"
echo echo
fi fi
+1 -17
View File
@@ -5,22 +5,6 @@
# Default is 2 # Default is 2
#runlevel 2 #runlevel 2
# Top-level cgroups and their default settings. All groups mandatory
# but more can be added, max 8 groups in total currently. The cgroup
# 'root' is also available, reserved for RT processes. Settings are
# as-is, only one shorthand 'mem.' exists, other than that it's the
# cgroup v2 controller default names.
#cgroup init cpu.weight:100
#cgroup user cpu.weight:100
#cgroup system cpu.weight:9700
# Task to run if ctrl-alt-del is pressed. This condition is asserted by
# Finit upon receiving SIGINT (from the kernel).
#task <sys/key/ctrlaltdel> [12345789] initctl reboot -- Rebooting system
# Task to run if the kernel gets a power fail condition is pressed.
# Asserted by Finit upon receiving SIGPWR (from the kernel).
#task <sys/pwr/fail> [12345789] initctl poweroff -- Shutting down system
## Bootstrap services and tasks ## Bootstrap services and tasks
# Can be listed here or in /etc/finit.d/*.conf # Can be listed here or in /etc/finit.d/*.conf
+13 -10
View File
@@ -1,24 +1,27 @@
SUBDIRS = available SUBDIRS = available
docsdir := @docdir@/contrib/debian/finit.d docsdir := @docdir@/contrib/debian/finit.d
d_LINKS = acpid.conf apparmor.conf avahi-daemon.conf \ d_LINKS = console-setup.conf getty.conf keyboard-setup.conf \
bluetooth.conf console-setup.conf elogind.conf \ modules.conf rsyslogd.conf sshd.conf
getty.conf keyboard-setup.conf modules.conf \
plymouth-quit.conf rsyslogd.conf sshd.conf
install-exec-hook: install-exec-hook:
@$(MKDIR_P) $(DESTDIR)$(docsdir)/available @$(MKDIR_P) $(DESTDIR)$(docsdir)/available
@$(MKDIR_P) $(DESTDIR)$(docsdir)/enabled
@for file in $(d_LINKS); do \ @for file in $(d_LINKS); do \
lnk=$(DESTDIR)$(docsdir)/enabled/$$file; \ lnk=$(DESTDIR)$(docsdir)/$$file; \
src=available/$$file; \ src=available/$$file; \
rm -f $$lnk; \ if [ -L $$lnk ]; then \
$(LN_S) ../$$src $$lnk; \ echo "Skipping $$lnk exists."; \
else \
$(LN_S) $$src $$lnk; \
fi; \
done done
uninstall-hook: uninstall-hook:
@for file in $(d_LINKS); do \ @for file in $(d_LINKS); do \
lnk=$(DESTDIR)$(docsdir)/enabled/$$file; \ lnk=$(DESTDIR)$(docsdir)/$$file; \
src=available/$$file; \ src=available/$$file; \
$(RM) -f $$lnk; \ if [ "`readlink $$lnk`" != "$$src" ]; then \
continue; \
fi; \
$(RM) $$lnk; \
done done
+3 -6
View File
@@ -1,8 +1,5 @@
docsdir := @docdir@/contrib/debian/finit.d/available docsdir := @docdir@/contrib/debian/finit.d/available
docs_DATA = acpid.conf apparmor.conf avahi-daemon.conf bluetooth.conf \ docs_DATA = acpid.conf console-setup.conf getty.conf \
console-setup.conf elogind.conf getty.conf \ keyboard-setup.conf lightdm.conf modules.conf \
keyboard-setup.conf lightdm.conf modules.conf sntpd.conf \ ntpclient.conf rsyslogd.conf sshd.conf xdm.conf
plymouth-quit.conf rsyslogd.conf sshd.conf syslogd.conf \
xdm.conf
EXTRA_DIST = $(docs_DATA) EXTRA_DIST = $(docs_DATA)
+2 -2
View File
@@ -1,3 +1,3 @@
# Handle PWR button to shutdown/reboot -- useful in Qemu (virt-manager) # Handle PWR button to shutdown/reboot -- useful in Qemu (virt-manager)
# Depends on a syslog daemon having started. Redirect any output to log. # Depends on rsyslogd having started. Redirect any output to log.
service [2345] <pid/syslogd> env:-/etc/default/acpid log acpid -f $OPTIONS -- ACPI daemon service [2345] <svc/usr/sbin/rsyslogd> log /usr/sbin/acpid -f -- ACPI daemon
@@ -1 +0,0 @@
task [2345] <sys/pwr/ac,pid/syslogd> halt:usr1 env:-/etc/default/anacron anacron -d -q $ANACRON_ARGS -- Anacron jobs
@@ -1,2 +0,0 @@
sysv [S] /etc/init.d/apparmor -- AppArmor initialization
@@ -1 +0,0 @@
service [2345] env:-/etc/default/avahi-daemon avahi-daemon -s $AVAHI_DAEMON_OPTS -- Avahi mDNS/DNS-SD Stack
@@ -1,3 +0,0 @@
# To ignore errors like "org.freedesktop.hostname1", update the env file with
# "--noplugin=hostname", i.e. append to BLUETOOTHD_OPTS
service [2345] log:null env:-/etc/default/bluetooth /usr/libexec/bluetooth/bluetoothd -n $BLUETOOTHD_OPTS -- Bluetooth service
@@ -1 +0,0 @@
service [2345] <sys/pwr/ac,pid/syslogd> env:-/etc/default/cron cron -f $EXTRA_OPTS -- Background job processing daemon
@@ -1,4 +0,0 @@
# On some systems, bootstrap can be really quick and cause elogind
# to not start before a user has managed to log in. To prevent
# this, add <pid/elogind> as condition to your TTYs in getty.conf
service [2345] <pid/syslogd> /lib/elogind/elogind -- Login manager
+3 -6
View File
@@ -1,7 +1,4 @@
# Consoles to start getty on when system is up # Consoles to start getty on when system is up
tty [12345] /dev/tty1 linux noclear nowait tty [12345] /dev/tty1 115200 vt100 noclear nowait
tty [2345] /dev/tty2 linux nowait tty [2345] /dev/tty2 38400 linux noclear nowait
tty [2345] /dev/tty3 linux nowait tty [2345] /dev/tty3 38400 linux noclear nowait
tty [2345] /dev/tty4 linux nowait
tty [2345] /dev/tty5 linux nowait
tty [2345] /dev/tty6 linux 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 ## Linux kernel modules to load
#module fbcon #module fbcon
#module button module button
#module evdev module evdev
#module loop module loop
#module psmouse module psmouse
#module mousedev module mousedev
#module 8139cp 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,2 +0,0 @@
# Need to stop plymouth, or it'll block stdin on tty1
task [S] /usr/bin/plymouth quit -- Stopping Plymouth Boot Screen
@@ -1,3 +1,2 @@
# Start rsyslogd as soon as possible, should always run # Start rsyslogd as soon as possible, should always run
# Provides pid/syslogd condition service [S12345] /usr/sbin/rsyslogd -n -- Reliable and extended syslog daemon
service [S12345] name:syslogd env:-/etc/default/rsyslog rsyslogd -n $RSYSLOGD_OPTIONS -- Reliable 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 -1
View File
@@ -1,2 +1,2 @@
# Start SSH daemon as soon as basic networking comes up # 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
+2 -2
View File
@@ -1,4 +1,4 @@
# Here we use XDM since it has few dependencies (relatively speaking). # Here we use XDM since it has few dependencies (relatively speaking).
# It is also an example of a service without a -- description. # It is also an example of a service without a -- description.
# service [3] lxdm -- Lightweight Login Manager # service [3] /usr/sbin/lxdm -- Lightweight Login Manager
service [3] xdm -nodaemon -- X Display Manager service [3] /usr/bin/xdm -nodaemon
+1
View File
@@ -0,0 +1 @@
available/console-setup.conf
+1
View File
@@ -0,0 +1 @@
available/getty.conf
+1
View File
@@ -0,0 +1 @@
available/keyboard-setup.conf
+1
View File
@@ -0,0 +1 @@
available/modules.conf
+1
View File
@@ -0,0 +1 @@
available/rsyslogd.conf
+1
View File
@@ -0,0 +1 @@
available/sshd.conf
+14
View File
@@ -0,0 +1,14 @@
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry '$MENU with Finit' --class $TYPE --class gnu-linux --class gnu --class os --user {
insmod gzio
insmod part_msdos
insmod ext2
search --no-floppy --fs-uuid --set=root $BOOT
linux /vmlinuz root=UUID=$ROOT ro quiet init=/sbin/finit
initrd /initrd.img
}
+3
View File
@@ -0,0 +1,3 @@
docsdir := @docdir@/contrib/debian/grub.d
docs_DATA = 40_custom
EXTRA_DIST = $(docs_DATA)
+11 -19
View File
@@ -8,10 +8,10 @@ if [ "x`id -u`" != "x0" ]; then
fi fi
# Adjust base directory # Adjust base directory
grep -q debian Makefile 2>/dev/null grep -q Debian os-release 2>/dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
cd ../.. cd ../..
elif [ ! -e configure.ac ]; then elif [ ! -e autogen.sh ]; then
echo "*** Please run this script from the Finit base directory." echo "*** Please run this script from the Finit base directory."
exit 1 exit 1
fi fi
@@ -23,7 +23,7 @@ echo "/sbin/finit - PID 1"
echo "/lib/finit/plugins/* - All enabled Finit plugins" echo "/lib/finit/plugins/* - All enabled Finit plugins"
echo "/etc/finit.conf - Finit configuration file" echo "/etc/finit.conf - Finit configuration file"
echo "/etc/finit.d/ - Finit services" echo "/etc/finit.d/ - Finit services"
echo "/etc/grub.d/10_linux - Add Finit to Grub's SUPPORTED_INITS" echo "/etc/grub.d/40_custom - Add menu entry to the Grub boot loader"
echo echo
read -p "Do you want to continue (y/N)? " yorn read -p "Do you want to continue (y/N)? " yorn
echo echo
@@ -31,25 +31,17 @@ echo
if [ "x$yorn" = "xy" -o "x$yorn" = "xY" ]; then if [ "x$yorn" = "xy" -o "x$yorn" = "xY" ]; then
echo "Installing Finit files ..." echo "Installing Finit files ..."
make install make install
cd /usr/share/doc/finit/contrib/debian cd `dirname $0`
for file in finit.conf; do install -vbD finit.conf /etc/finit.conf
install -vbD $file /etc/$file
done
cp -va finit.d /etc/ cp -va finit.d /etc/
echo "*** Setting up a GRUB boot entry ..." echo "*** Setting up a GRUB boot entry ..."
fn=/etc/grub.d/10_linux MENU=`grep gnu-linux /boot/grub/grub.cfg |head -1 |sed "s/menuentry '\([^']*\).*/\1/"`
if [ -e $fn ]; then TYPE=`grep gnu-linux /boot/grub/grub.cfg |head -1 |sed "s/.*' --class \([a-z]*\).*/\1/"`
if `grep SUPPORTED_INITS $fn |head -1 |grep -q finit`; then BOOT=`grep set=root /boot/grub/grub.cfg |head -1 |sed 's/.* \([a-f0-9]*-[a-f0-9]*-[a-f0-9]*-[a-f0-9]*-[a-f0-9]*\).*/\1/'`
echo "Already installed, done." ROOT=`grep root=UUID /boot/grub/grub.cfg |head -1 |sed 's/.*UUID=\([a-f0-9]*-[a-f0-9]*-[a-f0-9]*-[a-f0-9]*-[a-f0-9]*\).*/\1/'`
else cat grub.d/40_custom | sed "s,\$BOOT,$BOOT,;s,\$ROOT,$ROOT,;s,\$TYPE,$TYPE,;s,\$MENU,$MENU," >/etc/grub.d/40_custom
echo "Adding Finit to list of SUPPORTED_INITS ..." update-grub
sed -i 's/SUPPORTED_INITS="[^"]*/& finit:\/sbin\/finit/' $fn
update-grub
fi
else
echo "Cannot find $fn, you'll have to set up your bootloader on your own."
fi
echo echo
echo "*** Done" echo "*** Done"
+8
View File
@@ -0,0 +1,8 @@
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
+17 -42
View File
@@ -2,24 +2,15 @@
# #
host testbed host testbed
# Devices to fsck at boot
check /dev/vda1
# Linux kernel modules to load # Linux kernel modules to load
module button module button
module evdev module evdev
module loop module loop
module psmouse module psmouse
# Top-level cgroups and their default settings. All groups mandatory
# but more can be added, max 8 groups in total currently. The cgroup
# 'root' is also available, reserved for RT processes. Settings are
# as-is, only one shorthand 'mem.' exists, other than that it's the
# cgroup v2 controller default names.
cgroup init cpu.weight:100
cgroup user cpu.weight:100
cgroup system cpu.weight:9700 cpu.max:50000
# Example extra cgroup
cgroup maint cpu.weight:100
# Runlevel to start after bootstrap, runlevel 'S' # Runlevel to start after bootstrap, runlevel 'S'
runlevel 2 runlevel 2
@@ -28,21 +19,13 @@ network service networking start
# Max file size for each log file: 100 kiB, rotate max 4 copies: # Max file size for each log file: 100 kiB, rotate max 4 copies:
# log => log.1 => log.2.gz => log.3.gz => log.4.gz # log => log.1 => log.2.gz => log.3.gz => log.4.gz
log size:100k count:4 log size=100k count=4
# Virtual consoles to start getty on # Virtual consoles to start getty on
tty /dev/tty1 tty /dev/tty1
tty /dev/tty2 tty /dev/tty2
tty /dev/tty3 tty /dev/tty3
# Task to run if ctrl-alt-del is pressed. This condition is asserted by
# Finit upon receiving SIGINT (from the kernel).
task <sys/key/ctrlaltdel> [12345789] initctl reboot -- Rebooting system
# Task to run if the kernel gets a power fail condition is pressed.
# Asserted by Finit upon receiving SIGPWR (from the kernel).
task <sys/pwr/fail> [12345789] initctl poweroff -- Shutting down system
# Alternative method instead of runparts # Alternative method instead of runparts
#task [S] /etc/init.d/keyboard-setup start -- Setting up preliminary keymap #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/acpid start -- Starting ACPI Daemon
@@ -50,36 +33,28 @@ task <sys/pwr/fail> [12345789] initctl poweroff -- Shutting down system
#run [2] /etc/init.d/networking start -- Start networking #run [2] /etc/init.d/networking start -- Start networking
# Services to be monitored and respawned as needed # Services to be monitored and respawned as needed
service [2345] /sbin/klogd -n -- Kernel logging server
# klgod and syslogd are placed in the maint cgroup service [2345] /sbin/syslogd -n -- Syslog server
cgroup.maint service [3] /usr/sbin/gdm -- GNOME Display Manager
service [2345] <pid/syslogd> klogd -n -- Kernel logging server
service [2345] syslogd -n -- Syslog server
# gdm in the system cgroup (default when read from it's own .conf file)
cgroup.system
service [3] cgroup:cpu.weight:250,mem.max:10M gdm -- GNOME Display Manager
# Start SSH daemon with opts from /etc/default/ssh (if available), move
# to user cgroup with cpu.weight:250. Default for services is system
# group. Default weight in user group is 100 (above). Max length of
# cgroup argument is (currently) 63 chars.
#
# Notice alternative syntax where current cgroup is only set for this
# particular service.
service [2345] cgroup.user:cpu.weight:250,mem.max:10M env:-/etc/default/ssh /usr/sbin/sshd -D $SSHD_OPTS -- OpenSSH daemon
# The BusyBox ntpd does not use syslog when running in the foreground # 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 # 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 # log file is rotated with the above settings. The condition declares
# a dependency on a system default route (gateway) to be set. A single # a dependency on a system default route (gateway) to be set. A single
# <!> at the beginning means ntpd does not respect SIGHUP for restart. # <!> 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 # Run start scripts from this directory
# runparts /etc/start.d # 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 # For multiple instances of the same service, add :ID somewhere between
# the service/run/task keyword and the command. # the service/run/task keyword and the command.
service :80 [2345] /sbin/httpd -f -h /http -p 80 -- Web server service :1 [2345] /sbin/httpd -f -h /http -p 80 -- Web server
service :8080 [2345] /sbin/httpd -f -h /http -p 8080 -- Old web server service :2 [2345] /sbin/httpd -f -h /http -p 8080 -- Old web server
-15
View File
@@ -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
@@ -1,75 +0,0 @@
In Finit issue #196 we were reminded [1] of a missing inotify flag in
Linux older kernels, IN_MASK_CREATE. Finit makes use of this internally
for monitoring PID conditions, and more. This is a central mechanism to
synchronize services at boot and reload at runtime.
The following patch for Linux 4.9.0, was provided by Andy Savage for
other people that may want to run Finit on slightly older kernels.
[1]: https://github.com/troglobit/finit/issues/196
Index: fs/notify/inotify/inotify_user.c
===================================================================
--- fs.orig/notify/inotify/inotify_user.c
+++ fs/notify/inotify/inotify_user.c
@@ -522,6 +522,7 @@ static int inotify_update_existing_watch
__u32 old_mask, new_mask;
__u32 mask;
int add = (arg & IN_MASK_ADD);
+ int create = (arg & IN_MASK_CREATE);
int ret;
mask = inotify_arg_to_mask(arg);
@@ -529,6 +530,8 @@ static int inotify_update_existing_watch
fsn_mark = fsnotify_find_inode_mark(group, inode);
if (!fsn_mark)
return -ENOENT;
+ else if (create)
+ return -EEXIST;
i_mark = container_of(fsn_mark, struct inotify_inode_mark, fsn_mark);
@@ -726,6 +729,10 @@ SYSCALL_DEFINE3(inotify_add_watch, int,
if (unlikely(!f.file))
return -EBADF;
+ /* IN_MASK_ADD and IN_MASK_CREATE don't make sense together */
+ if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE)))
+ return -EINVAL;
+
/* verify that this is indeed an inotify instance */
if (unlikely(f.file->f_op != &inotify_fops)) {
ret = -EINVAL;
@@ -814,7 +821,7 @@ static int __init inotify_user_setup(voi
BUILD_BUG_ON(IN_ISDIR != FS_ISDIR);
BUILD_BUG_ON(IN_ONESHOT != FS_IN_ONESHOT);
- BUG_ON(hweight32(ALL_INOTIFY_BITS) != 21);
+ BUG_ON(hweight32(ALL_INOTIFY_BITS) != 22);
inotify_inode_mark_cachep = KMEM_CACHE(inotify_inode_mark, SLAB_PANIC);
Index: include/linux/inotify.h
===================================================================
--- include.orig/linux/inotify.h
+++ include/linux/inotify.h
@@ -17,6 +17,6 @@ extern struct ctl_table inotify_table[];
IN_DELETE_SELF | IN_MOVE_SELF | IN_UNMOUNT | \
IN_Q_OVERFLOW | IN_IGNORED | IN_ONLYDIR | \
IN_DONT_FOLLOW | IN_EXCL_UNLINK | IN_MASK_ADD | \
- IN_ISDIR | IN_ONESHOT)
+ IN_MASK_CREATE | IN_ISDIR | IN_ONESHOT)
#endif /* _LINUX_INOTIFY_H */
Index: include/uapi/linux/inotify.h
===================================================================
--- include.orig/uapi/linux/inotify.h
+++ include/uapi/linux/inotify.h
@@ -52,6 +52,7 @@ struct inotify_event {
#define IN_ONLYDIR 0x01000000 /* only watch the path if it is a directory */
#define IN_DONT_FOLLOW 0x02000000 /* don't follow a sym link */
#define IN_EXCL_UNLINK 0x04000000 /* exclude events on unlinked objects */
+#define IN_MASK_CREATE 0x10000000 /* only create watches */
#define IN_MASK_ADD 0x20000000 /* add to the mask of an already existing watch */
#define IN_ISDIR 0x40000000 /* event occurred against dir */
#define IN_ONESHOT 0x80000000 /* only send event once */
+1 -1
View File
@@ -1,4 +1,4 @@
SUBDIRS = finit.d SUBDIRS = finit.d
docsdir := @docdir@/contrib/void docsdir := @docdir@/contrib/void
docs_DATA = README.md finit.conf build.sh install.sh rc.local docs_DATA = README.md finit.conf build.sh install.sh rc.local xbps
EXTRA_DIST = $(docs_DATA) EXTRA_DIST = $(docs_DATA)
+7 -5
View File
@@ -14,11 +14,12 @@ fi
# The plugins are optional, but you may need D-Bus and X11 if you want # 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. # to run X-Window, the other configure flags are however required.
PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig ./configure \ PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig ./configure \
--prefix=/usr --exec-prefix= \ --enable-rw-rootfs --enable-progress \
--sysconfdir=/etc --localstatedir=/var \ --enable-dbus-plugin --enable-x11-common-plugin \
--enable-dbus-plugin --enable-x11-common-plugin \ --enable-alsa-utils-plugin --enable-inetd-echo-plugin \
--enable-alsa-utils-plugin --with-watchdog \ --enable-inetd-chargen-plugin --enable-inetd-daytime-plugin \
--with-keventd --with-sulogin --enable-inetd-discard-plugin --enable-inetd-time-plugin \
--with-heading="Void Linux" --with-hostname=void
echo echo
echo "*** Building ..." echo "*** Building ..."
@@ -35,3 +36,4 @@ fi
echo echo
echo "*** Done" echo "*** Done"
echo echo
-17
View File
@@ -5,22 +5,5 @@
# Default is 2 # Default is 2
#runlevel 2 #runlevel 2
# Top-level cgroups and their default settings. All groups mandatory
# but more can be added, max 8 groups in total currently. The cgroup
# 'root' is also available, reserved for RT processes. Settings are
# as-is, only one shorthand 'mem.' exists, other than that it's the
# cgroup v2 controller default names.
#cgroup init cpu.weight:100
#cgroup user cpu.weight:100
#cgroup system cpu.weight:9700
# Task to run if ctrl-alt-del is pressed. This condition is asserted by
# Finit upon receiving SIGINT (from the kernel).
#task <sys/key/ctrlaltdel> [12345789] initctl reboot -- Rebooting system
# Task to run if the kernel gets a power fail condition is pressed.
# Asserted by Finit upon receiving SIGPWR (from the kernel).
#task <sys/pwr/fail> [12345789] initctl poweroff -- Shutting down system
## Bootstrap services and tasks ## Bootstrap services and tasks
# Can be listed here or in /etc/finit.d/*.conf # Can be listed here or in /etc/finit.d/*.conf
+11 -6
View File
@@ -4,18 +4,23 @@ d_LINKS = acpid.conf dhcpcd.conf getty.conf sshd.conf uuidd.conf
install-exec-hook: install-exec-hook:
@$(MKDIR_P) $(DESTDIR)$(docsdir)/available @$(MKDIR_P) $(DESTDIR)$(docsdir)/available
@$(MKDIR_P) $(DESTDIR)$(docsdir)/enabled
@for file in $(d_LINKS); do \ @for file in $(d_LINKS); do \
lnk=$(DESTDIR)$(docsdir)/enabled/$$file; \ lnk=$(DESTDIR)$(docsdir)/$$file; \
src=available/$$file; \ src=available/$$file; \
rm -f $$lnk; \ if [ -L $$lnk ]; then \
$(LN_S) ../$$src $$lnk; \ echo "Skipping $$lnk exists."; \
else \
$(LN_S) $$src $$lnk; \
fi; \
done done
uninstall-hook: uninstall-hook:
@for file in $(d_LINKS); do \ @for file in $(d_LINKS); do \
lnk=$(DESTDIR)$(docsdir)/enabled/$$file; \ lnk=$(DESTDIR)$(docsdir)/$$file; \
src=available/$$file; \ src=available/$$file; \
$(RM) -f $$lnk; \ if [ "`readlink $$lnk`" != "$$src" ]; then \
continue; \
fi; \
$(RM) $$lnk; \
done done
+1
View File
@@ -0,0 +1 @@
available/acpid.conf
+2 -2
View File
@@ -1,5 +1,5 @@
docsdir := @docdir@/contrib/void/finit.d/available docsdir := @docdir@/contrib/void/finit.d/available
docs_DATA = acpid.conf crond.conf dhcpcd.conf dmeventd.conf getty.conf \ docs_DATA = acpid.conf crond.conf dhcpcd.conf dmeventd.conf getty.conf \
keymap.conf lxdm.conf modules.conf ntpd.conf \ keymap.conf klogd.conf lxdm.conf modules.conf ntpd.conf \
sshd.conf syslog.conf uuidd.conf sshd.conf syslogd.conf uuidd.conf
EXTRA_DIST = $(docs_DATA) EXTRA_DIST = $(docs_DATA)
+1 -1
View File
@@ -1,3 +1,3 @@
# Handle PWR button to shutdown/reboot -- useful in Qemu (virt-manager) # Handle PWR button to shutdown/reboot -- useful in Qemu (virt-manager)
# Depends on syslogd having started. Redirect any output to log. # 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
View File
@@ -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
View File
@@ -1 +1 @@
service [2345] dhcpcd -B -M -- DHCP client service [2345] /usr/sbin/dhcpcd -B -M -- DHCP client
+1 -1
View File
@@ -1 +1 @@
service [S12345] dmeventd -f -- Device mapper event daemon service [S12345] /sbin/dmeventd -f -- Device mapper event daemon
+3 -3
View File
@@ -1,4 +1,4 @@
# Consoles to start Finit built-in getty on when system is up # Consoles to start Finit built-in getty on when system is up
tty [12345] /dev/tty1 noclear nowait tty /dev/tty1 noclear nowait
tty [2345] /dev/tty2 noclear nowait tty /dev/tty2 noclear nowait
tty [2345] /dev/tty3 noclear nowait tty /dev/tty3 noclear nowait
@@ -0,0 +1,2 @@
# Start klogd as soon as possible, should always run
service [S12345] /sbin/klogd -n -- Kernel log daemon
+1 -1
View File
@@ -1 +1 @@
service [2345] lxdm -- Lightweight Login Manager service [2345] /usr/sbin/lxdm -- Lightweight Login Manager
+4 -5
View File
@@ -1,7 +1,6 @@
## Linux kernel modules to load ## Linux kernel modules to load
#module fbcon #module fbcon
#module button module button
#module evdev module evdev
#module mousedev module mousedev
#module 8139cp module 8139cp
module softdog
+1 -1
View File
@@ -1,2 +1,2 @@
# Silly Busybox ntpd has no option to use syslog when running in foreground # 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 -1
View File
@@ -1,2 +1,2 @@
# Start SSH daemon as soon as basic networking comes up # 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,4 +0,0 @@
# Start syslogd as soon as possible, should always run
# Start klogd as soon as possible, but after syslogd
service [S12345] syslogd -n -- Syslog daemon
service [S12345] <pid/syslogd> klogd -n -- Kernel log daemon
@@ -0,0 +1,2 @@
# Start syslogd as soon as possible, should always run
service [S12345] /sbin/syslogd -n -- Syslog daemon
+1 -1
View File
@@ -1 +1 @@
service @uuidd:uuidd [2345] uuidd -F -- UUID generation daemon service @uuidd:uuidd [2345] /sbin/uuidd -F -- UUID generation daemon
+1
View File
@@ -0,0 +1 @@
available/dhcpcd.conf
+1
View File
@@ -0,0 +1 @@
available/getty.conf

Some files were not shown because too many files have changed in this diff Show More