diff --git a/src/include/66/service.h b/src/include/66/service.h index 226c2e3838366062970e2bf859285f02c071b037..63af538c70cf4f6c2790be91bc93c9d73d6270fe 100644 --- a/src/include/66/service.h +++ b/src/include/66/service.h @@ -315,7 +315,7 @@ extern int service_resolve_read_cdb(cdb *c, resolve_service_t *res) ; extern void service_resolve_write(resolve_service_t *res) ; extern void service_resolve_write_tmp(resolve_service_t *res, char const *dst, uint8_t force) ; extern int service_resolve_write_cdb(cdbmaker *c, resolve_service_t *sres) ; -extern void service_enable_disable(graph_t *g, unsigned int idx, resolve_service_t *ares, unsigned int areslen, uint8_t action, visit_t *visit) ; +extern void service_enable_disable(graph_t *g, unsigned int idx, resolve_service_t *ares, unsigned int areslen, uint8_t action, visit_t *visit, uint8_t propagate) ; /* avoid circular dependencies by prototyping the ss_state_t instead * of calling the state.h header file*/ typedef struct ss_state_s ss_state_t, *ss_state_t_ref ; diff --git a/src/include/66/ssexec.h b/src/include/66/ssexec.h index d00cc13f616d2cbf582a5218e0587d40a4d5b18f..d1ddb69f7e9dad259008241111f980ffc9b26708 100644 --- a/src/include/66/ssexec.h +++ b/src/include/66/ssexec.h @@ -231,9 +231,9 @@ extern char const *help_halt ; #define OPTS_PARSE_LEN (sizeof OPTS_PARSE - 1) #define OPTS_INIT "h" #define OPTS_INIT_LEN (sizeof OPTS_INIT - 1) -#define OPTS_ENABLE "hfSI" +#define OPTS_ENABLE "hfSIP" #define OPTS_ENABLE_LEN (sizeof OPTS_ENABLE - 1) -#define OPTS_DISABLE "hSFR" +#define OPTS_DISABLE "hSFRP" #define OPTS_DISABLE_LEN (sizeof OPTS_DISABLE - 1) #define OPTS_START "hP" #define OPTS_START_LEN (sizeof OPTS_START - 1) diff --git a/src/lib66/exec/ssexec_disable.c b/src/lib66/exec/ssexec_disable.c index 21f286fc9f140e9d731a21a7554c00986f347eeb..0c07eaa7ccfe33dd701bb94eb843ac337c2eabec 100644 --- a/src/lib66/exec/ssexec_disable.c +++ b/src/lib66/exec/ssexec_disable.c @@ -37,7 +37,7 @@ int ssexec_disable(int argc, char const *const *argv, ssexec_t *info) log_flow() ; uint32_t flag = 0 ; - uint8_t stop = 0 ; + uint8_t stop = 0, propagate = 1 ; int n = 0, e = 1 ; size_t pos = 0 ; graph_t graph = GRAPH_ZERO ; @@ -81,6 +81,11 @@ int ssexec_disable(int argc, char const *const *argv, ssexec_t *info) log_1_warn("options -F is deprecated -- use instead 66 remove <service>") ; break ; + case 'P' : + + propagate = 0 ; + break ; + default : log_usage(info->usage, "\n", info->help) ; } @@ -105,20 +110,27 @@ int ssexec_disable(int argc, char const *const *argv, ssexec_t *info) if (aresid < 0) log_die(LOG_EXIT_USER, "service: ", argv[n], " not available -- did you parse it?") ; - service_enable_disable(&graph, aresid, ares, areslen, 0, visit) ; + service_enable_disable(&graph, aresid, ares, areslen, 0, visit, propagate) ; if (!sastr_add_string(&sa, argv[n])) log_dieu(LOG_EXIT_SYS, "add string") ; + } if (stop && sa.len) { size_t len = sastr_nelement(&sa) ; - int nargc = 2 + len ; + int nargc = 3 + len ; char const *prog = PROG ; char const *newargv[nargc] ; unsigned int m = 0 ; + char const *help = info->help ; + char const *usage = info->usage ; + + info->help = help_stop ; + info->usage = usage_stop ; + newargv[m++] = "stop" ; newargv[m++] = "-u" ; FOREACH_SASTR(&sa, pos) @@ -126,8 +138,12 @@ int ssexec_disable(int argc, char const *const *argv, ssexec_t *info) newargv[m] = 0 ; PROG = "stop" ; - e = ssexec_stop(nargc, newargv, info) ; + e = ssexec_stop(m, newargv, info) ; PROG = prog ; + + info->help = help ; + info->usage = usage ; + goto end ; } e = 0 ; diff --git a/src/lib66/exec/ssexec_enable.c b/src/lib66/exec/ssexec_enable.c index 225b48598ddf5ee83ce9604a865c6e4e0dca6c4e..382ed068d88ebc1bf5921c2e5c7e767d16e997fe 100644 --- a/src/lib66/exec/ssexec_enable.c +++ b/src/lib66/exec/ssexec_enable.c @@ -58,7 +58,7 @@ int ssexec_enable(int argc, char const *const *argv, ssexec_t *info) log_flow() ; uint32_t flag = 0 ; - uint8_t force = 0, conf = 0, start = 0 ; + uint8_t force = 0, conf = 0, start = 0, propagate = 1 ; int n = 0, e = 1 ; size_t pos = 0 ; graph_t graph = GRAPH_ZERO ; @@ -105,6 +105,11 @@ int ssexec_enable(int argc, char const *const *argv, ssexec_t *info) start = 1 ; break ; + case 'P' : + + propagate = 0 ; + break ; + default : log_usage(info->usage, "\n", info->help) ; } @@ -132,7 +137,8 @@ int ssexec_enable(int argc, char const *const *argv, ssexec_t *info) if (aresid < 0) log_die(LOG_EXIT_USER, "service: ", argv[n], " not available -- did you parse it?") ; - service_enable_disable(&graph, aresid, ares, areslen, 1, visit) ; + if (propagate) + service_enable_disable(&graph, aresid, ares, areslen, 1, visit, propagate) ; if (!sastr_add_string(&sa, argv[n])) log_dieu(LOG_EXIT_SYS, "add string") ; @@ -141,19 +147,29 @@ int ssexec_enable(int argc, char const *const *argv, ssexec_t *info) if (start && sa.len) { size_t len = sastr_nelement(&sa) ; - int nargc = 1 + len ; + int nargc = 2 + len ; char const *prog = PROG ; char const *newargv[nargc] ; unsigned int m = 0 ; + char const *help = info->help ; + char const *usage = info->usage ; + + info->help = help_start ; + info->usage = usage_start ; + newargv[m++] = "start" ; FOREACH_SASTR(&sa, pos) newargv[m++] = sa.s + pos ; newargv[m] = 0 ; PROG = "start" ; - e = ssexec_start(nargc, newargv, info) ; + e = ssexec_start(m, newargv, info) ; PROG = prog ; + + info->help = help ; + info->usage = usage ; + goto end ; } e = 0 ; diff --git a/src/lib66/service/service_enable_disable.c b/src/lib66/service/service_enable_disable.c index 4d2187116d64c7a1273b1094a883033f6ed2c606..653cf3da51c1afc6cad0e2806ddbbd4999ddcf12 100644 --- a/src/lib66/service/service_enable_disable.c +++ b/src/lib66/service/service_enable_disable.c @@ -26,7 +26,7 @@ #include <66/utils.h> #include <66/enum.h> -static void service_enable_disable_deps(graph_t *g, unsigned int idx, resolve_service_t *ares, unsigned int areslen, uint8_t action, visit_t *visit) +static void service_enable_disable_deps(graph_t *g, unsigned int idx, resolve_service_t *ares, unsigned int areslen, uint8_t action, visit_t *visit, uint8_t propagate) { log_flow() ; @@ -47,7 +47,7 @@ static void service_enable_disable_deps(graph_t *g, unsigned int idx, resolve_se log_die(LOG_EXIT_USER, "service: ", name, " not available -- did you parse it?") ; if (visit[aresid] == VISIT_WHITE) - service_enable_disable(g, aresid, ares, areslen, action, visit) ; + service_enable_disable(g, aresid, ares, areslen, action, visit, propagate) ; } } @@ -56,7 +56,7 @@ static void service_enable_disable_deps(graph_t *g, unsigned int idx, resolve_se /** @action -> 0 disable * @action -> 1 enable */ -void service_enable_disable(graph_t *g, unsigned int idx, resolve_service_t *ares, unsigned int areslen, uint8_t action, visit_t *visit) +void service_enable_disable(graph_t *g, unsigned int idx, resolve_service_t *ares, unsigned int areslen, uint8_t action, visit_t *visit, uint8_t propagate) { log_flow() ; @@ -67,7 +67,8 @@ void service_enable_disable(graph_t *g, unsigned int idx, resolve_service_t *are if (!state_messenger(res, STATE_FLAGS_ISENABLED, !action ? STATE_FLAGS_FALSE : STATE_FLAGS_TRUE)) log_dieusys(LOG_EXIT_SYS, "send message to state of: ", res->sa.s + res->name) ; - service_enable_disable_deps(g, idx, ares, areslen, action, visit) ; + if (propagate) + service_enable_disable_deps(g, idx, ares, areslen, action, visit, propagate) ; /** the logger must be disabled to avoid to start it * with the 66 tree start <tree> command */ @@ -112,7 +113,7 @@ void service_enable_disable(graph_t *g, unsigned int idx, resolve_service_t *are if (!state_messenger(&ares[aresid], STATE_FLAGS_ISENABLED, !action ? STATE_FLAGS_FALSE : STATE_FLAGS_TRUE)) log_dieusys(LOG_EXIT_SYS, "send message to state of: ", res->sa.s + res->name) ; - service_enable_disable_deps(g, aresid, ares, areslen, action, visit) ; + service_enable_disable_deps(g, aresid, ares, areslen, action, visit, propagate) ; visit[aresid] = VISIT_GRAY ;