mirror of
https://github.com/troglobit/finit.git
synced 2026-10-29 12:40:44 +00:00
Disable conditions for some non-oneshot (runtime) hooks
The SVC_RECONF, SVC_LOST, SVC_START, and RUNLEVEL_CHANGE hooks are not
one-shot, they are also not regular conditions since there exist no
mechanism to reset them from flux.
One idea was to turn them into actions, but the lost + start hooks need
to be called multiple times per trigger, e.g. `initctl reload`, which
turned out to be non-trivial to implement right now.
Therefore, for (at least) the Finit v3.1 release these conditions have
been disabled ("nop") and ignored by Finit. Only actual C-style plugins
will be called.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
8ef216af62
commit
1017e7b8e5
3 files changed
+28
-6
No files matched your search
+12
-1
@@ -149,6 +149,9 @@ static void cond_update(const char *name)
|
|||||||
void cond_set(const char *name)
|
void cond_set(const char *name)
|
||||||
{
|
{
|
||||||
_d("%s", name);
|
_d("%s", name);
|
||||||
|
if (string_compare(name, "nop"))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!cond_set_path(cond_path(name), COND_ON))
|
if (!cond_set_path(cond_path(name), COND_ON))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -157,9 +160,14 @@ void cond_set(const char *name)
|
|||||||
|
|
||||||
void cond_set_oneshot(const char *name)
|
void cond_set_oneshot(const char *name)
|
||||||
{
|
{
|
||||||
const char *path = cond_path(name);
|
const char *path;
|
||||||
|
|
||||||
|
if (string_compare(name, "nop"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
path = cond_path(name);
|
||||||
_d("s => %s", name, path);
|
_d("s => %s", name, path);
|
||||||
|
|
||||||
if (cond_checkpath(path))
|
if (cond_checkpath(path))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -170,6 +178,9 @@ void cond_set_oneshot(const char *name)
|
|||||||
void cond_clear(const char *name)
|
void cond_clear(const char *name)
|
||||||
{
|
{
|
||||||
_d("%s", name);
|
_d("%s", name);
|
||||||
|
if (string_compare(name, "nop"))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!cond_set_path(cond_path(name), COND_OFF))
|
if (!cond_set_path(cond_path(name), COND_OFF))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
|
|
||||||
#define COND_PATH _PATH_VARRUN "finit/cond"
|
#define COND_PATH _PATH_VARRUN "finit/cond"
|
||||||
#define COND_SVC_PATH COND_PATH "/svc/"
|
|
||||||
#define COND_RECONF COND_PATH "/reconf"
|
#define COND_RECONF COND_PATH "/reconf"
|
||||||
|
|
||||||
typedef enum cond_state {
|
typedef enum cond_state {
|
||||||
|
|||||||
+16
-4
@@ -55,6 +55,18 @@
|
|||||||
* Predefined hook points and corresponding conditions in Finit,
|
* Predefined hook points and corresponding conditions in Finit,
|
||||||
* for use by plugins and scripts. Recommended to use the task
|
* for use by plugins and scripts. Recommended to use the task
|
||||||
* or run stanzas: task <hook/mount/error> /bin/rescue.sh
|
* or run stanzas: task <hook/mount/error> /bin/rescue.sh
|
||||||
|
*
|
||||||
|
* Some of the below hooks cannot (currently) be realized as conditions.
|
||||||
|
* The idea was to rename them action scripts, with optional argument,
|
||||||
|
* according to the following scheme:
|
||||||
|
*
|
||||||
|
* - HOOK_SVC_RECONF :: action/svc/reconf
|
||||||
|
* - HOOK_SVC_LOST :: action/svc/lost
|
||||||
|
* - HOOK_SVC_START :: action/svc/start
|
||||||
|
* - HOOK_RUNLEVEL_CHANGE :: action/sys/runlevel
|
||||||
|
*
|
||||||
|
* However, the implementation did not turn out to be stable enough for
|
||||||
|
* general release, so it was pulled.
|
||||||
*/
|
*/
|
||||||
#define HOOK_TYPES { \
|
#define HOOK_TYPES { \
|
||||||
/* Bootstrap hooks, runlevel [S] */ \
|
/* Bootstrap hooks, runlevel [S] */ \
|
||||||
@@ -67,10 +79,10 @@
|
|||||||
CHOOSE(HOOK_SYSTEM_UP, "hook/sys/up"), \
|
CHOOSE(HOOK_SYSTEM_UP, "hook/sys/up"), \
|
||||||
\
|
\
|
||||||
/* Runtime hooks, runlevel [S1-9] */ \
|
/* Runtime hooks, runlevel [S1-9] */ \
|
||||||
CHOOSE(HOOK_SVC_RECONF, "hook/svc/reconf"), \
|
CHOOSE(HOOK_SVC_RECONF, "nop"), \
|
||||||
CHOOSE(HOOK_SVC_LOST, "hook/svc/lost"), \
|
CHOOSE(HOOK_SVC_LOST, "nop"), \
|
||||||
CHOOSE(HOOK_SVC_START, "hook/svc/start"), \
|
CHOOSE(HOOK_SVC_START, "nop"), \
|
||||||
CHOOSE(HOOK_RUNLEVEL_CHANGE, "hook/sys/runlevel"), \
|
CHOOSE(HOOK_RUNLEVEL_CHANGE, "nop"), \
|
||||||
\
|
\
|
||||||
/* Shutdown hooks, runlevel [06] */ \
|
/* Shutdown hooks, runlevel [06] */ \
|
||||||
CHOOSE(HOOK_SHUTDOWN, "hook/sys/shutdown"), \
|
CHOOSE(HOOK_SHUTDOWN, "hook/sys/shutdown"), \
|
||||||
|
|||||||
Reference in new issue
Block a user