rc-service: add a --dry-run option

This is for #225.
This commit is contained in:
William Hubbs 2018-05-14 19:00:04 -05:00
parent 3c53680018
commit a7f475ca04
2 changed files with 12 additions and 1 deletions

View File

@ -35,6 +35,9 @@
.Fl e , -exists
.Ar service
.Nm
.Fl Z , -dry-run
.Ar service
.Nm
.Fl l , -list
.Nm
.Fl r , -resolve
@ -68,6 +71,9 @@ return 0 if it can find
otherwise -1.
.Fl r , -resolve
does the same and also prints the full path of the service to stdout.
.Pp
.Fl Z , -dry-run
prints out the commands it would execute rather than executing them.
.Sh SEE ALSO
.Xr openrc 8 ,
.Xr stdout 3

View File

@ -29,7 +29,7 @@
const char *applet = NULL;
const char *extraopts = NULL;
const char *getoptstring = "ce:ilr:IN" getoptstring_COMMON;
const char *getoptstring = "ce:ilr:INZ" getoptstring_COMMON;
const struct option longopts[] = {
{ "exists", 1, NULL, 'e' },
{ "ifcrashed", 0, NULL, 'c' },
@ -38,6 +38,7 @@ const struct option longopts[] = {
{ "ifnotstarted", 0, NULL, 'N' },
{ "list", 0, NULL, 'l' },
{ "resolve", 1, NULL, 'r' },
{ "dry-run", 0, NULL, 'Z' },
longopts_COMMON
};
const char * const longopts_help[] = {
@ -48,6 +49,7 @@ const char * const longopts_help[] = {
"if the service is not started then run the command",
"list all available services",
"resolve the service name to an init script",
"dry run (show what would happen)",
longopts_help_COMMON
};
const char *usagestring = "" \
@ -112,6 +114,9 @@ int main(int argc, char **argv)
free(service);
return EXIT_SUCCESS;
/* NOTREACHED */
case 'Z':
setenv("IN_DRYRUN", "yes", 1);
break;
case_RC_COMMON_GETOPT
}