Add "ifstopped" command to runscript
Signed-off-by: Christian Ruppert <idl0r@gentoo.org>
This commit is contained in:
parent
14625346c0
commit
30a56cdb46
@ -32,6 +32,7 @@
|
|||||||
.Op Fl D , -nodeps
|
.Op Fl D , -nodeps
|
||||||
.Op Fl d , -debug
|
.Op Fl d , -debug
|
||||||
.Op Fl s , -ifstarted
|
.Op Fl s , -ifstarted
|
||||||
|
.Op Fl S , -ifstopped
|
||||||
.Op Fl Z , -dry-run
|
.Op Fl Z , -dry-run
|
||||||
.Op Ar command ...
|
.Op Ar command ...
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
@ -76,6 +77,8 @@ Set xtrace on in the shell to assist in debugging.
|
|||||||
Ignore all dependency information the service supplies.
|
Ignore all dependency information the service supplies.
|
||||||
.It Fl s , -ifstarted
|
.It Fl s , -ifstarted
|
||||||
Only run the command if the service has been started.
|
Only run the command if the service has been started.
|
||||||
|
.It Fl S , -ifstopped
|
||||||
|
Only run the command if the service has been stopped.
|
||||||
.It Fl q , -quiet
|
.It Fl q , -quiet
|
||||||
Turns off all informational output the service generates.
|
Turns off all informational output the service generates.
|
||||||
Output from any non OpenRC commands is not affected.
|
Output from any non OpenRC commands is not affected.
|
||||||
|
@ -1079,12 +1079,13 @@ service_plugable(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
#define getoptstring "dDsvl:Z" getoptstring_COMMON
|
#define getoptstring "dDsSvl:Z" getoptstring_COMMON
|
||||||
#define extraopts "stop | start | restart | describe | zap"
|
#define extraopts "stop | start | restart | describe | zap"
|
||||||
static const struct option longopts[] = {
|
static const struct option longopts[] = {
|
||||||
{ "debug", 0, NULL, 'd'},
|
{ "debug", 0, NULL, 'd'},
|
||||||
{ "dry-run", 0, NULL, 'Z'},
|
{ "dry-run", 0, NULL, 'Z'},
|
||||||
{ "ifstarted", 0, NULL, 's'},
|
{ "ifstarted", 0, NULL, 's'},
|
||||||
|
{ "ifstopped", 0, NULL, 'S'},
|
||||||
{ "nodeps", 0, NULL, 'D'},
|
{ "nodeps", 0, NULL, 'D'},
|
||||||
{ "lockfd", 1, NULL, 'l'},
|
{ "lockfd", 1, NULL, 'l'},
|
||||||
longopts_COMMON
|
longopts_COMMON
|
||||||
@ -1093,6 +1094,7 @@ static const char *const longopts_help[] = {
|
|||||||
"set xtrace when running the script",
|
"set xtrace when running the script",
|
||||||
"show what would be done",
|
"show what would be done",
|
||||||
"only run commands when started",
|
"only run commands when started",
|
||||||
|
"only run commands when stopped",
|
||||||
"ignore dependencies",
|
"ignore dependencies",
|
||||||
"fd of the exclusive lock from rc",
|
"fd of the exclusive lock from rc",
|
||||||
longopts_help_COMMON
|
longopts_help_COMMON
|
||||||
@ -1235,6 +1237,10 @@ runscript(int argc, char **argv)
|
|||||||
if (!(rc_service_state(service) & RC_SERVICE_STARTED))
|
if (!(rc_service_state(service) & RC_SERVICE_STARTED))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
break;
|
break;
|
||||||
|
case 'S':
|
||||||
|
if (!(rc_service_state(service) & RC_SERVICE_STOPPED))
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
deps = false;
|
deps = false;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user