1*e3da17ccSuwe.\" $NetBSD: service.8,v 1.6 2023/03/14 21:50:25 uwe Exp $ 204efec84Sast.\" 304efec84Sast.\" Copyright (c) 2009 Douglas Barton 404efec84Sast.\" All rights reserved. 504efec84Sast.\" 604efec84Sast.\" Redistribution and use in source and binary forms, with or without 704efec84Sast.\" modification, are permitted provided that the following conditions 804efec84Sast.\" are met: 904efec84Sast.\" 1. Redistributions of source code must retain the above copyright 1004efec84Sast.\" notice, this list of conditions and the following disclaimer. 1104efec84Sast.\" 2. Redistributions in binary form must reproduce the above copyright 1204efec84Sast.\" notice, this list of conditions and the following disclaimer in the 1304efec84Sast.\" documentation and/or other materials provided with the distribution. 1404efec84Sast.\" 1504efec84Sast.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1604efec84Sast.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1704efec84Sast.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1804efec84Sast.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1904efec84Sast.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2004efec84Sast.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2104efec84Sast.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2204efec84Sast.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2304efec84Sast.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2404efec84Sast.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2504efec84Sast.\" SUCH DAMAGE. 2604efec84Sast.\" 27c6ec2ed8Skre.Dd March 12, 2023 2804efec84Sast.Dt SERVICE 8 2904efec84Sast.Os 3004efec84Sast.Sh NAME 3104efec84Sast.Nm service 3204efec84Sast.Nd run or list system services 3304efec84Sast.Sh SYNOPSIS 3404efec84Sast.Nm 3551041dd8Swiz.Op Fl elv 3604efec84Sast.Nm 3751041dd8Swiz.Op Fl ev 38c6ec2ed8Skre.Ar rc_script_name Op Ar rc_script_name Ar ... 3904efec84Sast.Nm 40baf9344eSast.Op Fl v 4104efec84Sast.Ar rc_script_name action 4204efec84Sast.Sh DESCRIPTION 4304efec84SastThe 4404efec84Sast.Nm 4504efec84Sastcommand is a simple interface to the services startup system. 4604efec84Sast.Pp 4704efec84SastIts purpose is to list the services or invoke actions on them 4804efec84Sastas provided by the 49*e3da17ccSuwe.Xr rc.d 8 5004efec84Sastscripts. 5104efec84SastWhen used to invoke 52*e3da17ccSuwe.Pa rc.d 5304efec84Sastscripts, 5404efec84Sast.Nm 5504efec84Sastwill set the same environment that is used at boot time. 5604efec84Sast.Pp 57baf9344eSastThe options are as follows: 58*e3da17ccSuwe.Bl -tag -width Fl 5904efec84Sast.It Fl e 6004efec84SastList services that are enabled. 6104efec84SastThe list of scripts is compiled using 6204efec84Sast.Xr rcorder 8 6304efec84Sastthe same way as is done in 6404efec84Sast.Xr rc 8 ; 6504efec84Sasteach script is first checked for an 66*e3da17ccSuwe.Dv rcvar 6704efec84Sastassignment and if present, 6804efec84Sastchecked to see if it is enabled. 6904efec84SastIf one or more 7004efec84Sast.Ar rc_script_name 7104efec84Sastare specified, only those are checked. 7204efec84SastThe 7304efec84Sast.Ar rc_script_name 7404efec84Sastarguments are always specified without a path prefix. 7504efec84Sast.It Fl l 7604efec84SastList all files in 7704efec84Sast.Pa /etc/rc.d 78*e3da17ccSuwe.Po 79*e3da17ccSuwethe default of 80*e3da17ccSuwe.Ev rc_directories 81*e3da17ccSuweas defined in 82*e3da17ccSuwe.Xr rc.conf 5 83*e3da17ccSuwe.Pc . 8404efec84SastA script will be listed unless it has the 85*e3da17ccSuwe.Dv nostart 8604efec84Sastkeyword enabled. 87c6ec2ed8SkreScripts are listed in the order the 88*e3da17ccSuwe.Pa rc.d 89c6ec2ed8Skresystem runs them at system boot time. 9004efec84Sast.It Fl v 9104efec84SastReport what 92*e3da17ccSuwe.Dv rc_directories 9304efec84Sastare defined or in which directory the 94*e3da17ccSuwe.Pa rc.d 95*e3da17ccSuwescript was found when an 9604efec84Sast.Ar action 9704efec84Sastis invoked. 9804efec84Sast.El 99c6ec2ed8Skre.Pp 100c6ec2ed8SkreThe 101c6ec2ed8Skre.Fl e 102c6ec2ed8Skreand 103c6ec2ed8Skre.Fl l 104c6ec2ed8Skreoptions are mutually exclusive. 105c6ec2ed8SkreOnly one of those may be used. 10604efec84Sast.Sh ENVIRONMENT 10704efec84SastWhen used to invoke 108*e3da17ccSuwe.Pa rc.d 109*e3da17ccSuwescripts, the 11004efec84Sast.Nm 11104efec84Sastcommand sets 112*e3da17ccSuwe.Xr umask 2 11304efec84Sastto 114*e3da17ccSuwe.Li 022 , 11504efec84Sast.Ev HOME 11604efec84Sastto 11704efec84Sast.Pa / , 11804efec84Sastand 11904efec84Sast.Ev PATH 12004efec84Sastto 121*e3da17ccSuwe.Li /sbin:/bin:/usr/sbin:/usr/bin 12204efec84Sastwhich is how they are set in 12304efec84Sast.Pa /etc/rc 12451041dd8Swizat boot time. 12551041dd8SwizThe 12604efec84Sast.Ar action 12704efec84Sastis typically one of 128*e3da17ccSuwe.Cm start , 129*e3da17ccSuwe.Cm restart , 130c6ec2ed8Skreor 131*e3da17ccSuwe.Cm status , 132c6ec2ed8Skrebut can be any other argument supported by the 13304efec84Sast.Fa rc_script_name . 13404efec84Sast.Sh EXIT STATUS 135c6ec2ed8Skre.Nm 136c6ec2ed8Skreexits with status 0 when successful, 137c6ec2ed8Skrestatus 1 when 138c6ec2ed8Skre.Fl e 139c6ec2ed8Skrewas given and no enabled script was found, 140c6ec2ed8Skreor when an 141c6ec2ed8Skre.Ar action 142c6ec2ed8Skreis to be performed, but the 143c6ec2ed8Skre.Ar rc_script_name 144c6ec2ed8Skregiven does not exist, 145c6ec2ed8Skreor 146c6ec2ed8Skrestatus >1 if another error occurs. 14704efec84Sast.Sh EXAMPLES 14804efec84SastThese are typical usages of the 14904efec84Sast.Nm 15004efec84Sastcommand: 151baf9344eSast.Bd -literal 152baf9344eSast# service sshd restart 153baf9344eSastStopping sshd. 154baf9344eSastStarting sshd. 155baf9344eSast.Ed 156baf9344eSast.Bd -literal 157baf9344eSast$ service -v inetd status 158baf9344eSastinetd is located in /etc/rc.d 159baf9344eSastinetd is running as pid 1713. 160baf9344eSast.Ed 161baf9344eSast.Bd -literal 162c6ec2ed8Skre$ if service -e inetd >/dev/null; then echo inetd is enabled; fi 163c6ec2ed8Skreinetd is enabled 164c6ec2ed8Skre.Ed 165c6ec2ed8Skre.Bd -literal 166c6ec2ed8Skre$ if service -e foobar >/dev/null; then echo foobar is enabled; fi 167c6ec2ed8Skre.Ed 168c6ec2ed8Skre.Bd -literal 169baf9344eSast$ service -ve ccd motd hostapd my_pkg 170baf9344eSastrc_directories is /etc/rc.d /usr/pkg/etc/rc.d 171baf9344eSast/etc/rc.d/ccd 172baf9344eSast/usr/pkg/etc/rc.d/my_pkg 173baf9344eSast/etc/rc.d/motd 174baf9344eSast.Ed 17504efec84Sast.Pp 17604efec84SastIn the last example, 17704efec84Sast.Xr hostapd 8 17804efec84Sastwas apparently left disabled and the additional directory 17904efec84Sast.Pa /usr/pkg/etc/rc.d 18004efec84Sastwas configured by redefining the variable 181*e3da17ccSuwe.Dv rc_directories 18204efec84Sastin 18351041dd8Swiz.Pa rc.conf ; 18451041dd8Swizfurther, 185*e3da17ccSuwe.Li my_pkg=yes 18604efec84Sastmust have also been set. 18704efec84Sast.Sh SEE ALSO 18804efec84Sast.Xr rc.conf 5 , 18904efec84Sast.Xr rc 8 , 19004efec84Sast.Xr rcorder 8 19104efec84Sast.Sh HISTORY 19204efec84SastThe 19304efec84Sast.Nm 19404efec84Sastutility first appeared in 19504efec84Sast.Nx 7.0 . 19604efec84Sast.Sh AUTHORS 19751041dd8Swiz.An -nosplit 19804efec84SastWritten for 19904efec84Sast.Fx 20004efec84Sastby 20104efec84Sast.An Douglas Barton Aq Mt dougb@FreeBSD.org . 20204efec84Sast.Pp 20304efec84SastAdapted and extended to 20404efec84Sast.Nx 20504efec84Sastby 20604efec84Sast.An Adrian Steinmann Aq Mt ast@marabu.ch . 207