- document optional "interpreter" argument to check_pidfile() and

check_process()
- document rc_* variables available in method and after run_rc_command()
  completes
This commit is contained in:
lukem 2002-03-24 15:32:59 +00:00
parent bbee4277ca
commit ee821504dd
1 changed files with 91 additions and 34 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: rc.subr.8,v 1.5 2002/03/21 12:29:18 lukem Exp $ .\" $NetBSD: rc.subr.8,v 1.6 2002/03/24 15:32:59 lukem Exp $
.\" .\"
.\" Copyright (c) 2002 The NetBSD Foundation, Inc. .\" Copyright (c) 2002 The NetBSD Foundation, Inc.
.\" All rights reserved. .\" All rights reserved.
@ -34,7 +34,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE. .\" POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.Dd March 21, 2002 .Dd March 25, 2002
.Dt RC.SUBR 8 .Dt RC.SUBR 8
.Os .Os
.Sh NAME .Sh NAME
@ -49,9 +49,9 @@
.It .It
.Ic checkyesno Ar var .Ic checkyesno Ar var
.It .It
.Ic check_pidfile Ar pidfile Ar procname .Ic check_pidfile Ar pidfile Ar procname Op Ar interpreter
.It .It
.Ic check_process Ar procname .Ic check_process Ar procname Op Ar interpreter
.It .It
.Ic err Ar exitval Ar message .Ic err Ar exitval Ar message
.It .It
@ -63,9 +63,9 @@
.It .It
.Ic reverse_list Ar item Op Ar ... .Ic reverse_list Ar item Op Ar ...
.It .It
.Ic run_rc_command Ar arg .Ic run_rc_command Ar argument
.It .It
.Ic run_rc_script Ar file Ar arg .Ic run_rc_script Ar file Ar argument
.It .It
.Ic wait_for_pids Op Ar pid Op Ar ... .Ic wait_for_pids Op Ar pid Op Ar ...
.It .It
@ -171,17 +171,36 @@ Otherwise, warn that
.Ar var .Ar var
is not set correctly. is not set correctly.
The values are case insensitive. The values are case insensitive.
.It Ic check_pidfile Ar pidfile Ar procname .It Xo
.Ic check_pidfile
.Ar pidfile
.Ar procname
.Op Ar interpreter
.Xc
Parses the first word of the first line of Parses the first word of the first line of
.Ar pidfile .Ar pidfile
for a PID, and ensures that the process with that PID for a PID, and ensures that the process with that PID
is running and its first argument matches is running and its first argument matches
.Ar procname . .Ar procname .
Prints the matching PID if successfully, otherwise nothing. Prints the matching PID if successfull, otherwise nothing.
.It Ic check_process Ar procname If
.Ar interpreter
is provided, parse the first line of
.Ar procname ,
ensure that the line is of the form
.Dl #! interpreter [...]
and use
.Ar interpreter
with its optional arguments and
.Ar procname
appended as the process string to search for.
.It Ic check_process Ar procname Op Ar interpreter
Prints the PIDs of any processes that are running with a first Prints the PIDs of any processes that are running with a first
argument that matches argument that matches
.Ar procname . .Ar procname .
.Ar interpreter
is handled as per
.Ic check_pidfile .
.It Ic err Ar exitval Ar message .It Ic err Ar exitval Ar message
Display an error message to Display an error message to
.Em stderr , .Em stderr ,
@ -245,9 +264,9 @@ prefixed by
Print the list of Print the list of
.Ar items .Ar items
in reverse order. in reverse order.
.It Ic run_rc_command Ar arg .It Ic run_rc_command Ar argument
Run the Run the
.Ar arg .Ar argument
method for the current method for the current
.Xr rc.d 8 .Xr rc.d 8
script, based on the settings of various shell variables. script, based on the settings of various shell variables.
@ -256,7 +275,7 @@ is extremely flexible, and allows fully functional
.Xr rc.d 8 .Xr rc.d 8
scripts to be implemented in a small amount of shell code. scripts to be implemented in a small amount of shell code.
.Pp .Pp
.Ar arg .Ar argument
is searched for in the list of supported commands, which may be one is searched for in the list of supported commands, which may be one
of: of:
.Dl start stop restart rcvar .Dl start stop restart rcvar
@ -269,20 +288,24 @@ or
is set, also allow: is set, also allow:
.Dl status poll .Dl status poll
.Pp .Pp
.Ar arg .Ar argument
may have one of the following prefixes which alters its operation: may have one of the following prefixes which alters its operation:
.Bl -tag -width "Prefix" -offset indent -compact .Bl -tag -width "Prefix" -offset indent -compact
.It Sy Prefix .It Sy Prefix
.Sy Operation .Sy Operation
.It Li fast .It Li fast
Skip the check for an existing running process. Skip the check for an existing running process,
and sets
.Sy rc_fast=YES .
.It Li force .It Li force
Skip the checks for Skip the checks for
.Sy rcvar .Sy rcvar
being set, being set to yes,
ignore and sets
.Ar arg Ns Sy _precmd .Sy rc_force=YES .
returning non-zero, and ignore any of the This ignores
.Ar argument Ns Sy _precmd
returning non-zero, and ignores any of the
.Sy required_* .Sy required_*
tests failing . tests failing .
.El .El
@ -303,7 +326,7 @@ to determine if this method should be run.
.It Sy command .It Sy command
Full path to the command. Full path to the command.
Not required if Not required if
.Ar arg Ns Sy _cmd .Ar argument Ns Sy _cmd
is defined for each supported keyword. is defined for each supported keyword.
.It Sy command_args .It Sy command_args
Optional arguments and/or shell directives for Optional arguments and/or shell directives for
@ -406,24 +429,24 @@ as.
Comma separated list of supplementary groups to run the chrooted Comma separated list of supplementary groups to run the chrooted
.Sy command .Sy command
with. with.
.It Ar arg Ns Sy _cmd .It Ar argument Ns Sy _cmd
Shell commands which override the default method for Shell commands which override the default method for
.Ar arg . .Ar argument .
.It Ar arg Ns Sy _precmd .It Ar argument Ns Sy _precmd
Shell commands to run just before running Shell commands to run just before running
.Ar arg Ns Sy _cmd .Ar argument Ns Sy _cmd
or the default method for or the default method for
.Ar arg . .Ar argument .
If this returns a non-zero exit code, the main method is not performed. If this returns a non-zero exit code, the main method is not performed.
If the default method is being executed, this check is performed after If the default method is being executed, this check is performed after
the the
.Sy required_* .Sy required_*
checks and process (non-)existence checks. checks and process (non-)existence checks.
.It Ar arg Ns Sy _postcmd .It Ar argument Ns Sy _postcmd
Shell commands to run if running Shell commands to run if running
.Ar arg Ns Sy _cmd .Ar argument Ns Sy _cmd
or the default method for or the default method for
.Ar arg .Ar argument
returned a zero exit code. returned a zero exit code.
.It Sy sig_stop .It Sy sig_stop
Signal to send the processes to stop in the default Signal to send the processes to stop in the default
@ -440,9 +463,9 @@ Defaults to
.El .El
.Pp .Pp
For a given method For a given method
.Ar arg , .Ar argument ,
if if
.Ar arg Ns Sy _cmd .Ar argument Ns Sy _cmd
is not defined, then a default method is provided by is not defined, then a default method is provided by
.Sy run_rc_command : .Sy run_rc_command :
.Bl -tag -width "argument" -offset indent .Bl -tag -width "argument" -offset indent
@ -497,11 +520,45 @@ This method always works, even if the appropriate
variable is set to variable is set to
.Sq NO . .Sq NO .
.El .El
.It Ic run_rc_script Ar file Ar arg .Pp
The following variables are available to the methods
(such as
.Ar argument Ns Sy _cmd )
as well as after
.Ic run_rc_command
has completed:
.Bl -tag -width "rc_flags" -offset indent
.It Sy rc_arg
Argument provided to
.Sy run_rc_command ,
after fast and force processing has been performed.
.It Sy rc_flags
Flasg to start the default command with.
Defaults to
.Sy ${name}_flags ,
unless overridden by the environment variable
.Sq Ev flags .
This variable may be changed by the
.Ar argument Ns Sy _precmd
method.
.It Sy rc_pid
PID of
.Sy command
(if appropriate).
.It Sy rc_fast
Not empty if
.Dq fast
prefix was used.
.It Sy rc_force
Not empty if
.Dq force
prefix was used.
.El
.It Ic run_rc_script Ar file Ar argument
Start the script Start the script
.Ar file .Ar file
with an argument of with an argument of
.Ar arg , .Ar argument ,
and handle the return value from the script. and handle the return value from the script.
.Pp .Pp
Various shell variables are unset before Various shell variables are unset before
@ -518,9 +575,9 @@ is started:
.Li required_dirs , .Li required_dirs ,
.Li required_files , .Li required_files ,
.Li required_vars , .Li required_vars ,
.Li Ar arg Ns _cmd , .Li Ar argument Ns _cmd ,
.Li Ar arg Ns _precmd . .Li Ar argument Ns _precmd .
.Li Ar arg Ns _postcmd . .Li Ar argument Ns _postcmd .
.Ed .Ed
.Pp .Pp
The startup behaviour of The startup behaviour of