Menu

[r10367]: / legacy / etc / rc.d / mountd  Maximize  Restore  History

Download this file

95 lines (80 with data), 2.2 kB

#!/bin/sh
#
# $FreeBSD: src/etc/rc.d/mountd,v 1.19.2.2.2.1 2009/04/15 03:14:26 kensmith Exp $
#
# Modified by Volker Theile (votdev@gmx.de)
# Changes:
# - Remove nfsserver quota
# - Add mkconf command
#

# PROVIDE: mountd
# REQUIRE: NETWORKING rpcbind
# KEYWORD: nojail shutdown
# XQUERY: -i "count(//nfsd/enable) > 0" -o "0" -b
# RCVAR: mountd

. /etc/rc.subr
. /etc/configxml.subr
. /etc/util.subr

name="mountd"
rcvar=`set_rcvar`
command="/usr/sbin/${name}"
pidfile="/var/run/${name}.pid"
mountd_config=${mountd_config:-"/var/etc/exports"}
required_files="${mountd_config}"
start_precmd="mountd_precmd"
mkconf_cmd="mountd_mkconf"
extra_commands="reload mkconf"

# Clear existing file
cat /dev/null > ${mountd_config}

mountd_mkconf()
{
	local _index _ipaddr _network _mask

	# Create /var/etc/exports file
	_index=`configxml_get_count "//nfsd/share"`
	while [ ${_index} -gt 0 ]
	do
		_ipaddr=`configxml_get "//nfsd/share[position()=${_index}]/network"`
		_network=${_ipaddr%/*}
		_mask=`get_subnetmask ${_ipaddr}`

		/usr/local/bin/xml sel -t -m "//nfsd/share[position()=${_index}]" \
			-v "path" \
			-i "count(options/*) > 0" -o " -" -b \
			-m "options/*" \
				-i "position() > 1" -o "," -b \
				-v "local-name()" \
			-b \
			-i "mapall[. = 'yes']" -o " -mapall=root" -b \
			-i "mapall[. != 'yes']" -o " -maproot=root" -b \
			-o " -network ${_network} -mask ${_mask}" -n \
			${configxml_file} | /usr/local/bin/xml unesc >> ${mountd_config}

		_index=$(( ${_index} - 1 ))
	done
}

mountd_precmd()
{
	mountd_mkconf

	if ! checkyesno rpcbind_enable  && \
	    ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
	then
		force_depend rpcbind || return 1
	fi

	# mountd flags will differ depending on rc.conf settings
	#
	if checkyesno nfs_server_enable ; then
		if checkyesno weak_mountd_authentication; then
			rc_flags="${mountd_flags} -n"
		fi
	else
		if checkyesno mountd_enable; then
			checkyesno weak_mountd_authentication && rc_flags="-n"
		fi
	fi

	if checkyesno zfs_enable; then
		rc_flags="${rc_flags} /etc/exports /etc/zfs/exports"
	fi

	rm -f /var/db/mountdtab
	( umask 022 ; > /var/db/mountdtab )
	return 0
}

load_rc_config $name
run_rc_command "$1"
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.