[Midnightbsd-cvs] src: etc/rc.d: ramdisk and ramdisk-own -> mdconfig and mdconfig2 statd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Jan 17 17:23:55 EST 2009


Log Message:
-----------
ramdisk and ramdisk-own -> mdconfig and mdconfig2
statd is from nfslocking

Modified Files:
--------------
    src/etc/rc.d:
        Makefile (r1.15 -> r1.16)

Added Files:
-----------
    src/etc/rc.d:
        mdconfig (r1.1)
        mdconfig2 (r1.1)
        statd (r1.1)

Removed Files:
-------------
    src/etc/rc.d:
        ramdisk
        ramdisk-own

-------------- next part --------------
--- etc/rc.d/ramdisk
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/bin/sh -
-#
-# Copyright (c) 2004  The FreeBSD Project
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-#    notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-#    notice, this list of conditions and the following disclaimer in the
-#    documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-# $FreeBSD: src/etc/rc.d/ramdisk,v 1.4 2004/10/07 13:55:26 mtm Exp $
-# $MidnightBSD: src/etc/rc.d/ramdisk,v 1.2 2006/08/28 02:47:46 laffer1 Exp $
-
-# PROVIDE: ramdisk
-# REQUIRE: localswap
-# BEFORE: mountcritlocal
-
-. /etc/rc.subr
-
-name="ramdisk"
-stop_cmd="ramdisk_stop"
-start_cmd="ramdisk_start"
-
-ramdisk_start()
-{
-	for unit in $ramdisk_units; do
-		eval mdoptions=\$ramdisk_${unit}_config
-		if [ "$mdoptions" = "${mdoptions##-t}" ]; then
-			echo "Type not specified for md$unit"
-			continue
-		fi
-		eval fsoptions=\$ramdisk_${unit}_newfs
-
-		mdconfig -a $mdoptions -u $unit
-		newfs $fsoptions /dev/md$unit
-	done
-}
-
-ramdisk_stop()
-{
-	for unit in $ramdisk_units
-	do
-		if [ -c /dev/md$unit ]; then
-			umount -f /dev/md$unit > /dev/null 2>&1
-			mdconfig -d -u $unit
-		fi
-	done
-}
-
-load_rc_config $name
-run_rc_command "$1"
-
--- /dev/null
+++ etc/rc.d/statd
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# FreeBSD History: src/etc/rc.d/nfslocking,v 1.11 2004/10/07 13:55:26 mtm Exp
+# $FreeBSD: src/etc/rc.d/statd,v 1.17.6.1 2008/01/28 07:58:31 dougb Exp $
+# $MidnightBSD: src/etc/rc.d/statd,v 1.1 2009/01/17 22:23:54 laffer1 Exp $
+
+# PROVIDE: statd
+# REQUIRE: nfsserver nfsclient nfsd rpcbind
+# BEFORE:  DAEMON
+# KEYWORD: nojail
+
+. /etc/rc.subr
+
+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
+	rc_flags=${rpc_statd_flags}
+	return ${ret}
+}
+
+load_rc_config $name
+run_rc_command $1
--- /dev/null
+++ etc/rc.d/mdconfig
@@ -0,0 +1,198 @@
+#!/bin/sh
+#
+# Copyright (c) 2006  The FreeBSD Project
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD: src/etc/rc.d/mdconfig,v 1.5 2007/08/25 00:19:17 matteo Exp $
+# $MidnightBSD: src/etc/rc.d/mdconfig,v 1.1 2009/01/17 22:23:54 laffer1 Exp $
+
+# PROVIDE: mdconfig
+# REQUIRE: localswap
+# BEFORE: mountcritlocal
+
+. /etc/rc.subr
+
+name="mdconfig"
+stop_cmd="mdconfig_stop"
+start_cmd="mdconfig_start"
+start_precmd='[ -n "${_mdconfig_list}" ]'
+required_modules="geom_md:g_md"
+
+is_readonly()
+{
+	local _mp _ret
+
+	_mp=$1
+	_ret=`mount | while read _line; do
+		case ${_line} in
+		*" ${_mp} "*read-only*)
+			echo "yes"
+			;;
+		
+		*)
+			;;
+		esac;
+	done`
+
+	if [ -n "${_ret}" ]; then
+		return 0
+	else
+		return 1
+	fi
+}
+
+init_variables()
+{
+	local _i
+
+	_fs=""
+	_mp=""
+	_dev="/dev/${_md}"
+	eval _config=\$mdconfig_${_md}
+	eval _newfs=\$mdconfig_${_md}_newfs
+
+	_type=${_config##*-t\ }
+	_type=${_type%%\ *}
+	if [ -z "${_type}" ]; then
+		err 1 "You need to specify \"-t <type>\" in mdconfig_${_md}"
+	fi
+
+	if [ "${_type}" = "vnode" ]; then
+		_file=${_config##*-f\ }
+		_file=${_file%%\ *}
+		if [ -z "${_file}" ]; then
+			err 2 "You need to specify \"-f <file>\" in mdconfig_${_md} for vnode devices"
+		fi
+		if [ "${_file}" != "${_file%.uzip}" ]; then
+			_dev="/dev/${_md}.uzip"
+		fi
+		for _i in `df ${_file} 2>/dev/null`; do _fs=${_i}; done
+	fi
+
+	# Debugging help.
+	debug "${_md} config: ${_config}"
+	debug "${_md} type: ${_type}"
+	debug "${_md} dev: ${_dev}"
+	debug "${_md} file: ${_file}"
+	debug "${_md} fs: ${_fs}"
+	debug "${_md} newfs flags: ${_newfs}"
+}
+
+mdconfig_start()
+{
+	local _md _mp _config _type _dev _file _fs _newfs _fsck_cmd
+
+	for _md in ${_mdconfig_list}; do
+		init_variables ${_md}
+		# Create md(4) devices of types swap, malloc and vnode if the
+		# file is on the root partition.
+		if [ "${_type}" != "vnode" -o "${_fs}" = "/" ]; then
+			if [ "${_type}" = "vnode" ]; then
+				if is_readonly ${_fs}; then
+					warn "${_fs} is mounted read-only, skipping ${_md}."
+					continue
+				fi
+				if [ "${_file}" != "${_file%.uzip}" ]; then
+					load_kld -m g_uzip geom_uzip || return 3
+					# sleep a bit to allow creation of /dev/mdX.uzip
+					sleep 2
+				fi
+			fi
+			if mdconfig -l -u ${_md} >/dev/null 2>&1; then
+				err 3 "${_md} already exists"
+			fi
+			echo "Creating ${_md} device (${_type})."
+			if ! mdconfig -a ${_config} -u ${_md}; then
+				echo "Creating ${_md} device failed, moving on."
+				continue
+			fi
+			# Skip fsck for uzip devices.
+			if [ "${_type}" = "vnode" ]; then
+				if [ "${_file}" != "${_file%.uzip}" ]; then
+					_fsck_cmd=":"
+				elif checkyesno background_fsck; then
+					_fsck_cmd="fsck -F"
+				else
+					_fsck_cmd="fsck"
+				fi
+				if ! eval ${_fsck_cmd} -p ${_dev} >/dev/null; then
+					echo "Fsck failed on ${_dev}, not mounting the filesystem."
+					continue
+					
+				fi
+			else
+				newfs ${_newfs} ${_dev} >/dev/null
+			fi
+			if mount -d ${_dev} 2>&1 >/dev/null; then
+				echo "Mounting ${_dev}."
+				mount ${_dev}
+			fi
+		fi
+	done
+}
+
+mdconfig_stop()
+{
+	local _md _mp _config _type _dev _file _fs _newfs _i
+
+	for _md in ${_mdconfig_list}; do
+		init_variables ${_md}
+		if [ "${_type}" != "vnode" -o "${_fs}" = "/" ]; then
+			for _i in `df ${_dev} 2>/dev/null`; do _mp=${_i}; done
+			if [ -z "${_mp}" -o "${_mp}" != "${_mp%%%}" ]; then
+				echo "Device ${_dev} isn't mounted."
+			else
+				echo "Umounting ${_dev}."
+				umount ${_dev}
+			fi
+			if mdconfig -l -u ${_md} >/dev/null 2>&1; then
+				echo "Destroying ${_md}."
+				mdconfig -d -u ${_md}
+			fi
+		fi
+	done
+}
+
+_mdconfig_cmd="$1"
+if [ $# -gt 0 ]; then
+        shift
+fi
+[ -n "$*" ] && _mdconfig_list="$*"
+
+load_rc_config $name
+
+_mdconfig_unit=0
+if [ -z "${_mdconfig_list}" ]; then
+	while :; do
+		eval _mdconfig_config=\$mdconfig_md${_mdconfig_unit}
+		if [ -z "${_mdconfig_config}" ]; then
+			break
+		else
+			_mdconfig_list="${_mdconfig_list}${_mdconfig_list:+ }md${_mdconfig_unit}"
+			_mdconfig_unit=$((${_mdconfig_unit} + 1))
+		fi
+	done
+fi
+	
+run_rc_command "${_mdconfig_cmd}"
--- etc/rc.d/ramdisk-own
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/sh -
-#
-# Copyright (c) 2004  The FreeBSD Project
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-#    notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-#    notice, this list of conditions and the following disclaimer in the
-#    documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-# $FreeBSD: src/etc/rc.d/ramdisk-own,v 1.4 2004/11/16 04:14:28 wes Exp $
-# $MidnightBSD: src/etc/rc.d/ramdisk-own,v 1.2 2006/08/28 02:47:46 laffer1 Exp $
-
-# PROVIDE: ramdisk-own
-# REQUIRE: ramdisk mountcritlocal
-# BEFORE: SERVERS
-
-. /etc/rc.subr
-
-name="ramdisk"
-stop_cmd=":"
-start_cmd="ramdisk_own_start"
-
-ramdisk_own_start()
-{
-	for unit in $ramdisk_units; do
-		device="/dev/md$unit"
-		dir=`mount | grep $device | cut -d' ' -f3`
-
-		eval owner=\$ramdisk_${unit}_owner
-		eval perms=\$ramdisk_${unit}_perms
-
-		[ "X$owner" != "X" ] && chown -f "$owner" $device $dir
-		[ "X$perms" != "X" ] && chmod -f "$perms" /dev/md$unit $dir
-	done
-}
-
-load_rc_config $name
-run_rc_command "$1"
-
Index: Makefile
===================================================================
RCS file: /home/cvs/src/etc/rc.d/Makefile,v
retrieving revision 1.15
retrieving revision 1.16
diff -L etc/rc.d/Makefile -L etc/rc.d/Makefile -u -r1.15 -r1.16
--- etc/rc.d/Makefile
+++ etc/rc.d/Makefile
@@ -22,7 +22,7 @@
 	kadmind kerberos kernel keyserv kldxref kpasswdd \
 	ldconfig local localpkg lockd lpd \
 	mixer motd mountcritlocal mountcritremote mountlate \
-	mountd moused mroute6d mrouted msgs \
+	mdconfig mdconfig2 mountd moused mroute6d mrouted msgs \
 	named natd netif netoptions \
 	network_ipv6 newsyslog nfsclient nfsd \
 	nfsserver nisdomain nsswitch ntpd \
@@ -30,10 +30,10 @@
 	pf pflog pfsync \
 	powerd power_profile ppp pppoed pwcheck \
 	quota \
-	ramdisk ramdisk-own random rarpd rdate resolv root \
+	random rarpd rdate resolv root \
 	route6d routed routing rpcbind rtadvd rwho \
 	savecore sdpd securelevel sendmail \
-	serial sound sppp swap1 \
+	serial sound sppp statd swap1 \
 	syscons sysctl syslogd \
 	timed tmp \
 	ugidfw \
--- /dev/null
+++ etc/rc.d/mdconfig2
@@ -0,0 +1,227 @@
+#!/bin/sh
+#
+# Copyright (c) 2006  The FreeBSD Project
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD: src/etc/rc.d/mdconfig2,v 1.4 2006/12/31 10:37:18 yar Exp $
+# $MidnightBSD: src/etc/rc.d/mdconfig2,v 1.1 2009/01/17 22:23:54 laffer1 Exp $
+
+# PROVIDE: mdconfig2
+# REQUIRE: mountcritremote
+# BEFORE: SERVERS
+
+. /etc/rc.subr
+
+name="mdconfig2"
+stop_cmd="mdconfig2_stop"
+start_cmd="mdconfig2_start"
+start_precmd='[ -n "${_mdconfig2_list}" ]'
+required_modules="geom_md:g_md"
+
+is_readonly()
+{
+	local _mp _ret
+
+	_mp=$1
+	_ret=`mount | while read _line; do
+		case ${_line} in
+		*" ${_mp} "*read-only*)
+			echo "yes"
+			;;
+		
+		*)
+			;;
+		esac;
+	done`
+
+	if [ -n "${_ret}" ]; then
+		return 0
+	else
+		return 1
+	fi
+}
+
+init_variables()
+{
+	local _i
+
+	_fs=""
+	_mp=""
+	_mounted="no"
+	_dev="/dev/${_md}"
+	eval _config=\$mdconfig_${_md}
+	eval _owner=\$mdconfig_${_md}_owner
+	eval _perms=\$mdconfig_${_md}_perms
+	eval _files=\$mdconfig_${_md}_files
+	eval _populate=\$mdconfig_${_md}_cmd
+
+	_type=${_config##*-t\ }
+	_type=${_type%%\ *}
+	if [ -z "${_type}" ]; then
+		err 1 "You need to specify \"-t <type>\" in mdconfig_${_md}"
+	fi
+
+	if [ "${_type}" = "vnode" ]; then
+		_file=${_config##*-f\ }
+		_file=${_file%%\ *}
+		if [ -z "${_file}" ]; then
+			err 2 "You need to specify \"-f <file>\" in mdconfig_${_md} for vnode devices"
+		fi
+
+		if [ "${_file}" != "${_file%.uzip}" ]; then
+			_dev="/dev/${_md}.uzip"
+		fi
+		for _i in `df ${_file} 2>/dev/null`; do _fs=${_i}; done
+	fi
+
+	# Debugging help.
+	debug "${_md} config: ${_config}"
+	debug "${_md} type: ${_type}"
+	debug "${_md} dev: ${_dev}"
+	debug "${_md} file: ${_file}"
+	debug "${_md} fs: ${_fs}"
+	debug "${_md} owner: ${_owner}"
+	debug "${_md} perms: ${_perms}"
+	debug "${_md} files: ${_files}"
+	debug "${_md} populate cmd: ${_populate}"
+}
+
+mdconfig2_start()
+{
+	local _md _fs _mp _mounted _dev _config _type _file _owner _perms _files _populate _fsck_cmd _i
+
+	for _md in ${_mdconfig2_list}; do
+		init_variables ${_md}
+		if [ ! -r ${_file} ]; then
+			err 3 "${_file} doesn't exist"
+			continue
+		fi
+		# First pass: create md(4) vnode devices from files stored on
+		# non-root partition. Swap and malloc md(4) devices have already
+		# been created.
+		if [ "${_type}" = "vnode" -a "${_fs}" != "/" ]; then
+			if [ "${_file}" != "${_file%.uzip}" ]; then
+				load_kld -m g_uzip geom_uzip || return 3
+			fi
+			if is_readonly ${_fs}; then
+				warn "${_fs} is mounted read-only, skipping ${_md}."
+				continue
+			fi
+			if mdconfig -l -u ${_md} >/dev/null 2>&1; then
+				err 3 "${_md} already exists"
+			fi
+			echo "Creating ${_md} device (${_type})."
+			if ! mdconfig -a ${_config} -u ${_md}; then
+				echo "Creating ${_md} device failed, moving on."
+				continue
+			fi
+			# Skip fsck for uzip devices.
+			if [ "${_file}" != "${_file%.uzip}" ]; then
+				_fsck_cmd=":"
+			elif checkyesno background_fsck; then
+				_fsck_cmd="fsck -F"
+			else
+				_fsck_cmd="fsck"
+			fi
+			if ! eval ${_fsck_cmd} -p ${_dev} >/dev/null; then
+				echo "Fsck failed on ${_dev}, not mounting the filesystem."
+				continue
+			fi
+			if mount -d ${_dev} >/dev/null 2>&1; then
+				echo "Mounting ${_dev}."
+				mount ${_dev}
+			fi
+		fi
+
+		for _i in `df ${_dev} 2>/dev/null`; do _mp=${_i}; done
+		if [ ! -z "${_mp}" -a "${_mp}" = "${_mp%%%}" ]; then
+			_mounted="yes"
+		fi
+
+		if checkyesno _mounted; then
+			# Second pass: change permissions and ownership.
+			[ -z "${_owner}" ] || chown -f ${_owner} ${_dev} ${_mp}
+			[ -z "${_perms}" ] || chmod -f ${_perms} ${_dev} ${_mp}
+
+			# Third pass: populate with foreign files.
+			if [ -n "${_files}" -o -n "${_populate}" ]; then
+				echo "Populating ${_dev}."
+			fi
+			if [ -n "${_files}" ]; then
+				cp -Rp ${_files} ${_mp}
+			fi
+			if [ -n "${_populate}" ]; then
+				eval ${_populate}
+			fi
+		fi
+	done
+}
+
+mdconfig2_stop()
+{
+	local _md _fs _mp _mounted _dev _config _type _file _owner _perms _files _populate
+
+	for _md in ${_mdconfig2_list}; do
+		init_variables ${_md}
+		if [ "${_type}" = "vnode" ]; then
+			for i in `df ${_dev} 2>/dev/null`; do _mp=$i; done
+			if [ ! -r "${_file}" -o "${_fs}" = "/" ]; then
+				continue
+			fi
+			if [ -z "${_mp}" -o "${_mp}" != "${_mp%%%}" ]; then
+				echo "Device ${_dev} isn't mounted."
+			else
+				echo "Umounting ${_dev}."
+				umount ${_dev}
+			fi
+			if mdconfig -l -u ${_md} >/dev/null 2>&1; then
+				echo "Destroying ${_md}."
+				mdconfig -d -u ${_md}
+			fi
+		fi
+	done
+}
+
+_mdconfig2_cmd="$1"
+if [ $# -gt 0 ]; then
+        shift
+fi
+[ -n "$*" ] && _mdconfig2_list="$*"
+
+load_rc_config $name
+
+_mdconfig2_unit=0
+if [ -z "${_mdconfig2_list}" ]; then
+	while :; do
+		eval _mdconfig2_config=\$mdconfig_md${_mdconfig2_unit}
+		if [ -z "${_mdconfig2_config}" ]; then
+			break
+		else
+			_mdconfig2_list="${_mdconfig2_list}${_mdconfig2_list:+ }md${_mdconfig2_unit}"
+			_mdconfig2_unit=$((${_mdconfig2_unit} + 1))
+		fi
+	done
+fi
+	
+run_rc_command "${_mdconfig2_cmd}"


More information about the Midnightbsd-cvs mailing list