summaryrefslogtreecommitdiffstats
path: root/etc/rc.subr
Commit message (Collapse)AuthorAgeFilesLines
...
* Allow for /usr/bin/env when parsing the shebang line from anyar2006-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
* MFp4:yar2006-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
* Teach find_processes() to use ${name}_chroot.flz2006-11-261-2/+2
| | | | | Obtained from: NetBSD X-MFC after: 6.2-RELEASE
* Remove leading dollar sign in rcvar command output.flz2006-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
* debug() shouldn't misidentify itself to logger(1).yar2006-10-021-1/+1
| | | | Noticed by: David Thompson <dat1965 yahoo com>
* Backout this commit since it breaks startup and some scripts inflz2006-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)
* Eliminate header line(s) from ps(1) output instead of skipping over them.yar2006-08-181-5/+2
|
* The ps(1) command is unfriendly to scripts by default becauseyar2006-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
* Allow for setting negative priority (niceness) when $foo_user is non-root.yar2006-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
* Back out rev. 1.63. It was a poor idea becauseyar2006-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
* Avoid extra runs of test(1) by using its built-in logical operations.yar2006-07-251-15/+9
|
* Sync comments around _doit with the code.yar2006-07-251-1/+2
|
* We notify of failures with err or warn.yar2006-07-251-2/+2
| | | | | Messages should end in full stop unless that can lead to confusion.
* Add diagnostics to load_kld().yar2006-07-251-4/+12
|
* Quite a number of rc.d scripts try to load kernel modules. Manyyar2006-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.)
* Remove the require_kld function I just committed and replace with a nicer ↵flz2006-05-181-29/+0
| | | | | | | solution. Reported by: pjd Approved by: cperciva
* Add two new scripts (mdconfig/mdconfig2) to replace old ramdisk{,-own}flz2006-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
* - Move _rc_subr_loaded=: at the end of the file, to be consistent with NetBSD.flz2006-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
* Use ps true power instead of tr/tail which aren't available early enough.flz2006-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)
* - If no pidfile has been created at startup, only stop processesflz2006-04-111-4/+7
| | | | | | | | | with current jid. PR: conf/93287 Submitted by: anders Approved by: cperciva (mentor) MFC after: 1 month
* - Oops, add a missing "then".flz2006-04-111-1/+1
| | | | Approved by: cperciva (mentor, implicit)
* - Set a two read-only variables (${prefix} and ${etcdir}). This isflz2006-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
* - Sync rc.subr with NetBSD.flz2006-04-041-10/+34
| | | | | | | | | - Merge some documentation bits. Reviewed by: brooks, simon (doc) Approved by: cperciva (mentor) Obtained from: NetBSD MFC after: 3 days
* Harmless typo (s/overide/override/).flz2006-03-231-2/+2
| | | | | Approved by: cperciva MFC after: 3 days
* Update a comment to match functionality changed in r1.39 (allow squareceri2006-02-151-0/+1
| | | | | | brackets in process names). MFC after: 2 days
* Don't include geli devices in list when noauto is specified in the options ↵flz2006-02-121-1/+10
| | | | | | | field. Approved by: pjd MFC after: 3 days
* Silence a warning about empty directories in all the places it mightdougb2005-12-101-1/+1
| | | | | | occur. Reminded by: yar
* Since rc.subr is a library of functions, it should not use exityar2005-12-061-6/+6
| | | | | | | | | | | | every now and then. It is up to the caller to choose a proper action upon an error condition. Therefore, use return, not exit, except for some special cases. Consistently return 1 to indicate an error. Submitted by: sem (initially) Reviewed by: freebsd-rc (silence) MFC after: 2 weeks
* Change how *.sh scripts are handled. If the script is in /etc/rc.d,dougb2005-12-051-2/+2
| | | | | | | | source it into the shell. If not, handle it in a subshell the same way that "real" rc.d-style scripts are handled. This will dramatically ease the "process local scripts in the base rcorder" transition. Add *.bak to the list of files in */rc.d that we ignore.
* Introduce startup scripts from the local_startup directories todougb2005-12-021-0/+38
| | | | | | | | | | | | | | | | the base rcorder. This is accomplished by running rcorder twice, first to get all the disks mounted (through mountcritremote), then again to include the local_startup directories. This dramatically changes the behavior of rc.d/localpkg, as all "local" scripts that have the new rc.d semantics are now run in the base rcorder, so only scripts that have not been converted yet will run in rc.d/localpkg. Make a similar change in rc.shutdown, and add some functions in rc.subr to support these changes. Bump __FreeBSD_version to reflect this change.
* Avoid invoking the current script again when we needyar2005-11-161-2/+3
| | | | | | | | | | | | | | to issue sub-commands, e.g., restart = stop + start. By calling run_rc_command instead, we provide rc.d scripts with full control over their configuration variables. For an example problem the former approach caused, see http://lists.freebsd.org/pipermail/freebsd-rc/2005-October/000311.html Reviewed by: freebsd-rc Tested by: Dirk Engling erdgeist <at> erdgeist.org MFC after: 2 weeks
* Override $command with $foo_program only if $commandyar2005-10-261-3/+1
| | | | | | | | | | has been set in the first place. This should reduce unwanted side-effects in rc.d scripts that don't mean to use $command and rc.subr(8) methods associated with it at all. Discussed with: brooks Reviewed by: -rc (silence)
* Document that `reload' is not provided by defaultyar2005-10-261-0/+2
| | | | yet it can be enabled when applicable.
* o Grammar.maxim2005-10-241-1/+1
| | | | | Submitted by: Ulrich Spoerlein MFC after: 1 week
* Allow the process name to be in square brackets ([]) in _find_processes().jhb2005-10-171-1/+1
| | | | | | PR: conf/82430 Submitted by: Pavel Volkov pol at iib dot ru MFC after: 1 week
* Fix the usage of rc_usage. The rc_usage function takesyar2005-10-011-3/+3
| | | | | | a list of possible keywords, not all them in a single argument. This also fixes the issue of extra delimiter characters appearing on the help line from rc.d scripts not setting $extra_commands.
* Stop hard-coding an -M flag to mdmfs(8) in /etc/rc.subr.yar2005-08-241-1/+1
| | | | | | | | | | | Now this flag can be set, or not set, for memory-backed file systems on individual basis, as illustrated by the rc.conf(5) variables tmpmfs_flags and varmfs_flags. The flag is set for those FS'en by default, in /etc/defaults/rc.conf, in order to stay compatible with the old rc.subr behaviour. Submitted by: marck MFC after: 3 days
* Add scripts for GELI device configuration on boot.pjd2005-08-141-0/+34
| | | | | | | | | | rc.d/geli - configures encryption (ask for passphrases, etc.); rc.d/geli2 - is called after file systems are mounted and mark devices for detach on last close. Sponsored by: Wheel Sp. z o.o. http://www.wheel.pl MFC after: 3 days
* Move 'local_tr' function to rc.subr and change its name to 'ltr'.pjd2005-08-141-0/+23
| | | | MFC after: 3 days
* Style: mostly tabs vs blanks, and semicolon placement.schweikh2005-05-221-26/+26
|
* Cosmetic typo in check_pidfile()keramida2005-01-091-1/+1
| | | | | PR: bin/75946 Submitted by: zero@gddn.org (Finn)
* Add two new rc.conf options: tmpmfs_flags and varmfs_flags.keramida2004-11-091-3/+3
| | | | | | | | | | | | | | These can be used to pass extra options to the mdmfs(8) utility, to customize the finer details of the md file system creation (i.e. to turn on/off softupdates, to specify a default owner for md filesystem, etc). Use these two new flags to mount tmpmfs and varmfs without softupdates, since it doesn't make much sense to use SU on malloc-backed file systems. Reviewed by: mtm Inspired by: J. D. Bronson, jbronson at wixb dot com
* Finish cleanup of rc.d/netif. It's now possible to start/stop moremtm2004-07-301-7/+13
| | | | | | | | | | | than one interface from the command line: # /etc/rc.d/netif start bfe0 xl0 It's also possible to restart an interface(s): # /etc/rc.d/netif restart bfe0 This required some changes to rc.subr(8) so that if the start/stop commands are overidden the rest of the command line (after the start/stop/etc... cmd) is passed through to the subroutines.
* Wrap rc.subr insidecperciva2004-07-041-0/+6
| | | | | | | | | | | if [ -z "${_rc_subr_loaded}" ]; then _rc_subr_loaded="YES" ... fi in order to avoid re-interpreting rc.subr every time an rc.d script is run. In my tests, this speeds up rc time by about 8-10%.
* Make the stop command respect the 'fast' prefix.mtm2004-06-261-3/+4
| | | | | | | | Most notably, this cleans up messages when shutting down from single user. In such a case there are usually no daemons running, but their pid files are still in /var/run. This causes rc.d to output diagnostics about daemons with pidfiles, but that are not running.
* Fix typo.mtm2004-06-241-1/+1
| | | | Submitted by: kuriyama
* Restore pre-rcNG behaviour:mtm2004-06-061-3/+2
| | | | | | | SIGINT (Ctrl-c) kills the current script SIGQUIT (Ctrl-\) kills /etc/rc (dropping you into single-user) Prodded by: harti
* Overhaul the /etc/rc.d/diskless script by splitting it out intobrooks2004-03-231-0/+13
| | | | | | | | | | hostname, resolve, tmp, and var scripts. The latter three are new and were repo copied. These scripts no longer depend on being booted with and NFS root instead attempt to automaticly create mfs /tmp and /var volumes if the they are not writable. This behavior can be overridden in /etc/rc.conf. Reviewed by: luigi, pjd
* Some (most?) processes don't cleanup their pid files whenmtm2004-03-031-1/+1
| | | | | | | | | | | they exit. Sometimes they simply can't (core-dump, for example). So, when searching for a running program send standard error output from ps(1) to never-never land. # This should quite those # ps: kvm_getprocs: No such user # errors. Since ports use a duplicate rc.subr(8) you might # still see this error from ports startup scripts.
* NetBSD rev. 1.61mtm2004-02-271-6/+16
| | | | | | | | | | | | | | | | Implement ``one'' prefix to allow a "one shot" operation as if ${rcvar}=yes yet all the other prerequisite tests are still performed. The existing ``force'' prefix is a sledgehammer that ignores all the prerequisite checks and always returns a zero exit status; this is a more gentle approach to the problem of "manipulate this disabled service without editing rc.conf(5)". Obtained From: NetBSD # We have a work-around in our version of rc.subr that # makes force* return a non-zero exit status if the # command/service could not be acted upon. The work-around # is no longer necessary and should be removed.
OpenPOWER on IntegriCloud