Commit Graph
308 Commits
Author SHA1 Message Date
Joachim Nilsson d7598ca672 Update URL of example to new download FTP. 2013-06-08 15:37:31 +02:00
Joachim Nilsson ff8e494abd Update README with a slightly more clear and catchy intro. 2013-06-08 14:49:28 +02:00
Joachim Nilsson dfaa6dd3f8 Minor ReST syntax fix for improved display in GitHub
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-06-08 11:23:24 +02:00
Joachim Nilsson 849f3fbb28 Explain finit.conf commands more in README, update example .conf
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
1.8
2013-06-07 14:09:46 +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 bf40278131 Delay start of TTYs to let system stabilize at boot.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-06-06 18:19:27 +02:00
Joachim Nilsson 4f2cf52eff Minor cleanup. 2013-06-06 18:19:27 +02:00
Joachim Nilsson f96fb855ce tty: Clear PID to be able to respawn it.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-06-06 18:19:27 +02:00
Joachim Nilsson 65f0be8a55 Simplify banner further, let distributions patch us instead.
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>
2013-06-06 18:19:26 +02:00
Joachim Nilsson bcfcafdb7c tty: Use calloc() instead of malloc() to prevent uninitialized errors.
On some platforms GCC does not zero the heap. This can lead to
serious problems, e.g., tty->pid may be non-zero while never
having been started.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-06-06 18:19:26 +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 4171fbdfd3 Store RUN_LVL in UTMP and change RUNLEVEL_BOOT from 10 to 0
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>
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 f97aab4699 Rename stat_restart_counter --> restart_counter
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-06-06 18:19:18 +02:00
Joachim Nilsson 740d447442 Update Debian 6.0 example /etc/finit.conf and /etc/finit.d
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-06-04 13:12:53 +02:00
Joachim Nilsson 6448d6ccfa Coding style and whitespace fixes
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-06-04 09:25:11 +02:00
Joachim Nilsson 25cc9f3b9b Improve runlevel support by adding a bootstrap phase, also adds task/run cmd
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>
2013-06-04 09:25:05 +02:00
Joachim Nilsson e776838de9 Rename USE_UDEV & MDEV to SETUP_DEVFS and USE_MESSAGE_BUS to HAVE_DBUS
USE_UDEV,MDEV   => Unique SETUP_DEVFS for embedded or distro usage.
USE_MESSAGE_BUS => HAVE_DBUS

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-06-04 07:21:08 +02:00
Joachim Nilsson bf0cfe0693 Update and clarify TODO items, e.g., add info on new "task" and "run" stanzas
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-06-04 07:21:00 +02:00
Joachim Nilsson f690767507 Refactor .conf file parser and add support for runlevel N
This commit is a refactor of how arguments to finit.conf file settings
are parsed.  Not all settings are run directly, but only need the arg
for future use.  The code should be a lot easier to understand now.

Also, added support for specifying the desired runlevel in finit.conf

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-05-22 12:42:56 +02:00
Joachim Nilsson 4d57b14b5b Bugfix chomp() and set_hostname()
chomp():
        Removed first \n instead of last \n

set_hostname():
        If /etc/hostname exists we need to realloc the size of
        the current hostname variable. Also, only try to set
        the hostname if !NULL

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-05-22 12:41:59 +02:00
Joachim Nilsson 263036045a tty: Check input arguments for invalid tty before adding.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-05-22 12:36:19 +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 d0c902ab78 libite: Add strtonum() from OpenBSD
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-05-21 19:55:41 +02:00
Joachim Nilsson 5ba7bc1fdf Cleanup and simplify boot process messages
- 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>
2013-05-21 12:52:06 +02:00
Joachim Nilsson 7e9ac7ba67 Fix indentation and ReST syntax.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-05-20 15:32:04 +02:00
Joachim Nilsson e2eaee9620 TODO: Add entry on mimicing Debian SysV init rcS.d, runs once at boot.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-05-20 15:25:14 +02:00
Joachim Nilsson b23ce7ab8e Update TODO
More inspiration and courage from the launchd Google Talk video!
Fascinating stuff about replacing init/inetd/cron/watchdogd that
I've been thinking about for ages!

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-05-19 23:39:23 +02:00
Joachim Nilsson 53127a7ce6 Update TODO
Move to use ReST syntax, like README, and update to reflect current
status of project.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-05-19 19:01:45 +02:00
Joachim Nilsson 011b73ba39 Fix issue with "Formatting of boot text changes in the middle of the boot."
This commit adds a line: "Loading kernel modules ..." before increasing
indentation level of module loading messages.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-05-19 19:01:45 +02:00
Mattias Walström 5d04a72a61 Add support for toggling the debug mode at runtime
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>
2013-05-19 19:01:44 +02:00
Joachim Nilsson c3b76fdccf Add basic support for runlevels and bugfix FIFO I/O plugins
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>
2013-05-19 19:01:44 +02:00
Mattias Walström ec95243dad libite: Fix memory leak in dir()
Signed-off-by: Mattias Walström <lazzer@gmail.com>
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-05-19 19:01:44 +02:00
Joachim Nilsson ae5d4a0bb2 Add support for user/distribution specific banner at startup.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-05-19 19:01:44 +02:00
Joachim Nilsson 0231f858e9 helpers.c: Make system message optional top run_interactive()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-05-19 19:01:44 +02:00
Joachim Nilsson 5d6db9f76f tty.c: Minor cleanup and check global variable before dereferencing.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-05-19 19:01:44 +02:00
Mattias Walström 3bcefd2160 Add support for specifying TTYs and console TTY in finit.conf
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>
2013-05-19 18:45:27 +02:00
Joachim Nilsson 89675403d8 Add support for service restart counter.
This commit adds a statistics counter to the finit svc_t process struct
which is incremented every time a process is restarted by the service
monitor.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-05-19 18:00:31 +02:00
Joachim Nilsson f277166354 sig.c: Use watchdogd to reboot system
This patch reorders the shutdown/reboot handler slightly and fixes
a bug in sleep().  It seems the sleep() syscall was interrupted by
receiving lots of SIGCHLD.  Unsurprisingly since we just sent all
processes SIGTERM, but unfortunate since that was too short time
to deliver SIGTERM to watchdogd.

We now call sleep() again, as long as it returns a non-zero value,
until at most two (2) seconds have passed.  During this time we
basically pend for watchdogd to do its job and let the WDT reboot
the system.  If the two second timeout passes we send SIGKILL and
forcibly reboot(RB_AUTOBOOT) the system.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-05-19 18:00:31 +02:00
Joachim Nilsson b212babc87 helpers.c: Fix run() argparser, assumed all commands have args. 2013-05-19 18:00:31 +02:00
Joachim Nilsson 6518c2d246 libite: Improve error handling for copyfile() and rsync()
When using the simple rsync() or copyfile() functions of libite some
error codes should not be interpreted as error.  I.e., if a file or
directory already exists when attempting to create it.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2013-05-19 18:00:31 +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
Joachim Nilsson c1198087af TODO: Update with requests for more consoles and runlevel support 2013-05-19 18:00:31 +02:00
Joachim Nilsson 990ccc6d8b Merge pull request #2 from mattiaswal/eglibc
Add support for strlcpy and strlcat
2013-02-19 09:30:22 -08:00
Joachim Nilsson 56a16066b7 Merge pull request #1 from mattiaswal/tty
Add basic support to specify TTYs in configuration
2013-02-19 09:30:06 -08: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 73b43b4f2b Add missing include <sys/stat.h> 2013-01-29 13:16:21 +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>
1.7
2012-10-08 12:05:21 +02:00
Joachim Nilsson 03c47a4020 Only cls() when verbose mode enabled, maybe we should remove it?
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2012-10-08 11:59:56 +02:00