Commit Graph

44 Commits

Author SHA1 Message Date
David Oberhollenzer 70ea16b0b4 Cleanup: remove rdsvc flags
With the previous changes, there were only used by the status
command.

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-04-24 12:26:26 +02:00
David Oberhollenzer 5f28289731 cleanup: merge runsvc back into initd
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-04-24 12:09:18 +02:00
David Oberhollenzer 0975ed0fb7 runsvc: make sure we close all fds before running a service
Just in case initd leaks anything. Also, the service has no
buisness writing all over /dev/console. It's a system service, it
better use syslog or its own internal logging service.

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-04-06 15:55:47 +02:00
David Oberhollenzer 9b43890591 cleanup: simplify runsvc environment config parsing
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-04-06 15:44:15 +02:00
David Oberhollenzer 87a524d931 cleanup: delete remains of libutil
- exec_t belongs to service.h, the main place where it is used/needed
 - code for executing exec_t is moved to runsvc for the same reason
 - what is left are NORETURN and ARRAY_SIZE
   - the former can be replaced with direct attribute usage since
     the only relevant compilers all support the attribute.
   - the later is only used in 3 places and can be trivially replaced
     with direct usage of sizeof().

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-03-31 18:19:27 +02:00
David Oberhollenzer c3d14cbfa8 cleanup: init status response
- rename init_status_response_t to init_status_t
 - merge code for handling it
 - fix memory leak in status command

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-29 21:00:53 +01:00
David Oberhollenzer 028394b8a5 Add service configuration reloading
This commit add the ability to initd to reload the service configuration
while running. The new configuration is merged with the existing one as
follows:

For each target:
 - If the existing service list is not NULL, we have not started that
   target yet. Simply replace it with the new list.
 - If it is NULL, the services have already been started.
    - First, remove all entries for services in that target that no
      loner exist (except from the 'running' list).
    - Second, add new services that we don't have yet. Treat them as
      recently diseased and let the user start them manualy.

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-29 21:00:53 +01:00
David Oberhollenzer 6fa0393be4 Add start/stop commands to service tool
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-28 15:32:10 +01:00
David Oberhollenzer d16d260181 Add filter argument to status request
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-27 17:48:32 +01:00
David Oberhollenzer 9fece2eb88 Add hacky utiliy that waits for the presence of some files
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-24 18:02:17 +01:00
David Oberhollenzer ec04681c4d Make service status matching fuzzier (also allow service name match)
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-21 17:11:52 +01:00
David Oberhollenzer 390175c406 cleanup runsvc: merge codepaths for execution, remove cleanup code
Simply execute the last entry in the list directly instead of forking and
remove the cleanup code.

If the list is empty, we return success.

If the list only has one entry, we directly execute that. No need to make a
distinction between single entry vs list anymore.

If the list is an actual list, we run it as before but execute the last one
directly. Typically, the last one is something like a daemon preceeded by
setup code. The daemon ends up directly underneath init, without a dummy
waiting runsvc stuck in the process list.

If we always do an exec, there is no point in doing cleanup. All our mapped
memory is evicted anyway. Same if we exit appruptly because of an error.

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-20 15:09:35 +01:00
David Oberhollenzer 4f1b393cee Dump more information in service status command
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-20 14:47:45 +01:00
David Oberhollenzer 1850f31d6d Seperate service loading/error loging from dumpscript command
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-19 23:53:49 +01:00
David Oberhollenzer 065d3b678d cleanup: remove broken stat ... open pattern
confused deputy is confused.

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-18 19:49:42 +01:00
David Oberhollenzer 11053ebe6a Add filtering parameters to status command
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-18 19:16:34 +01:00
David Oberhollenzer a9602ad6e0 Cleanup status reporting
- mimic format of initd
 - skip formatting if not a tty
 - distinguish exited because failed vs exited because done

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-18 18:47:20 +01:00
David Oberhollenzer 3f40c4d3ed Add status report command to service command line utility
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-18 18:42:38 +01:00
David Oberhollenzer d9a5736bdf Remove some no longer needed cruft
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-11-23 23:00:58 +01:00
David Oberhollenzer c14c3c0173 Relicense what is left of the init system under OpenBSD style ISC license
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-11-23 13:16:08 +01:00
David Oberhollenzer bf878d08dd Remove cron daemon, rewritten and split off into seperate repo
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-11-21 12:01:39 +01:00
David Oberhollenzer b864c727c8 Remove unused telinit code
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-11-04 15:33:00 +01:00
David Oberhollenzer c0e8c7e245 cleanup: let rdline_init open the file
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-11-04 15:02:11 +01:00
David Oberhollenzer 34f542b7cc Seperate init specific code from utility code
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-11-04 14:30:16 +01:00
David Oberhollenzer acd09007a1 Remove usyslogd/klogd and syslog utility program
This is split out to a seperate package.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-11-03 19:26:00 +01:00
David Oberhollenzer 24c90b7700 Configuration parser cleanup
- Do a getline() & process in rdline instead of doing a read per character
   and feeding it through a state machine.
 - Move splitkv to rdcfg.c, the only place where it is used

Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-10-10 16:45:11 +02:00
David Oberhollenzer 33aa4cedff Update documentation
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-09-19 12:22:14 +02:00
David Oberhollenzer b9ba11b4db Add service commands to manage gcrond services
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-09-19 12:22:14 +02:00
David Oberhollenzer f38163772c Add simple cron implementation
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-09-19 12:22:14 +02:00
David Oberhollenzer 42fba964c9 Centralize/unify version string printing
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-09-01 17:22:24 +02:00
David Oberhollenzer f39aba8aa3 Add man page for service command
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-08-31 17:54:23 +02:00
David Oberhollenzer 34aff498ed Add man page for syslog command
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-08-31 10:14:06 +02:00
David Oberhollenzer b5c6e9d392 Add man page stub for shutdown
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-08-28 20:55:27 +02:00
David Oberhollenzer 2d54b32d24 Cleanup shutdown command, make reboot a symlink to shutdown
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-08-24 21:17:31 +02:00
David Oberhollenzer 95d8ddd713 Clean up service list short listing format
We already print the services in dependency order, for each target
individually. There is no need to print the depencies and the target
for each service.

In addtion, printing name and description in one line shortens the
resulting list.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-07-23 09:28:02 +02:00
David Oberhollenzer 056d3c8e64 Add output truncation flag
This commit adds a "truncate" flag that can be added to a service
description between the "tty" keyword and the path string.

If the flag is set, the output file is truncated to 0 after opening.

This probably requires some remodeling in the future as the tty keyword
no longer deals with just tty devices.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-07-22 17:57:20 +02:00
David Oberhollenzer d9f883f215 Add utility for producing syslog message from the shell
This can can be used by shell scripts to produce syslog messages,
as well as aiding in debugging the usyslogd daemon.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-06-11 19:45:42 +02:00
David Oberhollenzer bf63f78b66 Split configuration parser and utility library
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-06-09 15:32:29 +02:00
David Oberhollenzer 59731dd69b Add helper program for running services
We no longer need to keep entire scripts in init program (i.e. saving space)
and reduce the code and complexity of the init program.

The runsvc tool can later be extended to do more complex child setup, such
as configuring namespaces or seccomp without adding complexity or memory
footprint to init.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-04-22 13:41:18 +02:00
David Oberhollenzer 720220a3c3 Add flags to selectively skip fields in service files
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-04-22 13:41:18 +02:00
David Oberhollenzer 6cf0a254cd Build system and directory structure cleanup
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-04-12 10:28:40 +02:00
David Oberhollenzer 0a28074071 Add System V init like killall5 helper program
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-03-25 13:11:33 +02:00
David Oberhollenzer 1b3b98135e Add license headers and comments to source
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-03-24 22:50:28 +01:00
David Oberhollenzer 9a88f7da45 Initial commit
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-03-24 17:04:20 +01:00