Commit Graph

184 Commits

Author SHA1 Message Date
David Oberhollenzer 5307b95b93 Cleanup: remove flag mechanism from config parser entirely
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-04-24 12:28:06 +02:00
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 9f9807d4d3 cleanup: initd: simplify and merge linux specific code into main.c
Targetting anything else than Linux isn't really relevant. All
other systems ($BSD and other Unices) are a closed ecosystem
where kernel & userspace are developed together. They don't need
something like a third party init system, so compatibillity can
be largely ignored.

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-03-31 13:09:04 +02:00
David Oberhollenzer 0d985a7430 Add RDSVC_NO_DESC flag
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-06-16 20:51:23 +02:00
David Oberhollenzer 60efd9dc33 Remove unused SOCK_FLAG_* enum
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-06-16 18:20:26 +02:00
David Oberhollenzer 1c72dd2c2f Fix remove by id
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-06-16 16:09:49 +02:00
David Oberhollenzer 2e89d32a75 Release init-0.10
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-29 21:00:53 +01:00
David Oberhollenzer c1cb8491f9 fix: actually remove started service from list
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-29 21:00:53 +01:00
David Oberhollenzer c8c0f10ce1 Keep original respawn limit
We also want this meachanism to still work for manually started
service (especially after reloading services).

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-29 21:00:53 +01:00
David Oberhollenzer be06641904 cleanup: init socket wire format
Replace array adhockery with structs and make use of the handy
endianness conversion macros.

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-29 21:00:53 +01: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 7cfe6e8458 cleanup: move init specific stuff of init socket to initd
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-29 21:00:53 +01:00
David Oberhollenzer f844c4e2c2 Update documentation
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 ba12700080 Add start/stop commands to init socket
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-28 15:32:10 +01:00
David Oberhollenzer 9e7478397a Include service ID in initsock status response
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-28 15:19:06 +01:00
David Oberhollenzer c16735414b initd: Hand out unique IDs to services
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-28 13:45:33 +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 affe9e4b88 Use fixed size integer for init socket request
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-27 17:48:32 +01:00
David Oberhollenzer 72c02308cd Fix: actually process SIGUSR1 in initd
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-25 16:32:45 +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 a6c059203b Fix warnings from gcc 8.3 + musl build
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-20 20:43:41 +01:00
David Oberhollenzer e21840cfce initd: don't start runsvc for services without exec block
First in rdsvc, tag the services that *do* have exec lines, even if we don't
read them.

Second, if a service does not have that flag set, don't try to execute it.

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-20 15:44:14 +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 40ad83dc6a initd: implement handling of socket requests
Actually process requests and send an answer to status inquiries.

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-18 18:29:02 +01:00
David Oberhollenzer 23b713c3b5 Add functions to transmit service status accross initd socket
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-18 18:29:02 +01:00
David Oberhollenzer 08f72865b2 Add init socket to initd
Create a socket if boot target is done. Close and reopen socket
if SIGUSR1 is received.

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-18 14:15:58 +01:00
David Oberhollenzer c78bbd2f73 Add helpers for initd socket
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-18 14:15:58 +01:00
David Oberhollenzer c544fcc7a3 initd: store completed services in list instead of deleting them
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-15 10:46:11 +01:00
David Oberhollenzer 5b106abaed Update e-mail address
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-14 17:18:34 +01:00
David Oberhollenzer 4ee949c1ca Release init-0.9
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-11-25 02:08:33 +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 d983a282ed Remove auto-magic release automation script
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-11-23 13:14:55 +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 dc6358b0e1 rdline: always do substitution of '%%'
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-11-13 19:11:33 +01:00
David Oberhollenzer 7ee95668ca Release init-0.8 2018-11-05 20:19:25 +01:00
David Oberhollenzer 4bcfd98764 Cleanup header dependencies
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-11-05 20:18:48 +01:00