FreeNAS Code
This project has moved to github - see https://github.com/freenas
Brought to you by:
cochard,
mattolander
#!/bin/sh # # $NetBSD: mountd,v 1.11 2002/01/31 01:26:06 lukem Exp $ # $FreeBSD: src/etc/rc.d/mountd,v 1.15.2.1 2005/09/21 20:27:50 rodrigc Exp $ # # Modified by Volker Theile (votdev@gmx.de) # # PROVIDE: mountd # REQUIRE: NETWORKING rpcbind # KEYWORD: nojail # XQUERY: -i "count(//nfs/enable) > 0" -o "0" -b # RCVAR: mountd . /etc/rc.subr . /etc/configxml.subr . /etc/util.subr name="mountd" rcvar=`set_rcvar` # Custom commands start_precmd="mountd_precmd" extra_commands="reload" # Defaults mountd_config=${mountd_config:-"/var/etc/exports"} required_files="${mountd_config}" command="/usr/sbin/${name}" command_args="-r ${mountd_config}" # Clear existing file. cat /dev/null > ${mountd_config} create_conf() { local _index _i _ipaddr _network _subnetmask # Create /var/etc/exports file. _index=`configxml_get_count "//nfs/nfsnetworks"` _i=0 while [ ${_index} -gt 0 ] do _ipaddr=`configxml_get "//nfs/nfsnetworks[position()=${_index}]"` _network=${_ipaddr%/*} _subnetmask=`get_subnetmask ${_ipaddr}` /usr/local/bin/xml sel -t -m "//mounts/mount" \ -v "concat('/mnt/',sharename,' -alldirs ')" \ -i "//nfs/mapall[. = 'yes']" -o "-mapall=root " -b \ -i "//nfs/mapall[. != 'yes']" -o "-maproot=root " -b \ -o "-network ${_network} -mask ${_subnetmask}" -n \ ${configxml_file} | /usr/local/bin/xml unesc >> ${mountd_config} _i=$(( ${_i} + 1 )) _index=$(( ${_index} - 1 )) done } mountd_precmd() { create_conf 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 rm -f /var/db/mountdtab ( umask 022 ; > /var/db/mountdtab ) return 0 } load_rc_config ${name} run_rc_command "$1"