]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man8/rc.subr.8
pmap_extract.9: Fix pmap_extract_and_hold()'s function type
[FreeBSD/FreeBSD.git] / share / man / man8 / rc.subr.8
1 .\"     $NetBSD: rc.subr.8,v 1.12 2004/01/06 00:52:24 lukem Exp $
2 .\"
3 .\" Copyright (c) 2002-2004 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
5 .\"
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Luke Mewburn.
8 .\"
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
11 .\" are met:
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\"    notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\"    notice, this list of conditions and the following disclaimer in the
16 .\"    documentation and/or other materials provided with the distribution.
17 .\"
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
29 .\"
30 .\" $FreeBSD$
31 .\"
32 .Dd July 31, 2020
33 .Dt RC.SUBR 8
34 .Os
35 .Sh NAME
36 .Nm rc.subr
37 .Nd functions used by system shell scripts
38 .Sh SYNOPSIS
39 .Bl -item -compact
40 .It
41 .Ic .\& Pa /etc/rc.subr
42 .Pp
43 .It
44 .Ic backup_file Ar action Ar file Ar current Ar backup
45 .It
46 .Ic checkyesno Ar var
47 .It
48 .Ic check_pidfile Ar pidfile Ar procname Op Ar interpreter
49 .It
50 .Ic check_process Ar procname Op Ar interpreter
51 .It
52 .Ic debug Ar message
53 .It
54 .Ic err Ar exitval Ar message
55 .It
56 .Ic force_depend Ar name
57 .It
58 .Ic info Ar message
59 .It
60 .Ic load_kld Oo Fl e Ar regex Oc Oo Fl m Ar module Oc Ar file
61 .It
62 .Ic load_rc_config Ar name
63 .It
64 .Ic load_rc_config_var Ar name Ar var
65 .It
66 .Ic mount_critical_filesystems Ar type
67 .It
68 .Ic rc_usage Ar command ...
69 .It
70 .Ic reverse_list Ar item ...
71 .It
72 .Ic run_rc_command Ar argument
73 .It
74 .Ic run_rc_script Ar file Ar argument
75 .It
76 .Ic wait_for_pids Op Ar pid ...
77 .It
78 .Ic warn Ar message
79 .El
80 .Sh DESCRIPTION
81 The
82 .Nm
83 script
84 contains commonly used shell script functions and variable
85 definitions which are used by various scripts such as
86 .Xr rc 8 .
87 Scripts required by ports in
88 .Pa /usr/local/etc/rc.d
89 will also eventually
90 be rewritten to make use of it.
91 .Pp
92 The
93 .Nm
94 functions were mostly imported from
95 .Nx .
96 .Pp
97 They are accessed by sourcing
98 .Pa /etc/rc.subr
99 into the current shell.
100 .Pp
101 The following shell functions are available:
102 .Bl -tag -width 4n
103 .It Ic backup_file Ar action file current backup
104 Make a backup copy of
105 .Ar file
106 into
107 .Ar current .
108 Save the previous version of
109 .Ar current
110 as
111 .Ar backup .
112 .Pp
113 The
114 .Ar action
115 argument
116 may be one of the following:
117 .Bl -tag -width ".Cm remove"
118 .It Cm add
119 .Ar file
120 is now being backed up by or possibly re-entered into this backup mechanism.
121 .Ar current
122 is created.
123 .It Cm update
124 .Ar file
125 has changed and needs to be backed up.
126 If
127 .Ar current
128 exists, it is copied to
129 .Ar backup
130 and then
131 .Ar file
132 is copied to
133 .Ar current .
134 .It Cm remove
135 .Ar file
136 is no longer being tracked by this backup mechanism.
137 .Ar current
138 is moved to
139 .Ar backup .
140 .El
141 .It Ic checkyesno Ar var
142 Return 0 if
143 .Ar var
144 is defined to
145 .Dq Li YES ,
146 .Dq Li TRUE ,
147 .Dq Li ON ,
148 or
149 .Ql 1 .
150 Return 1 if
151 .Ar var
152 is defined to
153 .Dq Li NO ,
154 .Dq Li FALSE ,
155 .Dq Li OFF ,
156 or
157 .Ql 0 .
158 Otherwise, warn that
159 .Ar var
160 is not set correctly.
161 The values are case insensitive.
162 .Sy Note :
163 .Ar var
164 should be a variable name, not its value;
165 .Ic checkyesno
166 will expand the variable by itself.
167 .It Ic check_pidfile Ar pidfile procname Op Ar interpreter
168 Parses the first word of the first line of
169 .Ar pidfile
170 for a PID, and ensures that the process with that PID
171 is running and its first argument matches
172 .Ar procname .
173 Prints the matching PID if successful, otherwise nothing.
174 If
175 .Ar interpreter
176 is provided, parse the first line of
177 .Ar procname ,
178 ensure that the line is of the form:
179 .Pp
180 .Dl "#! interpreter [...]"
181 .Pp
182 and use
183 .Ar interpreter
184 with its optional arguments and
185 .Ar procname
186 appended as the process string to search for.
187 .It Ic check_process Ar procname Op Ar interpreter
188 Prints the PIDs of any processes that are running with a first
189 argument that matches
190 .Ar procname .
191 .Ar interpreter
192 is handled as per
193 .Ic check_pidfile .
194 .It Ic debug Ar message
195 Display a debugging message to
196 .Va stderr ,
197 log it to the system log using
198 .Xr logger 1 ,
199 and
200 return to the caller.
201 The error message consists of the script name
202 (from
203 .Va $0 ) ,
204 followed by
205 .Dq Li ": DEBUG: " ,
206 and then
207 .Ar message .
208 This function is intended to be used by developers
209 as an aid to debugging scripts.
210 It can be turned on or off
211 by the
212 .Xr rc.conf 5
213 variable
214 .Va rc_debug .
215 .It Ic err Ar exitval message
216 Display an error message to
217 .Va stderr ,
218 log it to the system log
219 using
220 .Xr logger 1 ,
221 and
222 .Ic exit
223 with an exit value of
224 .Ar exitval .
225 The error message consists of the script name
226 (from
227 .Va $0 ) ,
228 followed by
229 .Dq Li ": ERROR: " ,
230 and then
231 .Ar message .
232 .It Ic force_depend Ar name
233 Output an advisory message and force the
234 .Ar name
235 service to start.
236 The
237 .Ar name
238 argument is the
239 .Xr basename 1
240 component of the path to the script located at
241 .Pa /etc/rc.d
242 (scripts stored in other locations such as
243 .Pa /usr/local/etc/rc.d
244 cannot be controlled with
245 .Ic force_depend
246 currently).
247 If the script fails for any reason it will output a warning
248 and return with a return value of 1.
249 If it was successful
250 it will return 0.
251 .It Ic info Ar message
252 Display an informational message to
253 .Va stdout ,
254 and log it to the system log using
255 .Xr logger 1 .
256 The message consists of the script name
257 (from
258 .Va $0 ) ,
259 followed by
260 .Dq Li ": INFO: " ,
261 and then
262 .Ar message .
263 The display of this informational output can be
264 turned on or off by the
265 .Xr rc.conf 5
266 variable
267 .Va rc_info .
268 .It Ic load_kld Oo Fl e Ar regex Oc Oo Fl m Ar module Oc Ar file
269 Load
270 .Ar file
271 as a kernel module unless it is already loaded.
272 For the purpose of checking the module status,
273 either the exact module name can be specified using
274 .Fl m ,
275 or an
276 .Xr egrep 1
277 regular expression matching the module name can be supplied via
278 .Fl e .
279 By default, the module is assumed to have the same name as
280 .Ar file ,
281 which is not always the case.
282 .It Ic load_rc_config Ar name
283 Source in the configuration files for
284 .Ar name .
285 First,
286 .Pa /etc/rc.conf
287 is sourced if it has not yet been read in.
288 Then,
289 .Pa /etc/rc.conf.d/ Ns Ar name
290 is sourced if it is an existing file.
291 The latter may also contain other variable assignments to override
292 .Ic run_rc_command
293 arguments defined by the calling script, to provide an easy
294 mechanism for an administrator to override the behaviour of a given
295 .Xr rc.d 8
296 script without requiring the editing of that script.
297 .It Ic load_rc_config_var Ar name Ar var
298 Read the
299 .Xr rc.conf 5
300 variable
301 .Ar var
302 for
303 .Ar name
304 and set in the current shell, using
305 .Ic load_rc_config
306 in a sub-shell to prevent unwanted side effects from other variable
307 assignments.
308 .It Ic mount_critical_filesystems Ar type
309 Go through a list of critical file systems,
310 as found in the
311 .Xr rc.conf 5
312 variable
313 .Va critical_filesystems_ Ns Ar type ,
314 mounting each one that
315 is not currently mounted.
316 .It Ic rc_usage Ar command ...
317 Print a usage message for
318 .Va $0 ,
319 with
320 .Ar commands
321 being the list of valid arguments
322 prefixed by
323 .Sm off
324 .Dq Bq Li fast | force | one | quiet .
325 .Sm on
326 .It Ic reverse_list Ar item ...
327 Print the list of
328 .Ar items
329 in reverse order.
330 .It Ic run_rc_command Ar argument
331 Run the
332 .Ar argument
333 method for the current
334 .Xr rc.d 8
335 script, based on the settings of various shell variables.
336 .Ic run_rc_command
337 is extremely flexible, and allows fully functional
338 .Xr rc.d 8
339 scripts to be implemented in a small amount of shell code.
340 .Pp
341 .Ar argument
342 is searched for in the list of supported commands, which may be one
343 of:
344 .Bl -tag -width ".Cm restart" -offset indent
345 .It Cm start
346 Start the service.
347 This should check that the service is to be started as specified by
348 .Xr rc.conf 5 .
349 Also checks if the service is already running and refuses to start if
350 it is.
351 This latter check is not performed by standard
352 .Fx
353 scripts if the system is starting directly to multi-user mode, to
354 speed up the boot process.
355 .It Cm stop
356 If the service is to be started as specified by
357 .Xr rc.conf 5 ,
358 stop the service.
359 This should check that the service is running and complain if it is not.
360 .It Cm restart
361 Perform a
362 .Cm stop
363 then a
364 .Cm start .
365 Defaults to displaying the process ID of the program (if running).
366 .It Cm enabled
367 Return 0 if the service is enabled and 1 if it is not.
368 This command does not print anything.
369 .It Cm rcvar
370 Display which
371 .Xr rc.conf 5
372 variables are used to control the startup of the service (if any).
373 .El
374 .Pp
375 If
376 .Va pidfile
377 or
378 .Va procname
379 is set, also support:
380 .Bl -tag -width ".Cm restart" -offset indent
381 .It Cm poll
382 Wait for the command to exit.
383 .It Cm status
384 Show the status of the process.
385 .El
386 .Pp
387 Other supported commands are listed in the optional variable
388 .Va extra_commands .
389 .Pp
390 .Ar argument
391 may have one of the following prefixes which alters its operation:
392 .Bl -tag -width ".Li force" -offset indent
393 .It Li fast
394 Skip the check for an existing running process,
395 and sets
396 .Va rc_fast Ns = Ns Li YES .
397 .It Li force
398 Skip the checks for
399 .Va rcvar
400 being set to
401 .Dq Li YES ,
402 and sets
403 .Va rc_force Ns = Ns Li YES .
404 This ignores
405 .Ar argument Ns Va _precmd
406 returning non-zero, and ignores any of the
407 .Va required_*
408 tests failing, and always returns a zero exit status.
409 .It Li one
410 Skip the checks for
411 .Va rcvar
412 being set to
413 .Dq Li YES ,
414 but performs all the other prerequisite tests.
415 .It Li quiet
416 Inhibits some verbose diagnostics.
417 Currently, this includes messages
418 .Qq Starting ${name}
419 (as checked by
420 .Ic check_startmsgs
421 inside
422 .Nm )
423 and errors about usage of services that are not enabled in
424 .Xr rc.conf 5 .
425 This prefix also sets
426 .Va rc_quiet Ns = Ns Li YES .
427 .Em Please, note\&:
428 .Va rc_quiet
429 is not intended to completely mask all debug and warning messages,
430 but only certain small classes of them.
431 .El
432 .Pp
433 .Ic run_rc_command
434 uses the following shell variables to control its behaviour.
435 Unless otherwise stated, these are optional.
436 .Bl -tag -width ".Va procname" -offset indent
437 .It Va name
438 The name of this script.
439 This is not optional.
440 .It Va rcvar
441 The value of
442 .Va rcvar
443 is checked with
444 .Ic checkyesno
445 to determine if this method should be run.
446 .It Va command
447 Full path to the command.
448 Not required if
449 .Ar argument Ns Va _cmd
450 is defined for each supported keyword.
451 Can be overridden by
452 .Va ${name}_program .
453 .It Va command_args
454 Optional arguments and/or shell directives for
455 .Va command .
456 .It Va command_interpreter
457 .Va command
458 is started with:
459 .Pp
460 .Dl "#! command_interpreter [...]"
461 .Pp
462 which results in its
463 .Xr ps 1
464 command being:
465 .Pp
466 .Dl "command_interpreter [...] command"
467 .Pp
468 so use that string to find the PID(s) of the running command
469 rather than
470 .Va command .
471 .It Va extra_commands
472 Extra commands/keywords/arguments supported.
473 .It Va pidfile
474 Path to PID file.
475 Used to determine the PID(s) of the running command.
476 If
477 .Va pidfile
478 is set, use:
479 .Pp
480 .Dl "check_pidfile $pidfile $procname"
481 .Pp
482 to find the PID.
483 Otherwise, if
484 .Va command
485 is set, use:
486 .Pp
487 .Dl "check_process $procname"
488 .Pp
489 to find the PID.
490 .It Va procname
491 Process name to check for.
492 Defaults to the value of
493 .Va command .
494 .It Va required_dirs
495 Check for the existence of the listed directories
496 before running the
497 .Cm start
498 method.
499 The list is checked before running
500 .Va start_precmd .
501 .It Va required_files
502 Check for the readability of the listed files
503 before running the
504 .Cm start
505 method.
506 The list is checked before running
507 .Va start_precmd .
508 .It Va required_modules
509 Ensure that the listed kernel modules are loaded
510 before running the
511 .Cm start
512 method.
513 The list is checked after running
514 .Va start_precmd .
515 This is done after invoking the commands from
516 .Va start_precmd
517 so that the missing modules are not loaded in vain
518 if the preliminary commands indicate a error condition.
519 A word in the list can have an optional
520 .Dq Li \&: Ns Ar modname
521 or
522 .Dq Li ~ Ns Ar pattern
523 suffix.
524 The
525 .Ar modname
526 or
527 .Ar pattern
528 parameter is passed to
529 .Ic load_kld
530 through a
531 .Fl m
532 or
533 .Fl e
534 option, respectively.
535 See the description of
536 .Ic load_kld
537 in this document for details.
538 .It Va required_vars
539 Perform
540 .Ic checkyesno
541 on each of the list variables
542 before running the
543 .Cm start
544 method.
545 The list is checked after running
546 .Va start_precmd .
547 .It Va ${name}_chdir
548 Directory to
549 .Ic cd
550 to before running
551 .Va command ,
552 if
553 .Va ${name}_chroot
554 is not provided.
555 .It Va ${name}_chroot
556 Directory to
557 .Xr chroot 8
558 to before running
559 .Va command .
560 Only supported after
561 .Pa /usr
562 is mounted.
563 .It Va ${name}_env
564 A list of environment variables to run
565 .Va command
566 with.
567 Those variables will be passed as arguments to the
568 .Xr env 1
569 utility unless
570 .Ar argument Ns Va _cmd
571 is defined.
572 In that case the contents of
573 .Va ${name}_env
574 will be exported via the
575 .Xr export 1
576 builtin of
577 .Xr sh 1 ,
578 which puts some limitations on the names of variables
579 (e.g., a variable name may not start with a digit).
580 .It Va ${name}_env_file
581 A file to source for environmental variables to run
582 .Va command
583 with.
584 Note that all the variables which are being assigned in this file are going
585 to be exported into the environment of
586 .Va command .
587 .It Va ${name}_fib
588 FIB
589 .Pa Routing Table
590 number to run
591 .Va command
592 with.
593 See
594 .Xr setfib 1
595 for more details.
596 .It Va ${name}_flags
597 Arguments to call
598 .Va command
599 with.
600 This is usually set in
601 .Xr rc.conf 5 ,
602 and not in the
603 .Xr rc.d 8
604 script.
605 The environment variable
606 .Sq Ev flags
607 can be used to override this.
608 .It Va ${name}_nice
609 .Xr nice 1
610 level to run
611 .Va command
612 as.
613 Only supported after
614 .Pa /usr
615 is mounted.
616 .It Va ${name}_limits
617 Resource limits to apply to
618 .Va command .
619 This will be passed as arguments to the
620 .Xr limits 1
621 utility.
622 By default, the resource limits are based on the login class defined in
623 .Va ${name}_login_class .
624 .It Va ${name}_login_class
625 Login class to use with
626 .Va ${name}_limits .
627 Defaults to
628 .Dq Li daemon .
629 .It Va ${name}_oomprotect
630 .Xr protect 1
631 .Va command
632 from being killed when swap space is exhausted.
633 If
634 .Dq Li YES
635 is used, no child processes are protected.
636 If
637 .Dq Li ALL ,
638 protect all child processes.
639 .It Va ${name}_program
640 Full path to the command.
641 Overrides
642 .Va command
643 if both are set, but has no effect if
644 .Va command
645 is unset.
646 As a rule,
647 .Va command
648 should be set in the script while
649 .Va ${name}_program
650 should be set in
651 .Xr rc.conf 5 .
652 .It Va ${name}_user
653 User to run
654 .Va command
655 as, using
656 .Xr chroot 8
657 if
658 .Va ${name}_chroot
659 is set, otherwise
660 uses
661 .Xr su 1 .
662 Only supported after
663 .Pa /usr
664 is mounted.
665 .It Va ${name}_group
666 Group to run the chrooted
667 .Va command
668 as.
669 .It Va ${name}_groups
670 Comma separated list of supplementary groups to run the chrooted
671 .Va command
672 with.
673 .It Va ${name}_prepend
674 Commands to be prepended to
675 .Va command .
676 This is a generic version of
677 .Va ${name}_env ,
678 .Va ${name}_fib ,
679 or
680 .Va ${name}_nice .
681 .It Ar argument Ns Va _cmd
682 Shell commands which override the default method for
683 .Ar argument .
684 .It Ar argument Ns Va _precmd
685 Shell commands to run just before running
686 .Ar argument Ns Va _cmd
687 or the default method for
688 .Ar argument .
689 If this returns a non-zero exit code, the main method is not performed.
690 If the default method is being executed, this check is performed after
691 the
692 .Va required_*
693 checks and process (non-)existence checks.
694 .It Ar argument Ns Va _postcmd
695 Shell commands to run if running
696 .Ar argument Ns Va _cmd
697 or the default method for
698 .Ar argument
699 returned a zero exit code.
700 .It Va sig_stop
701 Signal to send the processes to stop in the default
702 .Cm stop
703 method.
704 Defaults to
705 .Dv SIGTERM .
706 .It Va sig_reload
707 Signal to send the processes to reload in the default
708 .Cm reload
709 method.
710 Defaults to
711 .Dv SIGHUP .
712 .El
713 .Pp
714 For a given method
715 .Ar argument ,
716 if
717 .Ar argument Ns Va _cmd
718 is not defined, then a default method is provided by
719 .Ic run_rc_command :
720 .Bl -tag -width ".Sy Argument" -offset indent
721 .It Sy Argument
722 .Sy Default method
723 .It Cm start
724 If
725 .Va command
726 is not running and
727 .Ic checkyesno Va rcvar
728 succeeds, start
729 .Va command .
730 .It Cm stop
731 Determine the PIDs of
732 .Va command
733 with
734 .Ic check_pidfile
735 or
736 .Ic check_process
737 (as appropriate),
738 .Ic kill Va sig_stop
739 those PIDs, and run
740 .Ic wait_for_pids
741 on those PIDs.
742 .It Cm reload
743 Similar to
744 .Cm stop ,
745 except that it uses
746 .Va sig_reload
747 instead, and does not run
748 .Ic wait_for_pids .
749 Another difference from
750 .Cm stop
751 is that
752 .Cm reload
753 is not provided by default.
754 It can be enabled via
755 .Va extra_commands
756 if appropriate:
757 .Pp
758 .Dl "extra_commands=reload"
759 .It Cm restart
760 Runs the
761 .Cm stop
762 method, then the
763 .Cm start
764 method.
765 .It Cm status
766 Show the PID of
767 .Va command ,
768 or some other script specific status operation.
769 .It Cm poll
770 Wait for
771 .Va command
772 to exit.
773 .It Cm rcvar
774 Display which
775 .Xr rc.conf 5
776 variable is used (if any).
777 This method always works, even if the appropriate
778 .Xr rc.conf 5
779 variable is set to
780 .Dq Li NO .
781 .El
782 .Pp
783 The following variables are available to the methods
784 (such as
785 .Ar argument Ns Va _cmd )
786 as well as after
787 .Ic run_rc_command
788 has completed:
789 .Bl -tag -width ".Va rc_service" -offset indent
790 .It Va rc_arg
791 Argument provided to
792 .Ic run_rc_command ,
793 after fast and force processing has been performed.
794 .It Va rc_flags
795 Flags to start the default command with.
796 Defaults to
797 .Va ${name}_flags ,
798 unless overridden by the environment variable
799 .Sq Ev flags .
800 This variable may be changed by the
801 .Ar argument Ns Va _precmd
802 method.
803 .It Va rc_service
804 Path to the service script being executed, in case it needs to re-invoke itself.
805 .It Va rc_pid
806 PID of
807 .Va command
808 (if appropriate).
809 .It Va rc_fast
810 Not empty if
811 .Dq Li fast
812 prefix was used.
813 .It Va rc_force
814 Not empty if
815 .Dq Li force
816 prefix was used.
817 .El
818 .It Ic run_rc_script Ar file argument
819 Start the script
820 .Ar file
821 with an argument of
822 .Ar argument ,
823 and handle the return value from the script.
824 .Pp
825 Various shell variables are unset before
826 .Ar file
827 is started:
828 .Bd -ragged -offset indent
829 .Va name ,
830 .Va command ,
831 .Va command_args ,
832 .Va command_interpreter ,
833 .Va extra_commands ,
834 .Va pidfile ,
835 .Va rcvar ,
836 .Va required_dirs ,
837 .Va required_files ,
838 .Va required_vars ,
839 .Ar argument Ns Va _cmd ,
840 .Ar argument Ns Va _precmd .
841 .Ar argument Ns Va _postcmd .
842 .Ed
843 .Pp
844 The startup behaviour of
845 .Ar file
846 depends upon the following checks:
847 .Bl -enum
848 .It
849 If
850 .Ar file
851 ends in
852 .Pa .sh ,
853 it is sourced into the current shell.
854 .It
855 If
856 .Ar file
857 appears to be a backup or scratch file
858 (e.g., with a suffix of
859 .Pa ~ , # , .OLD ,
860 or
861 .Pa .orig ) ,
862 ignore it.
863 .It
864 If
865 .Ar file
866 is not executable, ignore it.
867 .It
868 If the
869 .Xr rc.conf 5
870 variable
871 .Va rc_fast_and_loose
872 is empty,
873 source
874 .Ar file
875 in a sub shell,
876 otherwise source
877 .Ar file
878 into the current shell.
879 .El
880 .It Ic stop_boot Op Ar always
881 Prevent booting to multiuser mode.
882 If the
883 .Va autoboot
884 variable is set to
885 .Ql yes
886 (see
887 .Xr rc 8
888 to learn more about
889 .Va autoboot ) ,
890 or
891 .Ic checkyesno Ar always
892 indicates a truth value, then a
893 .Dv SIGTERM
894 signal is sent to the parent
895 process, which is assumed to be
896 .Xr rc 8 .
897 Otherwise, the shell exits with a non-zero status.
898 .It Ic wait_for_pids Op Ar pid ...
899 Wait until all of the provided
900 .Ar pids
901 do not exist any more, printing the list of outstanding
902 .Ar pids
903 every two seconds.
904 .It Ic warn Ar message
905 Display a warning message to
906 .Va stderr
907 and log it to the system log
908 using
909 .Xr logger 1 .
910 The warning message consists of the script name
911 (from
912 .Va $0 ) ,
913 followed by
914 .Dq Li ": WARNING: " ,
915 and then
916 .Ar message .
917 .El
918 .Sh FILES
919 .Bl -tag -width ".Pa /etc/rc.subr" -compact
920 .It Pa /etc/rc.subr
921 The
922 .Nm
923 file resides in
924 .Pa /etc .
925 .El
926 .Sh SEE ALSO
927 .Xr rc.conf 5 ,
928 .Xr rc 8
929 .Sh HISTORY
930 The
931 .Nm
932 script
933 appeared in
934 .Nx 1.3 .
935 The
936 .Xr rc.d 8
937 support functions appeared in
938 .Nx 1.5 .
939 The
940 .Nm
941 script
942 first appeared in
943 .Fx 5.0 .