summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authordougb <dougb@FreeBSD.org>2012-02-14 10:51:24 +0000
committerdougb <dougb@FreeBSD.org>2012-02-14 10:51:24 +0000
commit5abebddb436aac4d1f396c82a98743aa0a774aa6 (patch)
tree25bb26903a57056ed6ba1543fab1af2635184b77 /etc
parenta6e5cd41ae1c223f22bef504edae255aea74c2e1 (diff)
downloadFreeBSD-src-5abebddb436aac4d1f396c82a98743aa0a774aa6.zip
FreeBSD-src-5abebddb436aac4d1f396c82a98743aa0a774aa6.tar.gz
Fix various issues with the NFS and RPC related scripts:
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.
Diffstat (limited to 'etc')
-rw-r--r--etc/defaults/rc.conf2
-rwxr-xr-xetc/rc.d/amd12
-rwxr-xr-xetc/rc.d/apmd10
-rwxr-xr-xetc/rc.d/keyserv8
-rwxr-xr-xetc/rc.d/lockd18
-rwxr-xr-xetc/rc.d/mountd10
-rwxr-xr-xetc/rc.d/nfsd22
-rwxr-xr-xetc/rc.d/statd17
-rwxr-xr-xetc/rc.d/ypbind14
-rwxr-xr-xetc/rc.d/yppasswdd21
-rwxr-xr-xetc/rc.d/ypserv13
-rwxr-xr-xetc/rc.d/ypset19
-rwxr-xr-xetc/rc.d/ypupdated16
-rwxr-xr-xetc/rc.d/ypxfrd19
-rw-r--r--etc/rc.subr15
15 files changed, 68 insertions, 148 deletions
diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf
index e8273d4..906151b 100644
--- a/etc/defaults/rc.conf
+++ b/etc/defaults/rc.conf
@@ -29,6 +29,8 @@ early_late_divider="FILESYSTEMS" # Script that separates early/late
# stages of the boot process. Make sure you know
# the ramifications if you change this.
# See rc.conf(5) for more details.
+always_force_depends="NO" # Set to check that indicated dependencies are
+ # running during boot (can increase boot time).
swapfile="NO" # Set to name of swapfile if aux swapfile desired.
apm_enable="NO" # Set to YES to enable APM BIOS functions (or NO).
diff --git a/etc/rc.d/amd b/etc/rc.d/amd
index e313f0c..2ed70eb 100755
--- a/etc/rc.d/amd
+++ b/etc/rc.d/amd
@@ -19,15 +19,8 @@ extra_commands="reload"
amd_precmd()
{
- if ! checkyesno nfs_client_enable; then
- force_depend nfsclient || return 1
- fi
-
- if ! checkyesno rpcbind_enable && \
- ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
- then
- force_depend rpcbind || return 1
- fi
+ force_depend nfsclient nfs_client || return 1
+ force_depend rpcbind || return 1
case ${amd_map_program} in
[Nn][Oo] | '')
@@ -49,7 +42,6 @@ amd_precmd()
command_args="> /var/run/amd.pid 2> /dev/null"
;;
esac
- return 0
}
load_rc_config $name
diff --git a/etc/rc.d/apmd b/etc/rc.d/apmd
index 2a326c1..beca912 100755
--- a/etc/rc.d/apmd
+++ b/etc/rc.d/apmd
@@ -19,24 +19,18 @@ apmd_prestart()
{
case `${SYSCTL_N} hw.machine_arch` in
i386)
- # Enable apm if it is not already enabled
- if ! checkyesno apm_enable && \
- ! /etc/rc.d/apm forcestatus 1>/dev/null 2>&1
- then
- force_depend apm || return 1
- fi
+ force_depend apm || return 1
# Warn user about acpi apm compatibility support which
# does not work with apmd.
if [ ! -e /dev/apmctl ]; then
- warn "/dev/apmctl not found; kernel is missing apm(4)"
+ warn "/dev/apmctl not found; kernel is missing apm(4)"
fi
;;
*)
return 1
;;
esac
- return 0
}
load_rc_config $name
diff --git a/etc/rc.d/keyserv b/etc/rc.d/keyserv
index 84b169a..33c631a 100755
--- a/etc/rc.d/keyserv
+++ b/etc/rc.d/keyserv
@@ -19,13 +19,7 @@ start_precmd="keyserv_prestart"
keyserv_prestart()
{
- if ! checkyesno rpcbind_enable && \
- ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
- then
- force_depend rpcbind || return 1
- fi
-
- return 0
+ force_depend rpcbind || return 1
}
load_rc_config $name
diff --git a/etc/rc.d/lockd b/etc/rc.d/lockd
index 135dda7..9704773 100755
--- a/etc/rc.d/lockd
+++ b/etc/rc.d/lockd
@@ -15,28 +15,16 @@ name="lockd"
rcvar=rpc_lockd_enable
command="/usr/sbin/rpc.${name}"
start_precmd='lockd_precmd'
-stop_precmd='checkyesno nfs_server_enable || checkyesno nfs_client_enable'
-status_precmd=$stop_precmd
# Make sure that we are either an NFS client or server, and that we get
# the correct flags from rc.conf(5).
#
lockd_precmd()
{
- local ret
- ret=0
-
- if ! checkyesno nfs_server_enable && ! checkyesno nfs_client_enable
- then
- ret=1
- fi
- if ! checkyesno rpcbind_enable && \
- ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
- then
- force_depend rpcbind || ret=1
- fi
+ force_depend rpcbind || return 1
+ force_depend statd rpc_statd || return 1
+
rc_flags=${rpc_lockd_flags}
- return ${ret}
}
load_rc_config $name
diff --git a/etc/rc.d/mountd b/etc/rc.d/mountd
index 826a158..f3ebfdb 100755
--- a/etc/rc.d/mountd
+++ b/etc/rc.d/mountd
@@ -19,11 +19,7 @@ extra_commands="reload"
mountd_precmd()
{
- if ! checkyesno rpcbind_enable && \
- ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
- then
- force_depend rpcbind || return 1
- fi
+ force_depend rpcbind || return 1
# mountd flags will differ depending on rc.conf settings
#
@@ -48,8 +44,8 @@ mountd_precmd()
fi
rm -f /var/db/mountdtab
- ( umask 022 ; > /var/db/mountdtab )
- return 0
+ ( umask 022 ; > /var/db/mountdtab ) ||
+ err 1 'Cannot create /var/db/mountdtab'
}
load_rc_config $name
diff --git a/etc/rc.d/nfsd b/etc/rc.d/nfsd
index 235a866..e067ad1 100755
--- a/etc/rc.d/nfsd
+++ b/etc/rc.d/nfsd
@@ -48,31 +48,15 @@ nfsd_precmd()
if checkyesno nfsv4_server_enable; then
sysctl vfs.nfsd.server_max_nfsvers=4 > /dev/null
- if ! checkyesno nfsuserd_enable && \
- ! /etc/rc.d/nfsuserd forcestatus 1>/dev/null 2>&1
- then
- if ! force_depend nfsuserd; then
- err 1 "Cannot run nfsuserd"
- fi
- fi
+ force_depend nfsuserd || err 1 "Cannot run nfsuserd"
else
echo 'NFSv4 is disabled'
sysctl vfs.nfsd.server_max_nfsvers=3 > /dev/null
fi
fi
- if ! checkyesno rpcbind_enable && \
- ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
- then
- force_depend rpcbind || return 1
- fi
-
- if ! checkyesno mountd_enable && \
- ! /etc/rc.d/mountd forcestatus 1>/dev/null 2>&1
- then
- force_depend mountd || return 1
- fi
- return 0
+ force_depend rpcbind || return 1
+ force_depend mountd || return 1
}
run_rc_command "$1"
diff --git a/etc/rc.d/statd b/etc/rc.d/statd
index 4e4a0a4..5119830 100755
--- a/etc/rc.d/statd
+++ b/etc/rc.d/statd
@@ -15,28 +15,15 @@ name="statd"
rcvar=rpc_statd_enable
command="/usr/sbin/rpc.${name}"
start_precmd='statd_precmd'
-stop_precmd='checkyesno nfs_server_enable || checkyesno nfs_client_enable'
-status_precmd=$stop_precmd
# Make sure that we are either an NFS client or server, and that we get
# the correct flags from rc.conf(5).
#
statd_precmd()
{
- local ret
- ret=0
-
- if ! checkyesno nfs_server_enable && ! checkyesno nfs_client_enable
- then
- ret=1
- fi
- if ! checkyesno rpcbind_enable && \
- ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
- then
- force_depend rpcbind || ret=1
- fi
+ force_depend rpcbind || return 1
+
rc_flags=${rpc_statd_flags}
- return ${ret}
}
load_rc_config $name
diff --git a/etc/rc.d/ypbind b/etc/rc.d/ypbind
index 4dbf351..71aea92 100755
--- a/etc/rc.d/ypbind
+++ b/etc/rc.d/ypbind
@@ -11,22 +11,20 @@
. /etc/rc.subr
name="ypbind"
-command="/usr/sbin/${name}"
-start_precmd="ypbind_precmd"
+rcvar="nis_client_enable"
load_rc_config $name
-rcvar="nis_client_enable"
+
+command="/usr/sbin/${name}"
command_args="${nis_client_flags}"
+start_precmd="ypbind_precmd"
+
ypbind_precmd()
{
local _domain
- if ! checkyesno rpcbind_enable && \
- ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
- then
- force_depend rpcbind || return 1
- fi
+ force_depend rpcbind || return 1
_domain=`domainname`
if [ -z "$_domain" ]; then
diff --git a/etc/rc.d/yppasswdd b/etc/rc.d/yppasswdd
index fbb80bc..cc25d9f 100755
--- a/etc/rc.d/yppasswdd
+++ b/etc/rc.d/yppasswdd
@@ -11,27 +11,22 @@
. /etc/rc.subr
name="yppasswdd"
-command="/usr/sbin/rpc.${name}"
-start_precmd="yppasswdd_precmd"
+rcvar="nis_yppasswdd_enable"
load_rc_config $name
-rcvar="nis_yppasswdd_enable"
+
+command="/usr/sbin/rpc.${name}"
command_args="${nis_yppasswdd_flags}"
+start_precmd="yppasswdd_precmd"
+
yppasswdd_precmd()
{
local _domain
- if ! checkyesno rpcbind_enable && \
- ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
- then
- force_depend rpcbind || return 1
- fi
- if ! checkyesno nis_server_enable && \
- ! /etc/rc.d/ypserv forcestatus 1>/dev/null 2>&1
- then
- force_depend ypserv || return 1
- fi
+ force_depend rpcbind || return 1
+ force_depend ypserv nis_server || return 1
+
_domain=`domainname`
if [ -z "$_domain" ]; then
warn "NIS domainname(1) is not set."
diff --git a/etc/rc.d/ypserv b/etc/rc.d/ypserv
index 8e17fd7..90e7061 100755
--- a/etc/rc.d/ypserv
+++ b/etc/rc.d/ypserv
@@ -11,21 +11,20 @@
name="ypserv"
rcvar="nis_server_enable"
-command="/usr/sbin/${name}"
-start_precmd="ypserv_prestart"
load_rc_config $name
+
+command="/usr/sbin/${name}"
command_args="${nis_server_flags}"
+start_precmd="ypserv_prestart"
+
ypserv_prestart()
{
local _domain
- if ! checkyesno rpcbind_enable && \
- ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
- then
- force_depend rpcbind || return 1
- fi
+ force_depend rpcbind || return 1
+
_domain=`domainname`
if [ -z "$_domain" ]; then
warn "NIS domainname(1) is not set."
diff --git a/etc/rc.d/ypset b/etc/rc.d/ypset
index 78c408b..f725545 100755
--- a/etc/rc.d/ypset
+++ b/etc/rc.d/ypset
@@ -11,25 +11,20 @@
name="ypset"
rcvar="nis_ypset_enable"
-command="/usr/sbin/${name}"
-start_precmd="ypset_precmd"
+
load_rc_config $name
+
+command="/usr/sbin/${name}"
command_args="${nis_ypset_flags}"
+start_precmd="ypset_precmd"
+
ypset_precmd()
{
local _domain
- if ! checkyesno rpcbind_enable && \
- ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
- then
- force_depend rpcbind || return 1
- fi
- if ! checkyesno nis_client_enable && \
- ! /etc/rc.d/ypbind forcestatus 1>/dev/null 2>&1
- then
- force_depend ypbind || return 1
- fi
+ force_depend rpcbind || return 1
+ force_depend ypbind nis_client || return 1
_domain=`domainname`
if [ -z "$_domain" ]; then
diff --git a/etc/rc.d/ypupdated b/etc/rc.d/ypupdated
index 98ef203..4098bd7 100755
--- a/etc/rc.d/ypupdated
+++ b/etc/rc.d/ypupdated
@@ -11,6 +11,9 @@
name="ypupdated"
rcvar="rpc_ypupdated_enable"
+
+load_rc_config $name
+
command="/usr/sbin/rpc.${name}"
start_precmd="rpc_ypupdated_precmd"
@@ -18,16 +21,8 @@ rpc_ypupdated_precmd()
{
local _domain
- if ! checkyesno rpcbind_enable && \
- ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
- then
- force_depend rpcbind || return 1
- fi
- if ! checkyesno nis_server_enable && \
- ! /etc/rc.d/ypserv forcestatus 1>/dev/null 2>&1
- then
- force_depend ypserv || return 1
- fi
+ force_depend rpcbind || return 1
+ force_depend ypserv nis_server || return 1
_domain=`domainname`
if [ -z "$_domain" ]; then
@@ -36,5 +31,4 @@ rpc_ypupdated_precmd()
fi
}
-load_rc_config $name
run_rc_command "$1"
diff --git a/etc/rc.d/ypxfrd b/etc/rc.d/ypxfrd
index f125a30..63924e4 100755
--- a/etc/rc.d/ypxfrd
+++ b/etc/rc.d/ypxfrd
@@ -11,25 +11,20 @@
name="ypxfrd"
rcvar="nis_ypxfrd_enable"
-command="/usr/sbin/rpc.${name}"
-start_precmd="ypxfrd_precmd"
+
load_rc_config $name
+
+command="/usr/sbin/rpc.${name}"
command_args="${nis_ypxfrd_flags}"
+start_precmd="ypxfrd_precmd"
+
ypxfrd_precmd()
{
local _domain
- if ! checkyesno rpcbind_enable && \
- ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
- then
- force_depend rpcbind || return 1
- fi
- if ! checkyesno nis_server_enable && \
- ! /etc/rc.d/ypserv forcestatus 1>/dev/null 2>&1
- then
- force_depend ypserv || return 1
- fi
+ force_depend rpcbind || return 1
+ force_depend ypserv nis_server || return 1
_domain=`domainname`
if [ -z "$_domain" ]; then
diff --git a/etc/rc.subr b/etc/rc.subr
index 0da7c07..e629bc7 100644
--- a/etc/rc.subr
+++ b/etc/rc.subr
@@ -71,22 +71,29 @@ set_rcvar_obsolete()
}
#
-# force_depend script
+# force_depend script [rcvar]
# Force a service to start. Intended for use by services
-# to resolve dependency issues. It is assumed the caller
-# has check to make sure this call is necessary
+# to resolve dependency issues.
# $1 - filename of script, in /etc/rc.d, to run
+# $2 - name of the script's rcvar (minus the _enable)
#
force_depend()
{
+ local _depend _dep_rcvar
+
_depend="$1"
+ _dep_rcvar="${2:-$1}_enable"
+
+ [ -n "$rc_fast" ] && ! checkyesno always_force_depends &&
+ checkyesno $_dep_rcvar && return 0
+
+ /etc/rc.d/${_depend} forcestatus >/dev/null 2>&1 && return 0
info "${name} depends on ${_depend}, which will be forced to start."
if ! /etc/rc.d/${_depend} forcestart; then
warn "Unable to force ${_depend}. It may already be running."
return 1
fi
- return 0
}
#
OpenPOWER on IntegriCloud