- 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.
.\" All rights reserved.
@ -34,7 +34,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd March 21, 2002
.Dd March 25, 2002
.Dt RC.SUBR 8
.Os
.Sh NAME
@ -49,9 +49,9 @@
.It
.Ic checkyesno Ar var
.It
.Ic check_pidfile Ar pidfile Ar procname
.Ic check_pidfile Ar pidfile Ar procname Op Ar interpreter
.It
.Ic check_process Ar procname
.Ic check_process Ar procname Op Ar interpreter
.It
.Ic err Ar exitval Ar message
.It
@ -63,9 +63,9 @@
.It
.Ic reverse_list Ar item Op Ar ...
.It
.Ic run_rc_command Ar arg
.Ic run_rc_command Ar argument
.It
.Ic run_rc_script Ar file Ar arg
.Ic run_rc_script Ar file Ar argument
.It
.Ic wait_for_pids Op Ar pid Op Ar ...
.It
@ -171,17 +171,36 @@ Otherwise, warn that
.Ar var
is not set correctly.
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
.Ar pidfile
for a PID, and ensures that the process with that PID
is running and its first argument matches
.Ar procname .
Prints the matching PID if successfully, otherwise nothing.
.It Ic check_process Ar procname
Prints the matching PID if successfull, otherwise nothing.
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
argument that matches
.Ar procname .
.Ar interpreter
is handled as per
.Ic check_pidfile .
.It Ic err Ar exitval Ar message
Display an error message to
.Em stderr ,
@ -245,9 +264,9 @@ prefixed by
Print the list of
.Ar items
in reverse order.
.It Ic run_rc_command Ar arg
.It Ic run_rc_command Ar argument
Run the
.Ar arg
.Ar argument
method for the current
.Xr rc.d 8
script, based on the settings of various shell variables.
@ -256,7 +275,7 @@ is extremely flexible, and allows fully functional
.Xr rc.d 8
scripts to be implemented in a small amount of shell code.
.Pp
.Ar arg
.Ar argument
is searched for in the list of supported commands, which may be one
of:
.Dl start stop restart rcvar
@ -269,20 +288,24 @@ or
is set, also allow:
.Dl status poll
.Pp
.Ar arg
.Ar argument
may have one of the following prefixes which alters its operation:
.Bl -tag -width "Prefix" -offset indent -compact
.It Sy Prefix
.Sy Operation
.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
Skip the checks for
.Sy rcvar
being set,
ignore
.Ar arg Ns Sy _precmd
returning non-zero, and ignore any of the
being set to yes,
and sets
.Sy rc_force=YES .
This ignores
.Ar argument Ns Sy _precmd
returning non-zero, and ignores any of the
.Sy required_*
tests failing .
.El
@ -303,7 +326,7 @@ to determine if this method should be run.
.It Sy command
Full path to the command.
Not required if
.Ar arg Ns Sy _cmd
.Ar argument Ns Sy _cmd
is defined for each supported keyword.
.It Sy command_args
Optional arguments and/or shell directives for
@ -406,24 +429,24 @@ as.
Comma separated list of supplementary groups to run the chrooted
.Sy command
with.
.It Ar arg Ns Sy _cmd
.It Ar argument Ns Sy _cmd
Shell commands which override the default method for
.Ar arg .
.It Ar arg Ns Sy _precmd
.Ar argument .
.It Ar argument Ns Sy _precmd
Shell commands to run just before running
.Ar arg Ns Sy _cmd
.Ar argument Ns Sy _cmd
or the default method for
.Ar arg .
.Ar argument .
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
the
.Sy required_*
checks and process (non-)existence checks.
.It Ar arg Ns Sy _postcmd
.It Ar argument Ns Sy _postcmd
Shell commands to run if running
.Ar arg Ns Sy _cmd
.Ar argument Ns Sy _cmd
or the default method for
.Ar arg
.Ar argument
returned a zero exit code.
.It Sy sig_stop
Signal to send the processes to stop in the default
@ -440,9 +463,9 @@ Defaults to
.El
.Pp
For a given method
.Ar arg ,
.Ar argument ,
if
.Ar arg Ns Sy _cmd
.Ar argument Ns Sy _cmd
is not defined, then a default method is provided by
.Sy run_rc_command :
.Bl -tag -width "argument" -offset indent
@ -497,11 +520,45 @@ This method always works, even if the appropriate
variable is set to
.Sq NO .
.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
.Ar file
with an argument of
.Ar arg ,
.Ar argument ,
and handle the return value from the script.
.Pp
Various shell variables are unset before
@ -518,9 +575,9 @@ is started:
.Li required_dirs ,
.Li required_files ,
.Li required_vars ,
.Li Ar arg Ns _cmd ,
.Li Ar arg Ns _precmd .
.Li Ar arg Ns _postcmd .
.Li Ar argument Ns _cmd ,
.Li Ar argument Ns _precmd .
.Li Ar argument Ns _postcmd .
.Ed
.Pp
The startup behaviour of