Date: Fri, 26 Aug 2011 15:06:45 -0700 From: Xin LI <delphij@delphij.net> To: Jilles Tjoelker <jilles@stack.nl> Cc: freebsd-rc@FreeBSD.ORG, d@delphij.net Subject: Re: [PATCH] Don't test if a service is enabled when it's required Message-ID: <4E5818F5.809@delphij.net> In-Reply-To: <20110826214456.GA41095@stack.nl> References: <4E50B5E3.90702@delphij.net> <20110821132045.GA3940@stack.nl> <4E541A49.9050207@delphij.net> <20110826214456.GA41095@stack.nl>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------080006030205030708020100 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Hi, Jilles, Thanks for your comments, I've revised the patchset based on these comments for further review. Cheers, - -- Xin LI <delphij@delphij.net> https://www.delphij.net/ FreeBSD - The Power to Serve! Live free or die -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (FreeBSD) iQEcBAEBCAAGBQJOWBj1AAoJEATO+BI/yjfBIn8IALkfN3D+CRJO0eXvcW3GcXvX U1DWvKQ9y0cs6Ieo7no4B8d6UC/pz/EjXc0+lYuHNsKOv0zmkthTdz85xIVr6yOo 0Thx5uRQodNKs74LuL1iFp5vRXfNfihTSjhYuF77Rk4Urz7YkehYXO1EiD5727Oq eVql2Krvt+m71HzZddAOAH1Pc7FQDKMYGV05RhieX8CUtaYYaUfRmlDvfN2CuIES 1VWG54Bp46IDktYHwzzGMzxyX9Y3y1E0FGeppcHPTvuZBP+smkY4dQY1Hir5GIeY /SJQH22VFl9GhtHQ6KSV/GvVR80Lv7m0y8crgbFmYDXQvnovXVABTX0z0LWBWCM= =TDNh -----END PGP SIGNATURE----- --------------080006030205030708020100 Content-Type: text/plain; name="rc-fastdepend-2.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="rc-fastdepend-2.diff" Index: etc/rc.d/amd =================================================================== --- etc/rc.d/amd (revision 225199) +++ etc/rc.d/amd (working copy) @@ -19,16 +19,9 @@ extra_commands="reload" amd_precmd() { - if ! checkyesno nfs_client_enable; then - force_depend nfsclient || return 1 - fi + fast_depend nfsclient nfs_client_enable || return 1 + fast_depend rpcbind || return 1 - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || return 1 - fi - case ${amd_map_program} in [Nn][Oo] | '') ;; Index: etc/rc.d/ypset =================================================================== --- etc/rc.d/ypset (revision 225199) +++ etc/rc.d/ypset (working copy) @@ -20,16 +20,8 @@ ypset_precmd() { local _domain - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || return 1 - fi - if ! checkyesno nis_client_enable && \ - ! /etc/rc.d/ypbind forcestatus 1>/dev/null 2>&1 - then - force_depend ypbind || return 1 - fi + fast_depend rpcbind || return 1 + fast_depend ypbind nis_client_enable || return 1 _domain=`domainname` if [ -z "$_domain" ]; then Index: etc/rc.d/mountd =================================================================== --- etc/rc.d/mountd (revision 225199) +++ etc/rc.d/mountd (working copy) @@ -19,11 +19,7 @@ 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 + fast_depend rpcbind || return 1 # mountd flags will differ depending on rc.conf settings # Index: etc/rc.d/yppasswdd =================================================================== --- etc/rc.d/yppasswdd (revision 225199) +++ etc/rc.d/yppasswdd (working copy) @@ -22,16 +22,9 @@ yppasswdd_precmd() { local _domain - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || return 1 - fi - if ! checkyesno nis_server_enable && \ - ! /etc/rc.d/ypserv forcestatus 1>/dev/null 2>&1 - then - force_depend ypserv || return 1 - fi + fast_depend rpcbind || return 1 + fast_depend ypserv nis_server_enable || return 1 + _domain=`domainname` if [ -z "$_domain" ]; then warn "NIS domainname(1) is not set." Index: etc/rc.d/keyserv =================================================================== --- etc/rc.d/keyserv (revision 225199) +++ etc/rc.d/keyserv (working copy) @@ -19,11 +19,7 @@ start_precmd="keyserv_prestart" keyserv_prestart() { - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || return 1 - fi + fast_depend rpcbind || return 1 return 0 } Index: etc/rc.d/ypupdated =================================================================== --- etc/rc.d/ypupdated (revision 225199) +++ etc/rc.d/ypupdated (working copy) @@ -18,16 +18,8 @@ rpc_ypupdated_precmd() { local _domain - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || return 1 - fi - if ! checkyesno nis_server_enable && \ - ! /etc/rc.d/ypserv forcestatus 1>/dev/null 2>&1 - then - force_depend ypserv || return 1 - fi + fast_depend rpcbind || return 1 + fast_depend ypserv nis_server_enable || return 1 _domain=`domainname` if [ -z "$_domain" ]; then Index: etc/rc.d/apmd =================================================================== --- etc/rc.d/apmd (revision 225199) +++ etc/rc.d/apmd (working copy) @@ -20,11 +20,7 @@ apmd_prestart() case `${SYSCTL_N} hw.machine_arch` in i386) # Enable apm if it is not already enabled - if ! checkyesno apm_enable && \ - ! /etc/rc.d/apm forcestatus 1>/dev/null 2>&1 - then - force_depend apm || return 1 - fi + fast_depend apm || return 1 # Warn user about acpi apm compatibility support which # does not work with apmd. Index: etc/rc.d/nfsd =================================================================== --- etc/rc.d/nfsd (revision 225199) +++ etc/rc.d/nfsd (working copy) @@ -43,30 +43,16 @@ nfsd_precmd() fi if checkyesno nfsv4_server_enable; then - if ! checkyesno nfsuserd_enable && \ - ! /etc/rc.d/nfsuserd forcestatus 1>/dev/null 2>&1 - then - if ! force_depend nfsuserd; then - err 1 "Cannot run nfsuserd" - fi - fi + fast_depend nfsuserd || err 1 "Cannot run nfsuserd" else echo 'NFSv4 is disabled' sysctl vfs.nfsd.server_max_nfsvers=3 > /dev/null fi fi - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || return 1 - fi + fast_depend rpcbind || return 1 + fast_depend mountd || return 1 - if ! checkyesno mountd_enable && \ - ! /etc/rc.d/mountd forcestatus 1>/dev/null 2>&1 - then - force_depend mountd || return 1 - fi return 0 } Index: etc/rc.d/lockd =================================================================== --- etc/rc.d/lockd (revision 225199) +++ etc/rc.d/lockd (working copy) @@ -30,11 +30,7 @@ lockd_precmd() 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 + fast_depend rpcbind || ret=1 rc_flags=${rpc_lockd_flags} return ${ret} } Index: etc/rc.d/statd =================================================================== --- etc/rc.d/statd (revision 225199) +++ etc/rc.d/statd (working copy) @@ -30,11 +30,7 @@ statd_precmd() 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 + fast_depend rpcbind || ret=1 rc_flags=${rpc_statd_flags} return ${ret} } Index: etc/rc.d/ypbind =================================================================== --- etc/rc.d/ypbind (revision 225199) +++ etc/rc.d/ypbind (working copy) @@ -22,11 +22,7 @@ ypbind_precmd() { local _domain - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || return 1 - fi + fast_depend rpcbind || return 1 _domain=`domainname` if [ -z "$_domain" ]; then Index: etc/rc.d/ypserv =================================================================== --- etc/rc.d/ypserv (revision 225199) +++ etc/rc.d/ypserv (working copy) @@ -21,11 +21,7 @@ ypserv_prestart() { local _domain - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || return 1 - fi + fast_depend rpcbind || return 1 _domain=`domainname` if [ -z "$_domain" ]; then warn "NIS domainname(1) is not set." Index: etc/rc.d/ypxfrd =================================================================== --- etc/rc.d/ypxfrd (revision 225199) +++ etc/rc.d/ypxfrd (working copy) @@ -20,16 +20,8 @@ ypxfrd_precmd() { local _domain - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || return 1 - fi - if ! checkyesno nis_server_enable && \ - ! /etc/rc.d/ypserv forcestatus 1>/dev/null 2>&1 - then - force_depend ypserv || return 1 - fi + fast_depend rpcbind || return 1 + fast_depend ypserv nis_server_enable || return 1 _domain=`domainname` if [ -z "$_domain" ]; then Index: etc/rc.subr =================================================================== --- etc/rc.subr (revision 225199) +++ etc/rc.subr (working copy) @@ -159,6 +159,29 @@ checkyesno() } # +# fast_depend script [var] +# Force a service to start if it's not already, regardless +# if it's enabled. Intended for use by services +# to resolve dependency issues. When rc_fast is set, +# only force the dependency if var is set to "NO", +# as the dependency must already been started otherwise. +# +# $1 - script name +# $2 - variable name if the variable to test is not ${1}_enable +# +fast_depend() +{ + _script="$1" + _variable="${2:-${1}_enable}" + + if { [ -z "${rc_fast}" ] || ! checkyesno ${_variable}; } && + ! /etc/rc.d/${_script} forcestatus 1>/dev/null 2>&1 + then + force_depend ${_script} || return 1 + fi +} + +# # reverse_list list # print the list in reverse order # --------------080006030205030708020100--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4E5818F5.809>