Commit Graph
226 Commits
Author SHA1 Message Date
Joachim Nilsson fbfffbc9a4 Eliminate name clash with system signal.h header file.
Tried to solve the signal.h name clash by using #include_next, but
seeing as this is not recommended[1] and breaks builds on some cross
compilers, the files were simply renamed: signal.[ch] --> sig.[ch]

[1] - http://gcc.gnu.org/onlinedocs/cpp/Wrapper-Headers.html

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-26 22:57:25 +02:00
Joachim Nilsson e496913f5c README: Redo feature table into a definition list.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
1.0
2012-09-26 13:53:25 +02:00
Joachim Nilsson 5bc9ff0e20 README: Slight syntax change in feature table
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-26 13:49:32 +02:00
Joachim Nilsson dd0220fd2c Update and clarify README
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-26 13:47:57 +02:00
Joachim Nilsson bb0a378f1c Rename README --> README.rst and symlink README to it.
This change is purely for people interacting with the GitHub interface.
The README itself is written in the plain text reST format.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-26 13:30:05 +02:00
Joachim Nilsson 2a025356d4 Bump version, update README and add TODO and dist: target to Makefile
Preparing for 1.0 release.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-26 13:20:21 +02:00
Joachim Nilsson c49d89dfe0 Revert new experimental libev backend due to time constraints
Due to time constraints I had to revert the new libev backend to the
service, I/O and signals monitor.  Employed instead is the tried and
tested signals based service monitor, with a small extension for an
additional I/O monitor using poll() for the I/O plugins to use.

Tried restoring the startx finit.conf directive on top of the service
implementation. However, it's currently not usable to run /usr/bin/startx
for any other user than root. I recommend using the examples/finit.conf
and run /usr/sbin/gdm instead.

finit.c:
        New run_loop() function, replaces libev ev_run().

helpers.c:
        Refactor start_process() into svc_start().

plugin.c:
        Add fds[] array for use in the io_monitor() called by the
        new run_loop().

signal.c:
        Ignore SIGCHLD. Handled by waitpid() in svc_monitor() now,
        which is called by the new run_loop().

svc.c:
        svc_register(): Optional @username parsing for the command line.
        svc_monitor(): Replaced libev callback with waitpid()
        svc_start(): Refactored to use most of helpers.c:start_process()

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-26 12:18:54 +02:00
Joachim Nilsson 75eb5cc043 Move fork() of console to run_getty() and remove startx conf option
New function helpers.c:run_getty() refactored from main(). Used to
start a default console getty.

Removed startx finit.conf option, superseded by service statement,
see examples/finit.conf for a working use case.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-25 15:20:55 +02:00
Joachim Nilsson dfa0fe6428 Refactor conf-file parser into a file of its own.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-25 14:49:33 +02:00
Joachim Nilsson 0e02429e75 Convert finit to use libev and fix so plugin ctors runs on dlopen().
Lots of cleanup and simplification of the main code in this commit.
Most notably libev has been added to take care of the main loop and
monitor services. Still TODO is migrating to use the libev signal
handling.

Convert initctl.c:listen_initctl() to a plugin instead.  This also
meant introducing a new form of I/O plugin to finit, also handled
by libev.

Load plugins *after* we've setup the base filesystem (BASEFS) in case
plugins reside on a filesystem not reachable before "mount -a" has run.
This also has the side effect of lining up nicely with the first level
plugin hooks.

If a plugin wants to hook up with a loded service we connect them by
their respective numeric IDs in plugin_register().  I.e., the service
monitor checks if a service has a registered callback, which in turn
decides if a service should be started, stopped or reloaded.

Rip out old EeePC distribution defines from finit.h, none of it really
applies anymore.  If you need distribution specific settings this is
the place to put them.

Make hookpoint names (#defines) clearer: after BASEFS, after networking,
after all setup, etc.

Use #inlude_next <signal.h> in signal.h to include system header file!

Simplify service monitor: move essential code to svc.c and rip out
the TIPC dependency. Write your own service.so plugin, or wait for
a more complete example of how to extend service monitoring using
the primitives in svc.c

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-25 14:23:23 +02:00
Joachim Nilsson 5dda9051ac Refactor main() into more functions and convert #ifdef hell into plugins.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-21 03:32:07 +02:00
Joachim Nilsson 239772d667 Add basic support for dynamically loadable plugins
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-21 00:33:46 +02:00
Joachim Nilsson a0fa877520 Move example configuration files to examples subdirectory
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-21 00:31:13 +02:00
Joachim Nilsson 23ef745985 Remove deprecated finit implementations, see the 0.6-pre tag for reference.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-20 17:54:29 +02:00
Joachim Nilsson 077a7e82e0 Debian now boots to X!
finit.conf:
        Use this as /etc/finit.conf on a Debian 6.0 based system with X
        installed and sysklogd instead of rsyslogd.  Works.

services:
        Alternative method for extending the finit boot procedure. Simply
        place this script file in an /etc/finit.d/ directory.  The script
        uses the standard run-parts tool to chain load other start scripts.

helpers.c:
        o New functions:
          - run(): home grown system() replacement
          - run_interactive(): display progress and status when called

        o Bugfix start_process(), make sure to use same signal setup for
          children as in run() and run_interactive(). Also, use execvp()
          instead of execv() to allow searching $PATH for executables.

finit.h:
        o Move signal specific code to new signal.h.
        o Bypass verbosity setting to let echo() always print to screen.

finit.c:
        o Make run_parts() the default, remove external deps, it works.

        o Use run() and run_interactive() to speed up execution further
          on embedded systems where forking is expensive.

        o Kernel cmdline "quiet" should not close STDIO since this makes
          it impossible to run some daemons and start scripts.  Instead,
          we let "quiet" toggle the finit verbosity setting.

        o Remove kernel cmdline "--verbose" (Upstart compat), to be used
          to enable verbose finit when kernel should be quiet.

        o Setup kernel specific settings in /etc/sysctl.conf

        o Fix D-Bus startup problems. Probably what caused X from not
          working initially. Silly rabbit.

        o Use system() workaround to start X, cannot get it to start
          at all using run() or run_interactive() at the moment.

signal.h:
        New file, header file for signal.c.  Was about time.

signal.c:
        Remove blocking of SIGCHLD from sig_setup(), instead we setup
        SIGCHLD early in sig_init() to handle fork() in run() & C:o.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-20 17:50:53 +02:00
Joachim Nilsson d21dc2b477 Westermo service starter and supervisor, inspired by daemontools
finit.c:
        o New service and shell_service stanzas for finit.conf
        o Run service_startup() before /etc/finit.d/ hooks
        o Run service_monitor() at end of startup

helpers.c:
        o Several new functions:
          - print_desc() displays a service starting up
          - print_result() shows if service started OK or not
          - start_process() is used by the services framework

svc.c:
        Generic API for managing svc_t structures

ipc.o:
        TIPC based framework for communicating with the service monitor.
        E.g., to relay (re)configuration signals from a Web/CLI
        front-end via finit to one or many setup daemons, and back.

services.c:
        Service monitor framework

strlcpy.c:
        Secure strncpy() replacement from OpenBSD under the free ISC License.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-20 01:16:00 +02:00
Joachim Nilsson c0356b5c7a Massive cleanup to be able to boot Debian 6.0
Update license and copyright information details in all files.
Much cleanup by moving hard coded strings/data to #defines and using more
common default values for each such #define.

finit.c:
        o Make sdown[], startx[] allocated strings by default NULL
        o This fixes the issues where the shutdown handler segfaulted
        o Add ability to handle NULL input to build_cmd() by allocating space
        o Ignore kernel cmdline "quiet" if in debug mode
        o Add support for "network" stanza in finit.conf
        o Mount -n to skip removing /etc/mtab
        o Call swapon to enable swap if enabled in /etc/fstab
        o Cleanup /tmp, /var/run and /var/lock
        o Move sig_setup() *after* mount, sig_init() otoh runs early
        o Start initctl monitor before forking off startx/getty process
        o The startx process is now the console process. Only a getty is
          started when in debug mode. Otherwise only X is started if it
          is properly setup in /etc/finit.conf
        o NOTE: Currently X evdev does not work!
        o Support for /usr/sbin/services.sh has been replaced with finit
          now instead supporting builtin run-parts for /etc/finit.d/

helpers.c:
        o Bug fixes in run_parts() and also added chdir(oldpwd) at bottom.
        o New functions:
          - getuser() similar to getgroup()
          - cls() clear screen, only runs when not in debug mode
          - set_procname() used to set name "console" on console process
          - set_hostname() encapsulates /etc/hostname and sethostname()

signal.c:
        o Split sig_setup() in two: sig_init() and sig_setup()
          The former to be called as soon as possible, while latter is
          supposed to run when the base filesystem is properly up.
        o Remove hard coded distribution specific progress bar write()
        o Add debug messages to do_shutdown()
        o Remove any lingering sync files in sig_setup()

initctl.c:
        o Add debug messages and a new default: case to catch stray runlevels

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-19 18:06:12 +02:00
Joachim Nilsson 855c7d8251 Assume kernel has devtmpfs enabled --> cleanup device creation & mount
Cleanup device creation and initial mount by assuming that the kernel
has devtmpfs enabled.  This is the default for most modern GNU/Linux
distributions.  See http://lwn.net/Articles/331818/ for more info.

Also, since finit is targeted at deeply embedded systems hooks for the
BusyBox udev replacement, mdev has been added.  If MDEV is defined in
the build it will take care of both hotplugging of devices and initial
setup of /dev

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-17 16:05:41 +02:00
Joachim Nilsson 2f527215d0 Compat kernel command line debug option --verbose
Check for "--verbose", as well as "finit_debug", on kernel command
line to enable debugging of finit.  The former is a compatibility
option with upstart, see http://upstart.ubuntu.com/wiki/Debugging

Add the following to the kernel command line to enable:

    "init=/sbin/finit --verbose"

Without the quote characters.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-17 11:09:35 +02:00
Joachim Nilsson 5da4f4cfc3 Add support for standard UNIX comment chars in finit.conf
finit.c:
        Skip standard UNIX comment character '#' if it appears at the
        beginning of a row in finit.conf

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-17 10:43:06 +02:00
Joachim Nilsson b0aec188bc Further cleanup, move signal setup to a file of its own.
finit.c:
        o Perform signal setup as soon as possible, no need to do any
          mounting of /proc or /sys beforehand
        o Move signal setup and callbacks to a file of its own
        o Use more #defines for hard coded strings
        o Use a more neutral default hostname

signal.c:
        o New file, for setup and signal handlers
        o Add support for SIGSTOP/SIGSTP and SIGCONT.  This pauses finit
          respawning of xinit/shell.  Useful for, e.g., debugging
        o Document each ignored and handled signal better
        o Disable SIGUSR1 and SIGUSR2 for now, will be reenabled later

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-17 10:41:18 +02:00
Joachim Nilsson 4657d9713a Minor cleanup. Moved code around a bit, to functions, away from main().
This commit is in preparation for importing the Westermo code changes.
Slowly refactoring the finit core into a more modularized unit to be a
bit more maintainable.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-17 01:51:37 +02:00
Joachim Nilsson a654d99b92 Archive previous versions for reference.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-14 13:23:17 +02:00
Joachim Nilsson e2c4a6ceaf Remove optional --directisa call to hwclock, this is the default anyway.
This is a followup to Olivier Blin's patch from 88ffb93 in that it
applies the same patch to finit-mod.c that is already in finit.c, or
finit-alt.c as it was called then.

Also, the optional --directisa argument to hwclock is not necessary.
The hwclock utility has a built-in fallback to use excplicit I/O over
the /dev/rtc in case the latter does not exist.  See the hwclock(8) man
page for more information on this.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-14 13:11:31 +02:00
Joachim Nilsson 5816c9cab9 Embedded finit for small embedded Linux systems and servers.
o Make finit-alt.c the new finit.c, save old finit.c as finit-org.c
o Keep original finit-alt.c for reference.
o Update README and ChangeLog with direction of this fork
o Correct ChangeLog date for v0.1 and set release date for
  the 0.6-pre release to 20100614, which is the last commit
  by the original author.
o Add standard LICENSE file for MIT License
o Add standard AUTHORS file to document history of project
o Bump version to 1.0-pre to distance fork from original

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-09-14 13:10:39 +02:00
Claudio Matsuoka f92438d42a Add hook to call shutdown script
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
0.6-pre
2010-07-14 18:09:16 -03:00
Claudio Matsuoka 6afbcbdd6e Mount /sys earlier (modprobe modprobe might use it) (blino)
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2009-04-29 12:49:01 -03:00
Claudio Matsuoka b9583fb354 Don't set Pentium M arch by default
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2009-04-14 12:59:48 -03:00
Claudio Matsuoka 37af9970d4 Disable annoying warning caused by attribute warn_unused_result
Example:
gcc -c -Os -Wall -DVERSION=\"0.6-pre\" -DWHOAMI=\"`whoami`@`hostname`\" -march=pentium-m -DBUILTIN_RUNPARTS -o finit-mod.o finit-mod.c
finit-mod.c: In function ‘main’:
finit-mod.c:107: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result
finit-mod.c:137: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result
finit-mod.c:164: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result
finit-mod.c:168: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2009-04-14 12:55:44 -03:00
Claudio Matsuoka 3a7f7cd61a Create /dev/vcsX, /dev/vcsaX when building for Mandriva (caio)
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2009-04-14 12:46:29 -03:00
Claudio Matsuoka b11d6c6d4e Make the version information a debug message (caio)
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2009-04-06 11:42:53 -03:00
Claudio Matsuoka 88ffb9351d Don't mess mess localtime/UTC setting in finit
Signed-off-by: Olivier Blin <oblin@mandriva.com>
2009-04-06 11:36:19 -03:00
Claudio Matsuoka c70872f19e Honor quiet flag in kernel command line
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2008-12-04 14:25:29 -02:00
Claudio Matsuoka 9e0b22ddb6 Hmm, maybe not. We'll see.
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2008-10-16 14:28:00 -02:00
Claudio Matsuoka 321264f0dc So hnoring quiet was important after all
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2008-10-16 13:51:21 -02:00
Claudio Matsuoka 65c971925c Remove usplash and nologin from Asus legacy code
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2008-10-10 13:03:31 -03:00
Claudio Matsuoka a2de2c1591 Add comment for DISPLAY setting
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2008-10-07 17:19:38 -03:00
Claudio Matsuoka 85fedac866 Set DISPLAY before invoking xinit (miura)
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2008-10-06 14:33:13 -03:00
Claudio Matsuoka 29ab953a87 Make startx command configurable from finit.conf
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2008-10-01 16:50:38 -03:00
Claudio Matsuoka 1843a0e66f Don't close descriptors on kernel "quiet" flag
(Asus legacy). Closing them prevents fsck output when booting quietly.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2008-09-11 16:45:19 -03:00
Claudio Matsuoka 6a8a3fd4ab Remove timestamping debug messages
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2008-09-04 15:24:24 -03:00
Claudio Matsuoka d096efe643 Remove extra sleep before executing services.sh
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2008-09-04 14:02:51 -03:00
Claudio Matsuoka e33d385f0c Update gdium makefile
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2008-09-03 14:41:13 -03:00
Claudio Matsuoka 7ebc19782f Update changelog
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2008-09-02 13:07:28 -03:00
Claudio Matsuoka 4af58f8bb0 Disable USE_VAR_RUN_RESOLVCONF for Mandriva, unset TERM
Unsetting TERM in distributions using bash as /bin/sh prevents execution
of loadkeys from bashrc when creating the user environment to run X

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2008-09-02 13:03:25 -03:00
Claudio Matsuoka ed4abc952a Unmount all filesystems before rebooting
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2008-08-27 17:17:26 -03:00
Claudio Matsuoka 52feb6f51c Invoke xinit directly instead of startx
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2008-08-26 19:10:09 -03:00
Claudio Matsuoka c7c388e567 Remove consolekit and superfluous 0.5s delay
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2008-08-25 15:19:34 -03:00
Claudio Matsuoka 95a70ed2af Update changelog
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2008-08-25 13:53:02 -03:00
Claudio Matsuoka 4554377e4d Don't start consolekit manually in mandriva
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
2008-08-25 13:31:36 -03:00