Date: Thu, 28 May 2009 21:32:15 -0700 From: Doug Barton <dougb@FreeBSD.org> To: Rick Macklem <rick@snowhite.cis.uoguelph.ca> Cc: kib@freebsd.org, rc@freebsd.org, rwatson@freebsd.org Subject: Re: rc scripts for the new experimental nfs subsystem Message-ID: <4A1F654F.6000509@FreeBSD.org> In-Reply-To: <200905282047.QAA12312@snowhite.cis.uoguelph.ca> References: <200905282047.QAA12312@snowhite.cis.uoguelph.ca>
next in thread | previous in thread | raw e-mail | index | archive | help
Overall this looks good, I've made a few comments in line based on a cursory inspection. Please review http://www.freebsd.org/doc/en_US.ISO8859-1/articles/rc-scripting/ as well. hth, Doug Rick Macklem wrote: > 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 Can we shorten the middle part of that? Not a requirement, but it's a bit long. > 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 Can you provide a unified diff? That's easier to review (at least for me). > 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 Since this seems to start a service, the shutdown KEYWORD is needed. Same thing with the script below as well. > . /etc/rc.subr > > name="nfsuserd" > rcvar="nfsv4_userd_enable" > command="/usr/sbin/${name}" > > load_rc_config $name > command_args="${nfsv4_userd_flags}" This defeats how command_args is supposed to work. I'm not sure off hand what's the best solution here though. In general it reduces confusion if you set $name, the name of the script file, and the PROVIDE line all to the same thing. What's your long term plan for this? Will the variables in rc.conf eventually be renamed nfsuserd_*? > 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" > _______________________________________________ > freebsd-rc@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-rc > To unsubscribe, send any mail to "freebsd-rc-unsubscribe@freebsd.org" >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4A1F654F.6000509>