]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man8/rc.subr.8
MFC r351863:
[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 .It Va required_files
500 Check for the readability of the listed files
501 before running the
502 .Cm start
503 method.
504 .It Va required_modules
505 Ensure that the listed kernel modules are loaded
506 before running the
507 .Cm start
508 method.
509 This is done after invoking the commands from
510 .Va start_precmd
511 so that the missing modules are not loaded in vain
512 if the preliminary commands indicate a error condition.
513 A word in the list can have an optional
514 .Dq Li \&: Ns Ar modname
515 or
516 .Dq Li ~ Ns Ar pattern
517 suffix.
518 The
519 .Ar modname
520 or
521 .Ar pattern
522 parameter is passed to
523 .Ic load_kld
524 through a
525 .Fl m
526 or
527 .Fl e
528 option, respectively.
529 See the description of
530 .Ic load_kld
531 in this document for details.
532 .It Va required_vars
533 Perform
534 .Ic checkyesno
535 on each of the list variables
536 before running the
537 .Cm start
538 method.
539 .It Va ${name}_chdir
540 Directory to
541 .Ic cd
542 to before running
543 .Va command ,
544 if
545 .Va ${name}_chroot
546 is not provided.
547 .It Va ${name}_chroot
548 Directory to
549 .Xr chroot 8
550 to before running
551 .Va command .
552 Only supported after
553 .Pa /usr
554 is mounted.
555 .It Va ${name}_env
556 A list of environment variables to run
557 .Va command
558 with.
559 Those variables will be passed as arguments to the
560 .Xr env 1
561 utility unless
562 .Ar argument Ns Va _cmd
563 is defined.
564 In that case the contents of
565 .Va ${name}_env
566 will be exported via the
567 .Xr export 1
568 builtin of
569 .Xr sh 1 ,
570 which puts some limitations on the names of variables
571 (e.g., a variable name may not start with a digit).
572 .It Va ${name}_env_file
573 A file to source for environmental variables to run
574 .Va command
575 with.
576 Note that all the variables which are being assigned in this file are going
577 to be exported into the environment of
578 .Va command .
579 .It Va ${name}_fib
580 FIB
581 .Pa Routing Table
582 number to run
583 .Va command
584 with.
585 See
586 .Xr setfib 1
587 for more details.
588 .It Va ${name}_flags
589 Arguments to call
590 .Va command
591 with.
592 This is usually set in
593 .Xr rc.conf 5 ,
594 and not in the
595 .Xr rc.d 8
596 script.
597 The environment variable
598 .Sq Ev flags
599 can be used to override this.
600 .It Va ${name}_nice
601 .Xr nice 1
602 level to run
603 .Va command
604 as.
605 Only supported after
606 .Pa /usr
607 is mounted.
608 .It Va ${name}_limits
609 Resource limits to apply to
610 .Va command .
611 This will be passed as arguments to the
612 .Xr limits 1
613 utility.
614 By default, the resource limits are based on the login class defined in
615 .Va ${name}_login_class .
616 .It Va ${name}_login_class
617 Login class to use with
618 .Va ${name}_limits .
619 Defaults to
620 .Dq Li daemon .
621 .It Va ${name}_oomprotect
622 .Xr protect 1
623 .Va command
624 from being killed when swap space is exhausted.
625 If
626 .Dq Li YES
627 is used, no child processes are protected.
628 If
629 .Dq Li ALL ,
630 protect all child processes.
631 .It Va ${name}_program
632 Full path to the command.
633 Overrides
634 .Va command
635 if both are set, but has no effect if
636 .Va command
637 is unset.
638 As a rule,
639 .Va command
640 should be set in the script while
641 .Va ${name}_program
642 should be set in
643 .Xr rc.conf 5 .
644 .It Va ${name}_user
645 User to run
646 .Va command
647 as, using
648 .Xr chroot 8
649 if
650 .Va ${name}_chroot
651 is set, otherwise
652 uses
653 .Xr su 1 .
654 Only supported after
655 .Pa /usr
656 is mounted.
657 .It Va ${name}_group
658 Group to run the chrooted
659 .Va command
660 as.
661 .It Va ${name}_groups
662 Comma separated list of supplementary groups to run the chrooted
663 .Va command
664 with.
665 .It Va ${name}_prepend
666 Commands to be prepended to
667 .Va command .
668 This is a generic version of
669 .Va ${name}_env ,
670 .Va ${name}_fib ,
671 or
672 .Va ${name}_nice .
673 .It Ar argument Ns Va _cmd
674 Shell commands which override the default method for
675 .Ar argument .
676 .It Ar argument Ns Va _precmd
677 Shell commands to run just before running
678 .Ar argument Ns Va _cmd
679 or the default method for
680 .Ar argument .
681 If this returns a non-zero exit code, the main method is not performed.
682 If the default method is being executed, this check is performed after
683 the
684 .Va required_*
685 checks and process (non-)existence checks.
686 .It Ar argument Ns Va _postcmd
687 Shell commands to run if running
688 .Ar argument Ns Va _cmd
689 or the default method for
690 .Ar argument
691 returned a zero exit code.
692 .It Va sig_stop
693 Signal to send the processes to stop in the default
694 .Cm stop
695 method.
696 Defaults to
697 .Dv SIGTERM .
698 .It Va sig_reload
699 Signal to send the processes to reload in the default
700 .Cm reload
701 method.
702 Defaults to
703 .Dv SIGHUP .
704 .El
705 .Pp
706 For a given method
707 .Ar argument ,
708 if
709 .Ar argument Ns Va _cmd
710 is not defined, then a default method is provided by
711 .Ic run_rc_command :
712 .Bl -tag -width ".Sy Argument" -offset indent
713 .It Sy Argument
714 .Sy Default method
715 .It Cm start
716 If
717 .Va command
718 is not running and
719 .Ic checkyesno Va rcvar
720 succeeds, start
721 .Va command .
722 .It Cm stop
723 Determine the PIDs of
724 .Va command
725 with
726 .Ic check_pidfile
727 or
728 .Ic check_process
729 (as appropriate),
730 .Ic kill Va sig_stop
731 those PIDs, and run
732 .Ic wait_for_pids
733 on those PIDs.
734 .It Cm reload
735 Similar to
736 .Cm stop ,
737 except that it uses
738 .Va sig_reload
739 instead, and does not run
740 .Ic wait_for_pids .
741 Another difference from
742 .Cm stop
743 is that
744 .Cm reload
745 is not provided by default.
746 It can be enabled via
747 .Va extra_commands
748 if appropriate:
749 .Pp
750 .Dl "extra_commands=reload"
751 .It Cm restart
752 Runs the
753 .Cm stop
754 method, then the
755 .Cm start
756 method.
757 .It Cm status
758 Show the PID of
759 .Va command ,
760 or some other script specific status operation.
761 .It Cm poll
762 Wait for
763 .Va command
764 to exit.
765 .It Cm rcvar
766 Display which
767 .Xr rc.conf 5
768 variable is used (if any).
769 This method always works, even if the appropriate
770 .Xr rc.conf 5
771 variable is set to
772 .Dq Li NO .
773 .El
774 .Pp
775 The following variables are available to the methods
776 (such as
777 .Ar argument Ns Va _cmd )
778 as well as after
779 .Ic run_rc_command
780 has completed:
781 .Bl -tag -width ".Va rc_service" -offset indent
782 .It Va rc_arg
783 Argument provided to
784 .Ic run_rc_command ,
785 after fast and force processing has been performed.
786 .It Va rc_flags
787 Flags to start the default command with.
788 Defaults to
789 .Va ${name}_flags ,
790 unless overridden by the environment variable
791 .Sq Ev flags .
792 This variable may be changed by the
793 .Ar argument Ns Va _precmd
794 method.
795 .It Va rc_service
796 Path to the service script being executed, in case it needs to re-invoke itself.
797 .It Va rc_pid
798 PID of
799 .Va command
800 (if appropriate).
801 .It Va rc_fast
802 Not empty if
803 .Dq Li fast
804 prefix was used.
805 .It Va rc_force
806 Not empty if
807 .Dq Li force
808 prefix was used.
809 .El
810 .It Ic run_rc_script Ar file argument
811 Start the script
812 .Ar file
813 with an argument of
814 .Ar argument ,
815 and handle the return value from the script.
816 .Pp
817 Various shell variables are unset before
818 .Ar file
819 is started:
820 .Bd -ragged -offset indent
821 .Va name ,
822 .Va command ,
823 .Va command_args ,
824 .Va command_interpreter ,
825 .Va extra_commands ,
826 .Va pidfile ,
827 .Va rcvar ,
828 .Va required_dirs ,
829 .Va required_files ,
830 .Va required_vars ,
831 .Ar argument Ns Va _cmd ,
832 .Ar argument Ns Va _precmd .
833 .Ar argument Ns Va _postcmd .
834 .Ed
835 .Pp
836 The startup behaviour of
837 .Ar file
838 depends upon the following checks:
839 .Bl -enum
840 .It
841 If
842 .Ar file
843 ends in
844 .Pa .sh ,
845 it is sourced into the current shell.
846 .It
847 If
848 .Ar file
849 appears to be a backup or scratch file
850 (e.g., with a suffix of
851 .Pa ~ , # , .OLD ,
852 or
853 .Pa .orig ) ,
854 ignore it.
855 .It
856 If
857 .Ar file
858 is not executable, ignore it.
859 .It
860 If the
861 .Xr rc.conf 5
862 variable
863 .Va rc_fast_and_loose
864 is empty,
865 source
866 .Ar file
867 in a sub shell,
868 otherwise source
869 .Ar file
870 into the current shell.
871 .El
872 .It Ic stop_boot Op Ar always
873 Prevent booting to multiuser mode.
874 If the
875 .Va autoboot
876 variable is set to
877 .Ql yes
878 (see
879 .Xr rc 8
880 to learn more about
881 .Va autoboot ) ,
882 or
883 .Ic checkyesno Ar always
884 indicates a truth value, then a
885 .Dv SIGTERM
886 signal is sent to the parent
887 process, which is assumed to be
888 .Xr rc 8 .
889 Otherwise, the shell exits with a non-zero status.
890 .It Ic wait_for_pids Op Ar pid ...
891 Wait until all of the provided
892 .Ar pids
893 do not exist any more, printing the list of outstanding
894 .Ar pids
895 every two seconds.
896 .It Ic warn Ar message
897 Display a warning message to
898 .Va stderr
899 and log it to the system log
900 using
901 .Xr logger 1 .
902 The warning message consists of the script name
903 (from
904 .Va $0 ) ,
905 followed by
906 .Dq Li ": WARNING: " ,
907 and then
908 .Ar message .
909 .El
910 .Sh FILES
911 .Bl -tag -width ".Pa /etc/rc.subr" -compact
912 .It Pa /etc/rc.subr
913 The
914 .Nm
915 file resides in
916 .Pa /etc .
917 .El
918 .Sh SEE ALSO
919 .Xr rc.conf 5 ,
920 .Xr rc 8
921 .Sh HISTORY
922 The
923 .Nm
924 script
925 appeared in
926 .Nx 1.3 .
927 The
928 .Xr rc.d 8
929 support functions appeared in
930 .Nx 1.5 .
931 The
932 .Nm
933 script
934 first appeared in
935 .Fx 5.0 .