Sven Mueller: init script generators
Gunnar is following up on the init script blog posts by Erich and me. First a note to Gunnar: The idea of the init scrip snippets isn’t exactly my own idea, but rather taken from a comment to one of Erich’s posts (IIRC), I don’t know the original author anymore.
Anyway, I really think that some init script generator should work. It should even be possible to fetch variables from /etc/default/<daemon-name> if needed. I’m just doing a braindump of what I have in mind for the start and stop of a daemon. I would expect a configuration file (currently I think one for each operation might be best, but INI-lookalike files might also be OK). So for the start operation, I would expect these options:
Does any init system require information that is not part of the following list? I would plan with supplying information how to:
Alright, if someone would like to see this post (or rather parts of it) on the Wiki page about an Init HackFest, please transfer it there yourself. I’m currently not able to log in, for whatever reason.
- simple daemon, uses a default config with a hardcoded path and needs no options or only static options passed:
[SIMPLE] /path/to/daemon option 1 option 2 option 3
Where I chose to name one option per line so whitespace and controll characters can be part of the options without the need to quote anything. - a bit more complicated, needs a few variables from /etc/default/daemon:
[TEMPLATED] /path/to/daemon option 1 %PARAMETER_FROM_ETC_DEFAULT% --parameter=%ANOTHER_ONE_FROM_ETC_DEFAULT%
Where the script generator would have to make sure that the parameters from /etc/default are filled in at runtime. I would expect POSIX-Shell-Scripts in /etc/default for this. - Really complex: A custom script snippet is needed which has to do some specificc tasks, like cleaning possible stable locks which had been left behind.
[SCRIPT] rm /var/lock/daemon.lck /path/to/daemon --background --and --other --options
Where the script generator would simply take this script and use it where it would otherwise generate its own code.
- [SCRIPT] like for starting the daemon
- killing by PID-file:
[PIDFILE] /path/to/pid-file
- killing by process name/executable:
[PROCESS] binary
or[PROCESS] /path/to/binary
where the generator would either only look at the name of the process (first version, no full pathname) or for a process with the given executable (from /proc/ /exec, I would expect).
Does any init system require information that is not part of the following list? I would plan with supplying information how to:
- start server in background
- start server in foreground (without the need for a terminal)
- determine wether a server runs (status)
- determine wether a server is ready to serve requests (also part of status)
- determine wether the server is installed (and able to be started)
- stop a background server
- stop a foreground server (unless specified, a simple SIGKILL to the process is assumed)
- restart foreground server (unless specified, a simple stop-start cycle is assumed)
- restart background server (unless specified, a simple stop-start cycle is assumed)
- reload config (unless specified, it is assumed that reloading doesn’t work and a restart is needed)
- reopen logs (unless specified, the “reload config” operation is assumed to do this)
- some meta information: short description, needs writeable filesystem(s) mounted, needs a certain daemon to be running already (or even: able to serve requests), enhances other daemon X and should be started before it (don’t care if X isn’t installed/configured), is enhanced by daemon Y and should be started after it (don’t care if Y isn’t installed/configured), replaces daemon Z, should only run once at startup, …
Alright, if someone would like to see this post (or rather parts of it) on the Wiki page about an Init HackFest, please transfer it there yourself. I’m currently not able to log in, for whatever reason.
