Check return code from `mount -na`, if there where any errors give
plugins a chance to do something about it.
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
- Reduce size of `helpers.c`, for linking against new `initctl` tool,
by moving out functions to `pid.c` and `exec.c`
- Add `AF_UNIX` API to Finit, to complement old `/dev/initctl` FIFO
- Let old FIFO API be used by init/telinit: `init <q | 1-9>`
- Move all advanced initctl code from `client.c` to `initctl.c`, yes
its a bit confusing to call the *new* tool the same as the old FIFO
but this is more in line with what, e.g Upstart does.
- Move all advanced server side code from `plugins/initctl.c` to `api.c`
- Update TODO with upcoming inetd syntax change and dynamic events.
- Temporarily fix display of inetd services from `initctl status -v`
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Further refactoring of the client code. Supported commands:
- debug: Toggle PID 1 debug flag
- version: Show Finit version or custom header string
- reload: Reload config files in /etc/finit.d/, same as SIGHUP
Also supported is the legacy 'init q' command, to reload config.
The 'status' command now supports an optiona '-v', either as an
argument to init itself, or as argument to the command. When it
is given 'status' lists verbose information about all services.
Currently only the service arguments are listed.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch refactors svc.c into two files: svc.c now as a low-level
svc_t API and service.c for the more advanced rest.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch adds support for adding and removing services from Finit at
runtime. Configuration file stanzas for service, run and task may now
be written to files in /etc/finit.d/*.conf, using the exact same syntax
as before in /etc/finit.conf. When a file is added, removed or modified
the user may simply SIGHUP Finit (PID 1) to activate the changes.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
When a user changes runlevel, or wants to reload the config, we want the
command to return only when the operation has completed. For instance,
rolling in a new system configuration in runlevel 1 requires that we are
sure we've actually entered that runlevel before rolling it in.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch adds support for a configure script and with it
support for disabling inetd support. See the output from
./configure --help
* Add configure script
* Sprinkle #ifdef fairy dust on svc.c when inetd support is disabled
* Use GCC built-in autodep calculator (-MMD -MP)
* Fix name space issue with include files, use relative paths
* Disable username/group name to uid/gid functions in static builds
* Bug out (error) if a user tries to build the bootmisc plugin static
Possibly fixes GitHub issue #5 and issue #6.
NOTE: The static build has not received any testing at all!
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch is slightly sub-optimal, since it will causes us to load all
availble plugins, not just those referenced by finit.conf. However, in
the short term perspective we need to reference internal inted services
provided by plugins from finit.conf, so the dependency order is clear.
In the midterm perspective we want to add support for SIGHUP to reload
finit.conf, but not plugins. So again, this is an OK patch.
One fix would be to allow loading of all plugins, parse finit.conf and
then unload all unused plugins before continuing.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Revert crazy BANNER macro idea from 5ba7bc1. It is simply too difficult to
set -DBANNER='"Some distributions specific text"' in a parent Makefile
without entering Shell/Make escape hell ... instead, downstream will
have to patch the banner() function.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Standard init implementations save current and previous runlevels
in utmp, now finit does too. Also, the initial runlevel at boot
has changed from 10 to the more obvious 0.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Add support for runlevels to tty command and support for reading baud
rate and TERM variable from finit.conf.
The tty-watcher thread has been converted to a standard I/O plugin.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Most systems need an early bootstrap phase for one-shot tasks and
necessary one-time probing. This phase usually runs well before any
networking is setup. This commit adds support for that 'S' runlevel,
and also extends the number of possible total runlevels to nine.
For the one-shot tasks that run in bootstrap two new finit.conf cmds
have been added:
- task: For one-shot tasks that can be started in parallell
- run: For one-shot tasks that must run in sequence
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
- Remove indentation of module loading and device node creation
- Clarify that we load kernel modules
- Clarify that we load Finit plugins
- Remove cls()
- Remove verbose condition for echo()
- Make banner a separate function with optional distribution banner
- Add a few neat ANSI escape sequences for cls(), clreol(), delline(), etc.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit adds support for -d, --debug option to init, which can
be used to toggle the finit debug mode at runtime.
Signed-off-by: Mattias Walström <lazzer@gmail.com>
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Like most other init implementations do, when entering runlevel 1, finit
creates the file /etc/nologin to prevent users from logging in during
single-user mode, this file is then removed upon leaving runlevel 1.
Also, bugfix how FIFO I/O plugins are handled in finit. A FIFO will
need to be reopened by the server side when the client closes the pipe.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit adds support for specifying TTY and console to be used
for starting a getty to login to the system
Add the following to your finit.conf to use this feature:
tty ttyS0
tty ttyUSB0
console ttyS0
Signed-off-by: Mattias Walström <lazzer@gmail.com>
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This also adds support for monitor /dev for TTYs appering after boot,
USB-to-serial converters for example.
Some limitations: Baudrate (and other settings) is hardcoded for now,
should be read from config file.
This is a bugfix to 785c21d, which introduced the new runparts
directive in finit.conf
- Do not attempt to free() a static string, use same approach as
username and hostname.
- Do not overwrite hostname, set the correct variable if runparts
directive is found in finit.conf
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
The run_parts() implementation used variable arguments in a bad way,
resulting in it not working properly. Replaced va_*() code with a
simple cmd argument that's passed to each script called.
Also, the opendir()/readdir() code has been replaced with scandir()
using regular alphasort(). This simplifies the code somewhat as well.
Otherwise, minor cleanups.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit adds support for the "runparts <DIR>" directive to
finit.conf. Enabling the user to override the built-in default,
which by default is /etc/finit.d.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Restructure start by calling the plugin loader earlier. This makes it
possible to run hooks even earlier. This also adds a new hook:
HOOK_ROOTFS_UP which runs as soon as the system root (/) is available.
Another very notable change is the slow refactor of helpers.c into a finit
helper library called libite.so (-lite). This is a light-weight
Also, lots of misc. fixes all over the place. Signal handling still really
needs to be looked into once more!
Makefile:
Add dependency handling for parallell build
Add libite library
ChangeLog:
Update with new 1.4 release. There is a lot of fixes!
libite/:
Collection of utility functions and C library extensions for
finit & its plugins
reboot.c:
New reboot tool. Simply sends SIGINT to PID 1
finit.h:
Cleanup old LISTEN_INITCTL define, code is in an optional plugin now
finit.c:
Let mdev/udev run *after* cls()
Add useful debug statement for /proc/cmdline
Earlier plugin load => new early hook point
Show OK/FAIL for total plugin load, not for each plugin => speedup
helpers.h:
Rename syslog macros to prevent common name clashes (DEBUG/ERROR)
Add __FILE__ to _e(), _d() and _pe() macros
helpers.c:
In ifconfig() the addr and mask arguments are now optional
The copyfile() has been moved to libite.so
Temporarily remove const directive from some functions to build
Use DFLSIG() macro in run_getty() to simplify code
plugin.h:
Add new HOOK_ROOTFS_UP hook
plugin.c:
Fix init_plugins() to actually register the plugin's I/O fd
Skip verbose listing of all plugins in plugin_load_all()
svc.c:
svc_start(): Dito
plugins/Makefile:
Inherit CFLAGS and LDFLAGS, but make sure to filter out -rdynamic
from LDFLAGS, it's used by the daemon, only
plugins/initctl.c:
New includes after helpers.h refactor
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Improve upon API names, both internal and external, to make it clearer
where methods are located and clarify responsibility.
Add new Makefile target "dev" to create untagged development snapshots.
Bump version for upcoming release.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>