summaryrefslogtreecommitdiffstats
path: root/etc/rc.subr
Commit message (Collapse)AuthorAgeFilesLines
* Refactor the root mount hold code and add the wait to etc/rc.d/fsck.trasz2016-05-101-0/+31
| | | | | | | | | | | This fixes mounting (non-root) USB drives on boot with fsck enabled (with non-zero 'Pass#' field in fstab(5)). Reported by: Graham Menhennitt <graham at menhennitt.com.au> Reviewed by: jilles@ MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D6221
* - Add two new subcommands to rc.subr:lme2016-04-231-3/+18
| | | | | | | | | | "describe" shows an rc script's description "extracommands" shows an rc script's non-standard commands like "reload", "configtest", "keygen", etc - Update the rc(8) manpage and the tcsh(1) completion examples to reflect these changes Approved by: bapt Sponsored by: Essen Linuxhotel Hackathon 2016 Differential Revision: D452
* - Add a global option where we can protect processes when swap spacearaujo2016-02-241-1/+25
| | | | | | | | | | | | | | | | | | | | | | is exhausted. How to use: Basically we need to add on rc.conf an another option like: If we want to protect only the main processes. syslogd_oomprotect="YES" If we want to protect all future children of the specified processes. syslogd_oomprotect="ALL" PR: 204741 (based on) Submitted by: eugen@grosbein.net Reviewed by: jhb, allanjude, rpokala and bapt MFC after: 4 weeks Relnotes: Yes Sponsored by: gandi.net Differential Revision: https://reviews.freebsd.org/D5176
* rc.subr: Check for running daemons before a custom start_cmd is executed.jilles2015-12-041-8/+8
| | | | | | | | | | | | | | | | | Currently rc scripts implementing their own start_cmd do not enjoy the benefits of rc.subr's own check for rc_pid. This leads to around a third of ports with such a start_cmd not to check for the process at all and two thirds of ports to re-implement this check (sometimes wrongly). This patch moves the check for rc_pid to before ${rc_arg}_cmd is executed. Submitted by: Dirk Engling Reviewed by: feld MFC after: 1 week Relnotes: yes Differential Revision: https://reviews.freebsd.org/D4156
* Correctly document the change made in r275359.des2015-10-261-2/+4
|
* Enforce consistent limits of daemons run from rc.subr:adrian2015-09-271-1/+6
| | | | | | | | | | | | * Allow the user to configure the login class to use in rc.conf by using {daemon}_login_class, which; * Use the daemon class by default; * .. and then use 'limits' to set the login class so it works both via init at startup (which runs this in 'daemon' class) and via whichever root environment (eg command line, other daemons, etc.) Reviewed by: dteske Differential Revision: https://reviews.freebsd.org/D3630
* Update the comment about handling old-style rc(5) scriptsngie2015-08-051-2/+5
| | | | | The old-style (*.sh) scripts in /etc/rc.d are explicitly ignored, whereas other scripts ending in .sh are permitted
* rc.subr: Allow rc.conf.d with multi-directory local_startup.jilles2015-08-011-1/+2
| | | | | | | | | I also changed ${...%*/rc.d} to ${...%/rc.d} since the shortest match always has an empty string for the asterisk. PR: 201641 Submitted by: Jamie Landeg-Jones (original version) MFC after: 1 week
* Allow load_rc_config to be called without a service name.des2014-12-011-17/+18
| | | | MFC after: 1 week
* Add env and prepend to _rc_namevarlist.hrs2014-10-121-1/+1
|
* Add ${name}_env and ${name}_prepend. ${name}_env is an argument list whichhrs2014-10-111-1/+11
| | | | | will be passed to env(1). ${name}_prepend is simply prepended to the command line for $command.
* Resurrect set_rcvar() as a function to define a rc.conf variable.hrs2014-10-021-5/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | It defines a variable and its default value in load_rc_config() just after rc.conf is loaded. "rcvar" command shows the current and the default values. This is an attempt to solve a problem that rc.d scripts from third-party software do not have entries in /etc/defaults/rc.conf. The fact that load_rc_config() reads rc.conf only once and /etc/rc invokes the function before running rc.d scripts made developers confused for a long time because load_rc_config() just before run_rc_command() in each rc.d script overrides variables only when the script is directly invoked, not from /etc/rc. Variables defined in set_rcvar are always set in load_rc_config() after loading rc.conf. An rc.d script can now be written in a self-contained manner regarding the related variables as follows: --- name=foo rcvar=foo_enable set_rcvar foo_enable YES "Enable $name" set_rcvar foo_flags "-s" "Flags to $name" ... load_rc_config $name run_rc_command "$@" ---
* Do not set net.inet.ip.{sourceroute,accept_sourceroute} in a vnet jail.hrs2014-09-131-0/+16
| | | | | | | The following warnings were displayed: sysctl: net.inet.ip.sourceroute=0: Operation not permitted sysctl: net.inet.ip.accept_sourceroute=0: Operation not permitted
* - Use $local_startup to load rc.conf.d/* scripts.hrs2014-08-271-17/+16
| | | | | | - Document support of rc.conf.d/<dir>/* introduced in r270392. Discussed with: bapt
* Allow to configure services from ${LOCALBASE}/etc/rc.conf.dbapt2014-08-261-0/+4
| | | | | | Reviewed by: bdrewery MFC after: 1 week Relnotes: yes
* Add support for /etc/rc.conf.d/<service> subdirectories. This isdes2014-08-231-1/+9
| | | | | | | | particularly useful for services such as "network" (netif) where each interface can now have its own separate configuration file. Add /etc/rc.conf.d to the mtree file so it is always present. MFC after: 3 days
* Loosen the processing of *_IF_aliasN vars to be less strict. Previously,dteske2014-04-071-8/+267
| | | | | | | | | | | the first alias had to be _alias0 and processing stopped at the first non- defined variable (preventing gaps). Allowing gaps gives the administrator the ability to group aliases in an adhoc manner and also lifts the requirement to renumber aliases simply to comment-out an existing one. Aliases are processed in numerical ascending order. Discussed on: -rc MFC after: 1 week
* - Update rc.d/jail to use a jail(8) configuration file instead ofhrs2013-10-101-22/+0
| | | | | | | | | | | | command line options. The "jail_<jname>_*" rc.conf(5) variables for per-jail configuration are automatically converted to /var/run/jail.<jname>.conf before the jail(8) utility is invoked. This is transparently backward compatible. - Fix a minor bug in jail(8) which prevented it from returning false when jail -r failed. Approved by: re (glebius)
* Add a setup script for unbound(8) called local-unbound-setup. Itdes2013-09-231-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | generates a configuration suitable for running unbound as a caching forwarding resolver, and configures resolvconf(8) to update unbound's list of forwarders in addition to /etc/resolv.conf. The initial list is taken from the existing resolv.conf, which is rewritten to point to localhost. Alternatively, a list of forwarders can be provided on the command line. To assist this script, add an rc.subr command called "enabled" which does nothing except return 0 if the service is enabled and 1 if it is not, without going through the usual checks. We should consider doing the same for "status", which is currently pointless. Add an rc script for unbound, called local_unbound. If there is no configuration file, the rc script runs local-unbound-setup to generate one. Note that these scripts place the unbound configuration files in /var/unbound rather than /etc/unbound. This is necessary so that unbound can reload its configuration while chrooted. We should probably provide symlinks in /etc. Approved by: re (blanket)
* rc.subr: disabling globbing while processing devfs rulesavg2013-03-281-1/+7
| | | | | | | | The rules themselves typically have shell-like patterns and it is incorrect when they get replaced with matching filesystem entries. Shell magic by: jilles MFC after: 2 weeks
* Allow perl scripts to be used in rc.d scriptssmh2013-01-101-1/+1
| | | | | | | PR: conf/117027 Reviewed by: pjd (mentor) Approved by: hrs MFC after: 2 weeks
* Do not put "already running" message when rc_quiet=yes.hrs2012-11-201-1/+4
| | | | PR: bin/165477
* Add check_namevarlist() to check if ${name}_var is reserved in rc.subr or not.hrs2012-11-171-0/+17
|
* Add setfib(1) support for services as <name>_fib in rc.conf.hrs2012-10-271-1/+6
|
* Allow spaces in _chrootcrees2012-10-271-3/+3
| | | | | | Noticed by: adj (IRC/#bsdports) Approved by: hrs MFC after: 1 month
* Whitespace nitkevlo2012-07-131-2/+2
|
* Put the signal trap output to standard error instead of standard output.delphij2012-02-181-3/+3
| | | | | | | | | | | Without this change, pressing ^T could result in rc.d script putting junk strings like: Script <filename> running in configuration files when redirecting standard output to these files. MFC after: 2 weeks
* Fix various issues with the NFS and RPC related scripts:dougb2012-02-141-4/+11
| | | | | | | | | | | | | | | | | | | 1. Add new functionality to the force_depend method to incorporate the tests for whether the service is enabled and/or already running. 2. Add a new option to bypass checking only that the service is enabled at boot time, and always check if it is running. 3. Use this new functionality to greatly simplify the rc.d scripts that use force_depend. 4. Add a force_depend for statd in lockd 5. Remove the check that either nfs_server or nfs_client is _enable'd from statd and lockd. This was always overkill, and prevented using the {one|force}start options, as well as stop'ing on the command line. 6. The yp* scripts had some of their arguments in various weird orders. Bring them into line with the model. 7. If mountd fails to create /var/db/mountdtab, err out. Ideas, suggestions, and/or review from delphij and jilles. Pointy hats are completely my responsibility however.
* If we're booting there is no need to waste time determining if the servicedougb2012-01-201-1/+1
| | | | | | | is running or not. PR: conf/150752 Submitted by: YIN Xiaofeng <75394094@qq.com>
* Now that its callers have been udpated, remove set_rcvar().dougb2012-01-141-46/+5
| | | | | | The concept of set_rcvar() was nice in theory, but the forks it creates are a drag on the startup process, which is especially noticeable on slower systems, such as embedded ones.
* rc.d: document 'quiet' prefix and fix dhclient/devd interactionrea2012-01-121-1/+1
| | | | | | | | | | | | | | | | | | | | | Document the current semantics of the 'quiet' command prefix in the rc.subr(8). Fix dhclient rc.d script: it should not call err() for non-DHCP-enabled interface when it is called from devd, because the latter just blindly calls 'service dhclient quietstart' on each "link up" event. Since the 'quietstart' will silence the message "Cannot 'start' <foo>. Set <foo>_enable to YES in /etc/rc.conf or use 'onestart' instead of 'start'." and running dhclient on the non-DHCP-enabled interface is the same thing as running the service <foo> without <foo>_enable set, such modification is in sync with the current semantics of the 'quiet' prefix. Approved by: glebius Reviewed by: freebsd-rc list MFC after: 2 weeks
* There is no longer a need to abstract ${rcvar_manpage} as we are notdougb2012-01-081-2/+1
| | | | attempting to maintain compatibility with NetBSD for some years now.
* Spelling fixes for etc/uqs2012-01-071-1/+1
|
* rc.d: Eliminate some unnecessary non-POSIX constructs:jilles2011-11-081-1/+1
| | | | | | * set - ... * empty braces * ^ in character class
* rc.subr: Make sure all functions are under if [ -z "${_rc_subr_loaded}" ].jilles2011-06-191-2/+2
|
* rc.subr: Eliminate a fork from check_kern_features, like r223227.jilles2011-06-191-1/+1
| | | | MFC after: 2 weeks
* rc.subr: Eliminate about 100 forks from the boot sequence.jilles2011-06-181-5/+5
| | | | | | | | | | | | With the current sh, placing eval in a command substitution always results in a fork(), even if it is the only command and only executes a single simple command. Therefore, avoid it where it can be avoided easily. Side effect: values starting with a hyphen and all whitespace are preserved. The values are defaults and names for rc.conf variables and messages to be given about obsolete ones. MFC after: 2 weeks
* Add a helper function to check kern.features.* sysctls.hrs2011-06-111-0/+22
| | | | Discussed with: dougb
* As previously advertised, remove the error message for enable_quotasdougb2011-04-231-4/+0
| | | | | | prior to 9.0-RELEASE. This change should not be MFC'ed.
* Improve the error handling for the new get_pidfile_from_conf()dougb2011-04-231-2/+6
|
* Introduce to rc.subr get_pidfile_from_conf(). It does just what it soundsdougb2011-04-231-0/+39
| | | | | | | | | like, determines the path to a pid file as it is specified in a conf file. Use the new feature for rc.d/named and rc.d/devd, the 2 services in the base that list their pid files in their conf files. Remove the now-obsolete named_pidfile, and warn users if they have it set.
* The change in r206686 to allow the stop argument to work for a servicedougb2011-04-171-1/+2
| | | | | | | | | | | | | | that is running even though not _enable'd had an annoying side effect. If the service was already started at boot time by another means when the related script came around again in rcorder it would start again, regardless of _enable, because there was a valid pid. [1] So, split the test into 2 parts, one for (!rcvar && !stop), and one for (stop && !valid_pid). This preserves the behavior from r206686 while preventing the undesired side effect. PR: conf/156427 [1] Submitted by: Eugene Grosbein <eugen@grosbein.pp.ru> [1]
* Revert r219578dougb2011-03-131-3/+3
|
* Use the allexport option in load_rc_config() in order to avoid havingdougb2011-03-121-3/+3
| | | | | | | | | | | | | | to repeatedly read the conf files. Depending on what is enabled the files are being read anywhere from 15, 30, or more times currently. By loading the values in the environment this is reduced to 1, with perhaps a couple more, again depending on what is enabled. The speed-up for boot and shutdown is negligible when rc.conf is on local disk, noticable when accessing files over NFS, and dramatic when pulling rc.conf values from a database. This change also includes a minor optimization to the conditional for $_rc_conf_loaded.
* Warn if rules could not be read from a ruleset file. Now at leastjh2011-01-071-1/+4
| | | | | | | something gets logged if the file has syntax errors. PR: conf/91342 Silence on: freebsd-rc
* Fix silly typo on my part (s/quotas_enable/quota_enable/)dougb2010-08-141-1/+1
| | | | Submitted by: ed
* Give people some warning before removing enable_quotasdougb2010-08-141-2/+2
|
* If a service is running, make 'stop' work even if ${name}_enabledougb2010-04-151-3/+3
| | | | | | | | is not set. PR: conf/130414 Submitted by: Dominic Fandrey <kamikaze@bsdforen.de> Reviewed by: freebsd-rc@
* In wait_for_pids(), pwait(1) can return when the process exits, butdougb2010-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.
* Convert to 2-clause license, from NetBSD rc.subr r1.70.emaste2010-01-261-7/+0
| | | | | Submitted by: Alex Kozlov Obtained from: NetBSD
OpenPOWER on IntegriCloud