Date: Thu, 28 May 2009 16:47:09 -0400 (EDT) From: Rick Macklem <rick@snowhite.cis.uoguelph.ca> To: rc@freebsd.org Cc: rwatson@freebsd.org, kib@freebsd.org Subject: rc scripts for the new experimental nfs subsystem Message-ID: <200905282047.QAA12312@snowhite.cis.uoguelph.ca>
next in thread | raw e-mail | index | archive | help
Hi, I've just put the sources and man pages for an experimental alternative to the regular NFS subsystem in FreeBSD-CURRENT. I have some rc scripts that I use to run it, but I'm not much of a shell programmer, so I wondered if someone might be able to review them? Thanks in advance for any help, rick Essentially, if nfsv4_serversupport_enable is yes, the "-e" argument must be added to the argument list for nfsd and mountd, so that they run the experimental server. (The current versions of these functions are the only ones that know "-e" and they also know to load the correct modules, so I don't think the business of running "nfsserver" to get the module loaded is necessary for this case.) It also forces the startup of nfsuserd. nfsuserd is used by both client and server and nfscbd is optionally used by the client, for callback handling. They know to load the correct modules, as required. I've added the following variables to /etc/defaults/rc.conf: nfsv4_serversupport_enable="NO" # Enable support for NFSv4 nfsv4_cbd_enable="NO" # NFSv4 client side callback daemon nfsv4_cbd_flags="" # Flags for nfscbd nfsv4_userd_enable="NO" # NFSv4 user/group name mapping daemon nfsv4_userd_flags="" # Flags for nfsuserd and then there are 2 modified scripts for /etc/rc.d and two new ones. A modified nfsd: #!/bin/sh # # $FreeBSD: src/etc/rc.d/nfsd,v 1.16 2008/11/03 10:38:00 dfr Exp $ # # PROVIDE: nfsd # REQUIRE: mountd hostname gssd # KEYWORD: nojail shutdown . /etc/rc.subr name="nfsd" rcvar=`set_rcvar nfs_server` command="/usr/sbin/${name}" load_rc_config $name start_precmd="nfsd_precmd" sig_stop="USR1" nfsd_precmd() { # If nfsv4_serversupport_enable is yes, force use of the experimental # server # if checkyesno nfsv4_serversupport_enable; then rc_flags="-e ${nfs_server_flags}" else rc_flags="${nfs_server_flags}" fi if checkyesno nfsv4_serversupport_enable; then if ! checkyesno nfsv4_userd_enable && \ ! /etc/rc.d/nfsuserd forcestatus 1>/dev/null 2>&1 then force_depend nfsuserd || return 1 fi elif ! sysctl vfs.nfsrv >/dev/null 2>&1; then force_depend nfsserver || return 1 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 if ! checkyesno nfsv4_serversupport_enable && \ checkyesno nfs_reserved_port_only; then echo 'NFS on reserved port only=YES' sysctl vfs.nfsrv.nfs_privport=1 > /dev/null fi return 0 } run_rc_command "$1" A modified mountd: #!/bin/sh # # $FreeBSD: src/etc/rc.d/mountd,v 1.21 2008/07/16 19:50:29 dougb Exp $ # # PROVIDE: mountd # REQUIRE: NETWORKING nfsserver rpcbind quota # KEYWORD: nojail shutdown . /etc/rc.subr name="mountd" rcvar=`set_rcvar` command="/usr/sbin/${name}" pidfile="/var/run/${name}.pid" required_files="/etc/exports" start_precmd="mountd_precmd" 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 # 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 nfsv4_serversupport_enable is yes, force use of the experimental # server # if checkyesno nfsv4_serversupport_enable; then rc_flags="-e ${rc_flags}" 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" A new script for the nfsuserd: #!/bin/sh # # $FreeBSD$ # # PROVIDE: nfsuserd # KEYWORD: nojail . /etc/rc.subr name="nfsuserd" rcvar="nfsv4_userd_enable" command="/usr/sbin/${name}" load_rc_config $name command_args="${nfsv4_userd_flags}" sig_stop="USR1" run_rc_command "$1" and a new script for the nfscbd: #!/bin/sh # # $FreeBSD$ # # PROVIDE: nfscbd # KEYWORD: nojail . /etc/rc.subr name="nfscbd" rcvar="nfsv4_cbd_enable" command="/usr/sbin/${name}" load_rc_config $name command_args="${nfsv4_cbd_flags}" sig_stop="USR1" run_rc_command "$1"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905282047.QAA12312>