207 lines
4.5 KiB
Groff
207 lines
4.5 KiB
Groff
.\" $NetBSD: service.8,v 1.6 2023/03/14 21:50:25 uwe Exp $
|
|
.\"
|
|
.\" Copyright (c) 2009 Douglas Barton
|
|
.\" All rights reserved.
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
.\" SUCH DAMAGE.
|
|
.\"
|
|
.Dd March 12, 2023
|
|
.Dt SERVICE 8
|
|
.Os
|
|
.Sh NAME
|
|
.Nm service
|
|
.Nd run or list system services
|
|
.Sh SYNOPSIS
|
|
.Nm
|
|
.Op Fl elv
|
|
.Nm
|
|
.Op Fl ev
|
|
.Ar rc_script_name Op Ar rc_script_name Ar ...
|
|
.Nm
|
|
.Op Fl v
|
|
.Ar rc_script_name action
|
|
.Sh DESCRIPTION
|
|
The
|
|
.Nm
|
|
command is a simple interface to the services startup system.
|
|
.Pp
|
|
Its purpose is to list the services or invoke actions on them
|
|
as provided by the
|
|
.Xr rc.d 8
|
|
scripts.
|
|
When used to invoke
|
|
.Pa rc.d
|
|
scripts,
|
|
.Nm
|
|
will set the same environment that is used at boot time.
|
|
.Pp
|
|
The options are as follows:
|
|
.Bl -tag -width Fl
|
|
.It Fl e
|
|
List services that are enabled.
|
|
The list of scripts is compiled using
|
|
.Xr rcorder 8
|
|
the same way as is done in
|
|
.Xr rc 8 ;
|
|
each script is first checked for an
|
|
.Dv rcvar
|
|
assignment and if present,
|
|
checked to see if it is enabled.
|
|
If one or more
|
|
.Ar rc_script_name
|
|
are specified, only those are checked.
|
|
The
|
|
.Ar rc_script_name
|
|
arguments are always specified without a path prefix.
|
|
.It Fl l
|
|
List all files in
|
|
.Pa /etc/rc.d
|
|
.Po
|
|
the default of
|
|
.Ev rc_directories
|
|
as defined in
|
|
.Xr rc.conf 5
|
|
.Pc .
|
|
A script will be listed unless it has the
|
|
.Dv nostart
|
|
keyword enabled.
|
|
Scripts are listed in the order the
|
|
.Pa rc.d
|
|
system runs them at system boot time.
|
|
.It Fl v
|
|
Report what
|
|
.Dv rc_directories
|
|
are defined or in which directory the
|
|
.Pa rc.d
|
|
script was found when an
|
|
.Ar action
|
|
is invoked.
|
|
.El
|
|
.Pp
|
|
The
|
|
.Fl e
|
|
and
|
|
.Fl l
|
|
options are mutually exclusive.
|
|
Only one of those may be used.
|
|
.Sh ENVIRONMENT
|
|
When used to invoke
|
|
.Pa rc.d
|
|
scripts, the
|
|
.Nm
|
|
command sets
|
|
.Xr umask 2
|
|
to
|
|
.Li 022 ,
|
|
.Ev HOME
|
|
to
|
|
.Pa / ,
|
|
and
|
|
.Ev PATH
|
|
to
|
|
.Li /sbin:/bin:/usr/sbin:/usr/bin
|
|
which is how they are set in
|
|
.Pa /etc/rc
|
|
at boot time.
|
|
The
|
|
.Ar action
|
|
is typically one of
|
|
.Cm start ,
|
|
.Cm restart ,
|
|
or
|
|
.Cm status ,
|
|
but can be any other argument supported by the
|
|
.Fa rc_script_name .
|
|
.Sh EXIT STATUS
|
|
.Nm
|
|
exits with status 0 when successful,
|
|
status 1 when
|
|
.Fl e
|
|
was given and no enabled script was found,
|
|
or when an
|
|
.Ar action
|
|
is to be performed, but the
|
|
.Ar rc_script_name
|
|
given does not exist,
|
|
or
|
|
status >1 if another error occurs.
|
|
.Sh EXAMPLES
|
|
These are typical usages of the
|
|
.Nm
|
|
command:
|
|
.Bd -literal
|
|
# service sshd restart
|
|
Stopping sshd.
|
|
Starting sshd.
|
|
.Ed
|
|
.Bd -literal
|
|
$ service -v inetd status
|
|
inetd is located in /etc/rc.d
|
|
inetd is running as pid 1713.
|
|
.Ed
|
|
.Bd -literal
|
|
$ if service -e inetd >/dev/null; then echo inetd is enabled; fi
|
|
inetd is enabled
|
|
.Ed
|
|
.Bd -literal
|
|
$ if service -e foobar >/dev/null; then echo foobar is enabled; fi
|
|
.Ed
|
|
.Bd -literal
|
|
$ service -ve ccd motd hostapd my_pkg
|
|
rc_directories is /etc/rc.d /usr/pkg/etc/rc.d
|
|
/etc/rc.d/ccd
|
|
/usr/pkg/etc/rc.d/my_pkg
|
|
/etc/rc.d/motd
|
|
.Ed
|
|
.Pp
|
|
In the last example,
|
|
.Xr hostapd 8
|
|
was apparently left disabled and the additional directory
|
|
.Pa /usr/pkg/etc/rc.d
|
|
was configured by redefining the variable
|
|
.Dv rc_directories
|
|
in
|
|
.Pa rc.conf ;
|
|
further,
|
|
.Li my_pkg=yes
|
|
must have also been set.
|
|
.Sh SEE ALSO
|
|
.Xr rc.conf 5 ,
|
|
.Xr rc 8 ,
|
|
.Xr rcorder 8
|
|
.Sh HISTORY
|
|
The
|
|
.Nm
|
|
utility first appeared in
|
|
.Nx 7.0 .
|
|
.Sh AUTHORS
|
|
.An -nosplit
|
|
Written for
|
|
.Fx
|
|
by
|
|
.An Douglas Barton Aq Mt dougb@FreeBSD.org .
|
|
.Pp
|
|
Adapted and extended to
|
|
.Nx
|
|
by
|
|
.An Adrian Steinmann Aq Mt ast@marabu.ch .
|