Add --exists and --resolve to rc-service.
This commit is contained in:
parent
e30ea10e6c
commit
be1f9b0a93
@ -24,7 +24,7 @@ start()
|
|||||||
done
|
done
|
||||||
|
|
||||||
# If we have an init script for this service, continue
|
# If we have an init script for this service, continue
|
||||||
rc-service --list | grep -q "${service}" && continue
|
rc-service --exists "${service}" && continue
|
||||||
|
|
||||||
# Ensure that the users rc.conf will start us - ignore the defaults
|
# Ensure that the users rc.conf will start us - ignore the defaults
|
||||||
eval enabled=\$${svc##*/}_enable
|
eval enabled=\$${svc##*/}_enable
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd Mar 21, 2008
|
.Dd Mar 26, 2008
|
||||||
.Dt RC-SERVICE 8 SMM
|
.Dt RC-SERVICE 8 SMM
|
||||||
.Os OpenRC
|
.Os OpenRC
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -34,6 +34,12 @@
|
|||||||
.Op Ar ...
|
.Op Ar ...
|
||||||
.Nm
|
.Nm
|
||||||
.Fl l , -list
|
.Fl l , -list
|
||||||
|
.Nm
|
||||||
|
.Fl e , -exists
|
||||||
|
.Ar service
|
||||||
|
.Nm
|
||||||
|
.Fl r , -resolve
|
||||||
|
.Ar service
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
Service scripts could be in different places on different systems.
|
Service scripts could be in different places on different systems.
|
||||||
.Nm
|
.Nm
|
||||||
@ -44,7 +50,15 @@ If given the
|
|||||||
argument then
|
argument then
|
||||||
.Nm
|
.Nm
|
||||||
will list all available services.
|
will list all available services.
|
||||||
|
.Pp
|
||||||
|
.Fl -e , exists
|
||||||
|
return 0 if it can find
|
||||||
|
.Ar service ,
|
||||||
|
otherwise -1.
|
||||||
|
.Fl -r , resolve
|
||||||
|
does the same and also prints the full path of the service to stdout.
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr rc 8 ,
|
.Xr rc 8 ,
|
||||||
|
.Xr stdout 3
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
.An "Roy Marples" Aq roy@marples.name
|
.An "Roy Marples" Aq roy@marples.name
|
||||||
|
@ -43,9 +43,11 @@
|
|||||||
extern char *applet;
|
extern char *applet;
|
||||||
|
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
#define getoptstring "l" getoptstring_COMMON
|
#define getoptstring "e:lr:" getoptstring_COMMON
|
||||||
static const struct option longopts[] = {
|
static const struct option longopts[] = {
|
||||||
{ "list", 0, NULL, 'l' },
|
{ "exists", 1, NULL, 'e' },
|
||||||
|
{ "list", 0, NULL, 'l' },
|
||||||
|
{ "resolve", 1, NULL, 'r' },
|
||||||
longopts_COMMON
|
longopts_COMMON
|
||||||
};
|
};
|
||||||
static const char * const longopts_help[] = {
|
static const char * const longopts_help[] = {
|
||||||
@ -68,6 +70,12 @@ int rc_service(int argc, char **argv)
|
|||||||
longopts, (int *) 0)) != -1)
|
longopts, (int *) 0)) != -1)
|
||||||
{
|
{
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
|
case 'e':
|
||||||
|
service = rc_service_resolve(optarg);
|
||||||
|
opt = service ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
|
free(service);
|
||||||
|
return opt;
|
||||||
|
/* NOTREACHED */
|
||||||
case 'l':
|
case 'l':
|
||||||
list = rc_services_in_runlevel(NULL);
|
list = rc_services_in_runlevel(NULL);
|
||||||
if (! list)
|
if (! list)
|
||||||
@ -78,6 +86,14 @@ int rc_service(int argc, char **argv)
|
|||||||
rc_stringlist_free(list);
|
rc_stringlist_free(list);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
|
case 'r':
|
||||||
|
service = rc_service_resolve(optarg);
|
||||||
|
if (!service)
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
printf("%s\n", service);
|
||||||
|
free(service);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
/* NOTREACHED */
|
||||||
|
|
||||||
case_RC_COMMON_GETOPT
|
case_RC_COMMON_GETOPT
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user