Commit Graph
119 Commits
Author SHA1 Message Date
Tobias Waldekranz 2232aea0f7 Dynamically manage service states based on user defined conditions
Old event system has been replaced with a more generic condition
concept. The idea is that finit plugins may provide arbitrary
conditions that services may specify as dependencies that they require
to run.

In order to accomodate this, the service management has been
redesigned to use a state machine.
2016-01-05 15:01:58 +01:00
Joachim Nilsson a822a7657c Update ChangeLog and bump version for v2.4 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-12-04 19:15:48 +01:00
Joachim Nilsson 8218fff7e5 Update ChangeLog and bump version for v2.3 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-28 13:59:47 +01:00
Joachim Nilsson d8188428ed Bump version for v2.2 release.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-23 13:20:44 +01:00
Joachim Nilsson d9f1882204 Update ChangeLog and prepare for release of v2.2
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-11-23 00:59:04 +01:00
Joachim Nilsson e1169628ce Update ChangeLog and bump version for v2.1 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-16 20:44:47 +02:00
Joachim Nilsson b5e3e69553 Do not allow VERSION to be overloaded by build system.
When integrating finit as a component in another system, that build
system may set VERSION as an environment variable for that OS -- we do
not want that version to be set as the version of finit.

Also, bump version to 2.0.1-dev for upcoming patch release cycle.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-02 15:09:07 +02:00
Joachim Nilsson 545f3105e2 Update ChangeLog and bump version for v2.0 release.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-20 12:27:41 +02:00
Joachim Nilsson eec166a9eb Add simple service script for SysV init compat.
This patch adds a simple `service <script> <stop|start|reload|restart>`
script for for SysV init compatibility.  Very common with users of the
Ubuntu upstart init as well.

Also, fixed `make uninstall` for plugins.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-19 22:04:26 +02:00
Joachim Nilsson 125fc661a3 Makefile: Allow clean and distclean targets when libite/libuev are disabled.
Even though libite and libuEv can be disabled, using the --with-libnnn
option to configure, we let make descend into those submodules for the
clean and distclean targets.  This way we can rely on make dev to work.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-18 09:14:49 +02:00
Joachim Nilsson 6531b2f20a Add --with-libuev=PATH to configure script to use external libuEv
This commit makes it possible to build Finit with an external libuEv.
Without this configure script option the libuev submodule is used.

With an external libuEv we make sure to set the SONAME to libuev.so.1
to prevent any future runtime ABI issues.

Fixes issue #4.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-17 12:59:20 +02:00
Joachim Nilsson 1f84edfb8c Add --with-libite=PATH to configure script to use external libite
This commit makes it possible to build Finit with an external libite.
Without this configure script option the libite submodule is used.

With an external libite we make sure to set the SONAME to libite.so.2
to prevent runtime ABI issues with older libite versions.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-17 11:59:46 +02:00
Joachim Nilsson 36aba8952f Bump version to v2.0-beta1 for upcoming release and rename CHANGELOG.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-15 09:25:05 +02:00
Joachim Nilsson 6e07dd8dec Add support for starting/stopping services on Netlink events
This commit adds support for event based services to Finit.  Along with
the previously added support for multiple instances of the same process,
the feature scope for Finit v2.0 has been reached!

As of now a service can be declared in /etc/finit.conf or /etc/finit.d/
like this:

    service :1 [2345] <!IFUP:eth0,GW> /sbin/dropbear -R -F -p 22 -- SSH daemon

Here the first instance `:1` of dropbear is declared to run in runlevels
2-5, but only if eth0 `IFUP:eth0` is up and a gateway `GW` is set.  When
the configuration changes, a new gateway is set, or somehow a new `IFUP`
event for eth0 is received, then dropbear is not SIGHUP'ed, but instead
stop-started `<!>`.  The latter trick applies to all services, even
those that do not define any events.

Currently inetd services are not supported for event based starting, but
it could easily be added.  Likely scenario is to deny incoming requests
on, e.g., eth0 if there is no gateway.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-15 09:13:33 +02:00
Joachim Nilsson 5126017c7e Merge branch 'makefile-glibc-2.20' of https://github.com/wishdev/finit into wishdev-makefile-glibc-2.20 2015-09-08 08:00:39 +02:00
John W Higgins d2ed03e74c Update Makefile for glibc-2.20+ 2015-09-07 16:56:32 -07:00
Joachim Nilsson ee9e49f412 Makefile: Do not fail anymore on warnings, not useful in production.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-06-22 22:04:14 +02:00
Joachim Nilsson f1807a32ca Make it possible to distribute finit.h in 'make dev-install'
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-06-22 15:12:20 +02:00
Joachim Nilsson 276cda9a4d Install -dev files for both libite and libuev, needed for external plugins.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-06-18 08:44:15 +02:00
Joachim Nilsson e7dad9a770 Add inetd.h to distributed headers, needed for external plugins.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-06-17 14:07:35 +02:00
Joachim Nilsson 02e5c868ba Makefile: Declare dependencies better, for parallel builds
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-06-17 14:07:30 +02:00
Joachim Nilsson 1a1f24721f Refactor: introduce telinit and a new initctl tool w/ API
- 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>
2015-06-13 12:26:16 +02:00
Joachim Nilsson 1d58f4abbe initctl: New symlink to finit binary, document functions in README.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-06-08 18:06:55 +02:00
Joachim Nilsson 811bd75eab Refactor: Move client code to separate file and add 'status' command.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-06-07 12:09:55 +02:00
Joachim Nilsson 97a48ec5fb Refactor: move advanced service methods from svc.c --> service.c
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>
2015-06-07 03:23:46 +02:00
Joachim Nilsson 9139afd318 Bump version for -dev cycle.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-04-25 10:18:40 +02:00
Joachim Nilsson 32587d341c Overhaul build system and add support for disabling inetd support.
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>
2015-03-10 10:25:46 +01:00
Joachim Nilsson a74b640507 Initial support for building Finit statically (incomplete)
This patch adresses issue #5.  However, there still remains a few issues
to work around before Finit can be built completely standalone.

    $ make clean all STATIC=1
    LINK    finit
    helpers.o: In function `getgroup':
    helpers.c:(.text+0x10a7): warning: Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    helpers.o: In function `getuser':
    helpers.c:(.text+0x108e): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    inetd.o: In function `getent':
    inetd.c:(.text+0x127): warning: Using 'getprotobyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    inetd.c:(.text+0xce): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

The problem is the NSS plugins and similar issues that prevent static
linking when using the above functions.  See issue #5 for more on this.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-03-06 21:58:56 +01:00
Joachim Nilsson cf651df744 Bump version for v1.12 release.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-03-04 17:00:37 +01:00
Joachim Nilsson a5b9f566b3 Initial support for inetd/on-demand services \o/
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-02-09 00:43:15 +01:00
Joachim Nilsson 46ddf4bcc6 Commence new -dev phase.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-01-24 23:56:52 +01:00
Joachim Nilsson 9b361864fa Fix make dist target for v1.11 release.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-01-24 16:16:13 +01:00
Joachim Nilsson 840ade6da7 Bump version for next release, fix make dist and rename NEWS --> CHANGELOG
- Bump version for coming 1.11 release
- Update `make dist` to use Kentzo's `git-archive-all` from
  https://github.com/Kentzo/git-archive-all
- Rename NEWS --> CHANGELOG and update for coming release
- Update CHANGELOG with info on the libuEv migration

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-01-18 23:22:39 +01:00
Joachim Nilsson 425cd17e57 Initial conversion to use libuEv for all event handling.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-01-18 00:53:14 +01:00
Joachim Nilsson aa8d6a7294 Bump version for 1.10 release.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2014-11-27 22:33:24 +01:00
Joachim Nilsson 757911f149 Bump version for release and update copyright years.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2014-04-21 16:03:54 +02:00
Joachim Nilsson 7ada824e3e Makefile: Add support for make check to run cppcheck
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2014-04-12 16:08:30 +02:00
Joachim Nilsson 329acf24bb Bump version and start preparing docs for release of 1.8
Renamed ChangeLog to NEWS and fixed doc style to use ReST, like the
README and TODO files.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-06-07 09:16:00 +02:00
Joachim Nilsson c57bd066d1 Build fix, if ROOTDIR was set linking failed. Use TOPDIR internally.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-06-06 18:19:26 +02:00
Joachim Nilsson 0f60aa2289 Refactor TTY code to honor runlevels and use I/O plugin to watch /dev
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>
2013-06-06 18:19:26 +02:00
Joachim Nilsson 56ef3f75d3 Build: Make subdir build prettier.
The ROOTDIR variable was only set in the top-level Makefile,
so when building from a subdirectory the output was slightly
garbled.  Moved ROOTDIR declaration to common.mk.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-05-22 06:18:52 +02:00
Joachim Nilsson c551228079 Makefile: Minor cleanup and only set ROOTDIR if unset already.
The ROOTDIR variable is used for pretty formatting during compilation.
Some users might want to have this display the build from the top of
their tree instead of the finit build tree.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-05-19 18:00:31 +02:00
Mattias Walström 407a47dd12 libite: Add strlcat and strlcpy.
These function only exist on uClibc and BSD, so if they
not already defined in string.h, define them here.
2013-01-29 13:29:45 +01:00
Mattias Walström 5961748b2a Add basic support to specify login TTYs in configuration
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.
2013-01-22 21:17:20 +01:00
Joachim Nilsson a18c5f3441 Update ChangeLog and bump version for release.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-10-08 12:05:21 +02:00
Joachim Nilsson 685618691d Update ChangeLog and bump version for release. 2012-10-06 18:07:39 +02:00
Joachim Nilsson cbb50937cd Update ChangeLog and bump version.
New release, 1.5! :)

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-10-03 23:30:23 +02:00
Joachim Nilsson 83a4bf7947 Add dependency resolver for plugins.
This has been something I wanted to avoid, but then I stumbled so hard
on it myself I simply had to add it.  With this commit finit actually
comes of age -- it's now possible to do anything a modern init can --
only faster! :-)

Included in this commit is the OpenBSD version of sys/queue.h, which
unline all versions of the same file on Linux has the _FOREACH_SAFE
macros for iterating over a linked list.

The plugins are now in a TAILQ, loaded in alphabetic order and, unless
the dependency resolver says otherwise, added last in the queue.  So,
naming your plugins according to standard sysvinit rules: S01, S02,
etc. takes care of the most basic dependency resolution.  When that is
not sufficient, simply add a line ".depends = { "other_plugin",
"another_plugin" }," to your plugin_t definition.  Be careful though
for circular dependencies, we don't check for those.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-10-03 23:20:34 +02:00
Joachim Nilsson 65c9e7ebc6 Fix I/O plugin watcher, load plugins earlier to enable a new early hook!
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>
2012-10-02 08:25:50 +02:00
Joachim Nilsson f55f68d032 Cleanup and refactor of public plugin API
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>
2012-10-02 06:39:19 +02:00