aboutsummaryrefslogtreecommitdiff
path: root/etc/rc.subr
Commit message (Collapse)AuthorAgeFilesLines
* If a service is running, make 'stop' work even if ${name}_enableDoug Barton2010-04-151-3/+3
| | | | | | | | | | | is not set. PR: conf/130414 Submitted by: Dominic Fandrey <kamikaze@bsdforen.de> Reviewed by: freebsd-rc@ Notes: svn path=/head/; revision=206686
* In wait_for_pids(), pwait(1) can return when the process exits, butDoug Barton2010-04-061-1/+4
| | | | | | | | | | | | | | | | | | | still exists as a zombie. The 'kill -0' test in this function can therefore return true even if the process isn't actually running. This could lead to wait_for_pids() printing an endless string of the pid number until the zombie finally exits. Solve this problem by moving the sleep up to after the 'kill -0' test, but only after we've run through the function once already. In the common case (only one pid in the list) this will always do the right thing. On the rare occasion that there is more than one pid in the list this will sleep 1 second per zombie process which will allow that process, and any other in the list a chance to exit. While I'm here, local'ize the variables that this function uses. Notes: svn path=/head/; revision=206248
* Convert to 2-clause license, from NetBSD rc.subr r1.70.Ed Maste2010-01-261-7/+0
| | | | | | | | Submitted by: Alex Kozlov Obtained from: NetBSD Notes: svn path=/head/; revision=203022
* Remove vestigial NetBSD compatibility shim.Ed Maste2010-01-251-11/+1
| | | | Notes: svn path=/head/; revision=202988
* Update the comments about files ending in .shDoug Barton2009-12-271-4/+5
| | | | | | | Prompted by: Alex Kozlov <spam@rm-rf.kiev.ua> Notes: svn path=/head/; revision=201038
* Delete some trailing whitespaceDoug Barton2009-12-271-2/+2
| | | | Notes: svn path=/head/; revision=201036
* rc.subr: Use pwait in wait_for_pids.Jilles Tjoelker2009-12-211-1/+1
| | | | | | | | | | | | | This waits for the requested process(es) to terminate, rather than polling with an interval of 2 seconds. If pwait is not available, the old method is used. PR: conf/132766 Reviewed by: dougb Notes: svn path=/head/; revision=200818
* Fix qouting in a comment, to make it look more consistentEd Schouten2009-10-181-1/+1
| | | | | | | | Submitted by: Jille Timmermans <jille quis cx> MFC after: 1 week Notes: svn path=/head/; revision=198216
* Allow $name_program to override $command in a more robust way thatDoug Barton2009-10-151-1/+1
| | | | | | | will not cause the value to be null if $command is not set. Notes: svn path=/head/; revision=198162
* In regards to the "Starting foo:" type messages at boot time, create andDoug Barton2009-10-101-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | employ a more generic solution, and use it in the individual rc.d scripts that also have an $rc_quiet test: 1. Add check_startmsgs() to rc.subr. 2. In the rc.d scripts that use rc_quiet (and rc.subr) substitute variations of [ -z "$rc_quiet" ] with check_startmsgs 3. In savecore add a trailing '.' to the end of the message to make it more consistent with other scripts. 4. In newsyslog remove a : before the terminal '.' since we do not expect there to be anything printed out in between to make it more consistent. 5. In the following scripts change "quotes" to 'quotes' where no variables exist in the message: savecore pf newsyslog 6. In the following scripts substitute if/then/fi for the simpler (and more consistent) check_startmsgs &&: faith stf 7. In the following scripts separate the "Starting foo:" from the terminal '.' to make them more consistent: moused hostname pf 8. In nfsclient move the message to its own line to avoid a style bug 9. In pf rc_quiet does not apply to the _stop method, so remove the test there. 10. In motd add 'quotes' around the terminal '.' for consistency Notes: svn path=/head/; revision=197947
* Fix a case when both ${name}_program and ${command} are defined.Hiroki Sato2009-10-051-1/+1
| | | | | | | Spotted by: Michio "Karl" Jinbo Notes: svn path=/head/; revision=197790
* Add a knob to show 'Starting foo:' messages when faststart is used,Doug Barton2009-09-171-1/+7
| | | | | | | such as at boot time. Notes: svn path=/head/; revision=197297
* Add an extension of set_rcvar(), a new function set_rcvar_obsolete(),Hiroki Sato2009-09-121-29/+143
| | | | | | | | | | | | | | | | | | and $desc. The set_rcvar_obsolete() is for displaying an obsolete variable and the new one. More specifically, a warning is displayed when a variable is removed or changed in the source tree and the user still defines the old one. $router* and $ipv6_router* are replaced with $routed_* and $route6d_* for consistency. The old variables still work but can be removed in the future. MFC after: 3 days Notes: svn path=/head/; revision=197144
* Now that the last of the *.sh scripts are gone from the base,Doug Barton2009-05-301-2/+2
| | | | | | | emit a warning if come across one. Notes: svn path=/head/; revision=193118
* Show which rc script is running since the default ^T just shows 'sh' as theAndrew Thompson2008-10-271-0/+1
| | | | | | | process. Notes: svn path=/head/; revision=184317
* Move the diagnostic output when the rc.subr(8) glue automatically starts aMike Makonnen2008-06-231-3/+9
| | | | | | | | | | | | | service behind $rc_quiet. Instead, output a warning if the pre-command routine or the command itself failed. Arguably, it's more useful to know when a command failed to start than it is to have an endless list of "Starting ...." lines[1]. [1] - This change actually helped me to discover a bug in rc.d/{lockd,statd} (fixed in r179941) that used to fail silently before. Notes: svn path=/head/; revision=179946
* Make quota knob conform to other rc(8) knobs. Keep older knob forMike Makonnen2008-06-191-0/+4
| | | | | | | | | compatibility. Requested by: Volker <volker@vwsoft.com> Notes: svn path=/head/; revision=179872
* Move the check for enabled knobs further down in run_rc_command() soMike Makonnen2008-06-191-14/+14
| | | | | | | | that bogus commands cause usage information to be printed instead of diagnostics about enabling the knob. Notes: svn path=/head/; revision=179870
* o Convert whitespaces to tabs.Maxim Konovalov2008-05-051-2/+2
| | | | Notes: svn path=/head/; revision=178776
* o Terminate "case" with "esac" not "fi".Maxim Konovalov2008-05-051-1/+1
| | | | | | | Reported by: Randy Bush Notes: svn path=/head/; revision=178775
* Fix improper use of checkyesno routine.Mike Makonnen2008-05-051-2/+6
| | | | | | | | Noticed by: oliver MFC after: 1 week Notes: svn path=/head/; revision=178770
* Re-implement: do not silently fail when a command is not carriedMike Makonnen2008-01-261-1/+16
| | | | | | | | | | | | | | | | | | out because the rc.conf(5) variable was not enabled. Display a message that the command wasn't run and offer suggestions on what the user can do. Implement a quiet prefix, which will disable some diagnostics. The fast prefix also implies quiet. During boot we use either fast or quiet. For shutdown we already use 'faststop'. So, this informational message should only appear during interactive use. An additional benefit of having a quiet prefix is that we can start putting some of our diagnostic messages behind this knob and start "de-cluttering" the console during boot and shutdown. Notes: svn path=/head/; revision=175676
* Backout previous commit. It's going to clutter the consoleMike Makonnen2008-01-251-3/+0
| | | | | | | | | | | | | during boot and shutdown. I think I'll hide it behind autoboot or maybe take brooks@ suggestion and implement a different command prefix for booting/shutdown purposes, but in any case it needs more thought and attention. Noticed by: ceri Pointyhat to: mtm Notes: svn path=/head/; revision=175662
* If the rc.conf(5) variable for a script is not enabled do not failMike Makonnen2008-01-251-0/+3
| | | | | | | | | | | silently. Display a message that the command wasn't run and make possible suggestions for what to do. PR: conf/118770 MFC after: 1 week Notes: svn path=/head/; revision=175660
* Remove pre-rc.d compatibility shims that were added before the 5.0 branchDoug Barton2007-10-091-16/+0
| | | | | | | | | | | | | for pre-5.0 variable names. Remove two dhcp compatibility variables added after the 5.1-RELEASE. Remove the now-unused support for these shims. Approved by: re (kensmith) Notes: svn path=/head/; revision=172487
* Be robust to a bogus script specification or contentsYaroslav Tykhiy2007-06-041-11/+24
| | | | | | | | | | when figuring out what the real interpreter is for an interpreted command. That is, check whether we can read the script file in the first place and, if so, make sure we got a valid shebang line from it. Notes: svn path=/head/; revision=170282
* o Implement the stop_boot subroutine [1]. This subroutine can be used byMike Makonnen2007-05-181-0/+22
| | | | | | | | | | | | | | | | | | | | scripts in rc.d to stop rc(8) from booting into multi-user mode when a critical or severe error condition is encountered. o Modify scripts in etc/rc.d that already implemented this functionality independently. o Document it. [1] - This subroutine was implemented in FreeBSD in rc.d/fsck. I moved it to rc.subr(8). Our version differs slightly in that it takes an optional argument to stop the boot even if "autoboot" is not set. Obtained from: NetBSD MFC after: 2 weeks Notes: svn path=/head/; revision=169668
* Prepend ${_chroot} to a pathname in a consistent and robust way:Yaroslav Tykhiy2007-03-101-2/+3
| | | | | | | | | insert a slash between ${_chroot} and the pathname if and only if ${_chroot} is set to a non-empty string. Now the pathname is very likely to be absolute, but we shouldn't take that for granted. Notes: svn path=/head/; revision=167413
* Allow for /usr/bin/env when parsing the shebang line from anYaroslav Tykhiy2006-12-311-0/+5
| | | | | | | | | | | | | | | | | | interpreted $command. Some "portable" sofware packages use such a line to skip the task of figuring out the absolute pathname of the interpreter at install time, e.g.: #!/usr/bin/env python It is insecure, but a popular book on Python seems to have advised it to a wide audience. Hence a number of such scripts in the ports, mostly written in Python. PR: bin/100287 MFC after: 1 week Notes: svn path=/head/; revision=165684
* MFp4:Yaroslav Tykhiy2006-12-271-146/+198
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement the checks for required_* objects as two functions, one to be run before precmd and the other after it. They get the current rc command as an argument so they can choose what requirement tests to perform. As of now, only "start" needs such tests. Implement a new requirement variable, required_modules. It can list kernel modules that need to be loaded after start_precmd indicated success. Each name in the list can be just "file", or "file:module", or "file~regex". This will allow us to remove a lot of duplicated code from rc.d scripts. Perform the checks not only for the default start method, but for any method. This allows for more flexibility and fixes a few rc.d scripts (namely newsyslog, pf, sendmail) that rely on a required_* variable while providing a non-default start method. To be able to call the new check_required* functions naturally, remove lots of crufty duplicated code pieces from run_rc_command and replace each of them by a call to the helper function providing a single corrected instance of the respective code snippet. Now run_rc_command isn't as scary as it used to be, and it even appears to have quite a nice logic that was obscured by the old crufty code. In the default handler for restart, run start from a subshell to protect global varibles, e.g., _postcmd, from modification by the start handler. This enables using restart_postcmd. [x] PR: conf/98734 [x] Submitted by: Rick van der Zwet <rick@wzoeterwoude.net> [x] Reviewed by: freebsd-rc (silence for an older version) MFC after: 1 month Notes: svn path=/head/; revision=165565
* Teach find_processes() to use ${name}_chroot.Florent Thoumie2006-11-261-2/+2
| | | | | | | | Obtained from: NetBSD X-MFC after: 6.2-RELEASE Notes: svn path=/head/; revision=164640
* Remove leading dollar sign in rcvar command output.Florent Thoumie2006-11-261-2/+2
| | | | | | | | | | | There's no dollar use in variable assignment in sh. Assuming this is can be expected behavior for some people, this change won't be MFC'ed to RELENG_6. Discussed with: yar on -rc Notes: svn path=/head/; revision=164629
* debug() shouldn't misidentify itself to logger(1).Yaroslav Tykhiy2006-10-021-1/+1
| | | | | | | Noticed by: David Thompson <dat1965 yahoo com> Notes: svn path=/head/; revision=162947
* Backout this commit since it breaks startup and some scripts inFlorent Thoumie2006-08-221-30/+5
| | | | | | | | | | | | | | | | | | | | certain conditions. I haven't been able to find a better solution yet: - Set a two read-only variables (${prefix} and ${etcdir}). This is especially useful when using /etc/rc.d scripts with third-party software installed from ports. - Fix rc.d/sshd to work with openssh from ports using ${etcdir} instead of hardcoded /etc. - Reflect prefix/etcdir changes in rc.subr.8. src/etc/rc.d/sshd: rev 1.9 -> 1.10 src/etc/rc.subr: rev 1.51 -> 1.52 src/share/man/man8/rc.subr.8: rev 1.11 -> 1.12 Approved by: cperciva (mentor) Notes: svn path=/head/; revision=161530
* Eliminate header line(s) from ps(1) output instead of skipping over them.Yaroslav Tykhiy2006-08-181-5/+2
| | | | Notes: svn path=/head/; revision=161436
* The ps(1) command is unfriendly to scripts by default becauseYaroslav Tykhiy2006-08-181-3/+4
| | | | | | | | | | | | | it limits the width of its output to the value of $COLUMNS, or what TIOCGWINSZ reports, or 79 columns. We should specify -ww to ps(1) so that it removes the limit and prints lines in full. Otherwise very long command pathnames could be mishandled, e.g., by _find_processes(). MFC after: 1 week Notes: svn path=/head/; revision=161435
* Allow for setting negative priority (niceness) when $foo_user is non-root.Yaroslav Tykhiy2006-08-171-2/+7
| | | | | | | | | | | The order in _doit must be "nice su", not "su nice", for that. In addition, don't ignore the exit status from "cd $foo_chdir". Reviewed by: freebsd-rc (silence) MFC after: 1 week Notes: svn path=/head/; revision=161396
* Back out rev. 1.63. It was a poor idea becauseYaroslav Tykhiy2006-07-261-9/+15
| | | | | | | | | | test(1) is built in sh(1) and it always evaluates both sides of -a or -o, unlike && or || in sh(1). Requested by: dougb Notes: svn path=/head/; revision=160698
* Avoid extra runs of test(1) by using its built-in logical operations.Yaroslav Tykhiy2006-07-251-15/+9
| | | | Notes: svn path=/head/; revision=160670
* Sync comments around _doit with the code.Yaroslav Tykhiy2006-07-251-1/+2
| | | | Notes: svn path=/head/; revision=160668
* We notify of failures with err or warn.Yaroslav Tykhiy2006-07-251-2/+2
| | | | | | | | Messages should end in full stop unless that can lead to confusion. Notes: svn path=/head/; revision=160667
* Add diagnostics to load_kld().Yaroslav Tykhiy2006-07-251-4/+12
| | | | Notes: svn path=/head/; revision=160666
* Quite a number of rc.d scripts try to load kernel modules. ManyYaroslav Tykhiy2006-06-211-0/+39
| | | | | | | | | | | | | of them do that conditionally depending on kldstat. The code is duplicated all over, but bugs can be uniqie. To make the things more consistent, introduce a new rc.subr function, load_kld, which takes care of loading a kernel module conditionally. (Found this lying for a while in my p4 branch for various hacks.) Notes: svn path=/head/; revision=159828
* Remove the require_kld function I just committed and replace with a nicer ↵Florent Thoumie2006-05-181-29/+0
| | | | | | | | | | solution. Reported by: pjd Approved by: cperciva Notes: svn path=/head/; revision=158723
* Add two new scripts (mdconfig/mdconfig2) to replace old ramdisk{,-own}Florent Thoumie2006-05-181-0/+29
| | | | | | | | | | | | | | | | | | | | | | | scripts. These scripts handle vnode backed md(4) devices. Old ramdisk{,-own} scripts will stay a bit in CVS to allow some time for migration since variable names have changed (ramdisk_* -> mdconfig_*). Two new variables have been introduced to be able to populate the md(4) device once it has been mounted (mdconfig_*_files and mdconfig_*_cmd). Use should be as easy as: mdconfig_md0="-t malloc -s 10m" mdconfig_md1="-t vnode -f /var/foo.img" See rc.conf(5) for more information and description of the additional variables. Approved by: cperciva Notes: svn path=/head/; revision=158722
* - Move _rc_subr_loaded=: at the end of the file, to be consistent with NetBSD.Florent Thoumie2006-04-181-5/+8
| | | | | | | | | | | | | | | - Sync with latest version from NetBSD. 'In order to handle some perl scripts running as daemons, add a pattern which also matches "`basename $interpreter`: $command" in the ps listing.' Approved by: cperciva (mentor) Obtained from: NetBSD MFC after: 1 week Notes: svn path=/head/; revision=157841
* Use ps true power instead of tr/tail which aren't available early enough.Florent Thoumie2006-04-131-1/+1
| | | | | | | | | | PR: conf/95654 Submitted by: Rong-En Fan <rafan@infor.org> Noticed/Fix by: many people on freebsd-current@ Approved by: cperciva (mentor) Notes: svn path=/head/; revision=157710
* - If no pidfile has been created at startup, only stop processesFlorent Thoumie2006-04-111-4/+7
| | | | | | | | | | | | with current jid. PR: conf/93287 Submitted by: anders Approved by: cperciva (mentor) MFC after: 1 month Notes: svn path=/head/; revision=157657
* - Oops, add a missing "then".Florent Thoumie2006-04-111-1/+1
| | | | | | | Approved by: cperciva (mentor, implicit) Notes: svn path=/head/; revision=157656
* - Set a two read-only variables (${prefix} and ${etcdir}). This isFlorent Thoumie2006-04-111-14/+43
| | | | | | | | | | | | | | especially useful when using /etc/rc.d scripts with third-party software installed from ports. - Fix rc.d/sshd to work with openssh from ports using ${etcdir} instead of hardcoded /etc. Reviewed by: brooks Approved by: cperciva (mentor) MFC after: 1 week Notes: svn path=/head/; revision=157653