diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/s6-frontend/deps-exe/s6-frontend | 1 | ||||
| -rw-r--r-- | src/s6-frontend/repository.help.txt | 9 | ||||
| -rw-r--r-- | src/s6-frontend/repository_check.c | 53 | ||||
| -rw-r--r-- | src/s6-frontend/s6-frontend-internal.h | 2 | ||||
| -rw-r--r-- | src/s6-frontend/s6.c | 6 |
5 files changed, 67 insertions, 4 deletions
diff --git a/src/s6-frontend/deps-exe/s6-frontend b/src/s6-frontend/deps-exe/s6-frontend index 14038f5..9f08747 100644 --- a/src/s6-frontend/deps-exe/s6-frontend +++ b/src/s6-frontend/deps-exe/s6-frontend @@ -14,6 +14,7 @@ process_restart.o process_startstop.o process_status.o repository.o +repository_check.o repository_help.o repository_init.o repository_list.o diff --git a/src/s6-frontend/repository.help.txt b/src/s6-frontend/repository.help.txt index 7a07296..3a9ee1e 100644 --- a/src/s6-frontend/repository.help.txt +++ b/src/s6-frontend/repository.help.txt @@ -5,6 +5,8 @@ Subcommands: init initialize a service repository sync synchronize repository with stores list list names of saved service sets + check check all sets and fix inconsistencies + s6 repository init options: -f --force Overwrite existing repository @@ -16,3 +18,10 @@ s6 repository sync options: s6 repository list options: none +s6 repository check options: + -E --no-force-essential do not allow manual changes to essential services (default) + -e --force-essential allow manual changes to essential services + -f --fix try to fix inconsistencies automatically + -d --down fix by disabling or masking services if necessary (default) + -u --up fix by enabling services if necessary + diff --git a/src/s6-frontend/repository_check.c b/src/s6-frontend/repository_check.c new file mode 100644 index 0000000..a0e7737 --- /dev/null +++ b/src/s6-frontend/repository_check.c @@ -0,0 +1,53 @@ +/* ISC license. */ + +#include <skalibs/uint64.h> +#include <skalibs/types.h> +#include <skalibs/envexec.h> + +#include <execline/config.h> + +#include <s6-rc/config.h> + +#include <s6-frontend/config.h> +#include "s6-frontend-internal.h" + +enum golb_e +{ + GOLB_FIXUP = 0x01, + GOLB_FORCE_ESSENTIAL = 0x02, + GOLB_FIX = 0x04, +} ; + +void repository_check (char const *const *argv) +{ + static gol_bool const rgolb[] = + { + { .so = 'E', .lo = "no-force-essential", .clear = GOLB_FORCE_ESSENTIAL, .set = 0 }, + { .so = 'e', .lo = "force-essential", .clear = 0, .set = GOLB_FORCE_ESSENTIAL }, + { .so = 'd', .lo = "down", .clear = GOLB_FIXUP, .set = 0 }, + { .so = 'u', .lo = "up", .clear = 0, .set = GOLB_FIXUP }, + { .so = 'f', .lo = "fix", .clear = 0, .set = GOLB_FIX }, + } ; + uint64_t wgolb = 0 ; + unsigned int m = 0 ; + char const *newargv[9] ; + char fmtv[UINT_FMT] = " " ; + + argv += gol_argv(argv, rgolb, 4, 0, 0, &wgolb, 0) ; + + newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-set-fix" ; + if (g->verbosity != 1) + { + fmtv[uint_fmt(fmtv, g->verbosity)] = 0 ; + newargv[m++] = "-v" ; + newargv[m++] = fmtv ; + } + newargv[m++] = "-r" ; + newargv[m++] = g->dirs.repo ; + newargv[m++] = wgolb & GOLB_FORCE_ESSENTIAL ? "--force-essential" : "--no-force-essential" ; + newargv[m++] = wgolb & GOLB_FIXUP ? "--fix-up" : "--fix-down" ; + if (!(wgolb & GOLB_FIX)) newargv[m++] = "--dry-run" ; + newargv[m++] = 0 ; + + xmexec_n(newargv, cleanup_modif.s, cleanup_modif.len, cleanup_modif.n) ; +} diff --git a/src/s6-frontend/s6-frontend-internal.h b/src/s6-frontend/s6-frontend-internal.h index ddd3b69..fdacb2b 100644 --- a/src/s6-frontend/s6-frontend-internal.h +++ b/src/s6-frontend/s6-frontend-internal.h @@ -61,6 +61,8 @@ extern void repository_init (char const *const *) gccattr_noreturn ; extern void repository_sync (char const *const *) gccattr_noreturn ; extern void repository_list (char const *const *) gccattr_noreturn ; +extern void repository_check (char const *const *) gccattr_noreturn ; + /* set */ diff --git a/src/s6-frontend/s6.c b/src/s6-frontend/s6.c index f19fd56..8777b8d 100644 --- a/src/s6-frontend/s6.c +++ b/src/s6-frontend/s6.c @@ -2,9 +2,7 @@ #include <stdlib.h> -#include <skalibs/prog.h> -#include <skalibs/strerr.h> -#include <skalibs/exec.h> +#include <skalibs/envexec.h> #include <execline/config.h> @@ -24,7 +22,7 @@ int main (int argc, char const *const *argv) newargv[m++] = "-I" ; newargv[m++] = "--" ; newargv[m++] = conffile ; - newargv[m++] = S6_FRONTEND_BINPREFIX "s6-frontend" ; + newargv[m++] = S6_FRONTEND_LIBEXECPREFIX "s6-frontend" ; while (argc--) newargv[m++] = *argv++ ; newargv[m++] = 0 ; xexec(newargv) ; |
