From owner-freebsd-rc@FreeBSD.ORG Tue Aug 23 21:23:23 2011 Return-Path: Delivered-To: freebsd-rc@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D0658106566B for ; Tue, 23 Aug 2011 21:23:23 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from anubis.delphij.net (anubis.delphij.net [IPv6:2001:470:1:117::25]) by mx1.freebsd.org (Postfix) with ESMTP id B2BDD8FC13 for ; Tue, 23 Aug 2011 21:23:23 +0000 (UTC) Received: from delta.delphij.net (drawbridge.ixsystems.com [206.40.55.65]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by anubis.delphij.net (Postfix) with ESMTPSA id 2304C9473; Tue, 23 Aug 2011 14:23:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=delphij.net; s=anubis; t=1314134603; bh=s/185whl8xY0I4A8wKwZcZarC4HND/GaPlnSYaYgZ1I=; h=Message-ID:Date:From:Reply-To:MIME-Version:To:CC:Subject: References:In-Reply-To:Content-Type; b=l5mDnsH8cG/nP9TlbEU4QeTxNZcf9n5n5zrf1JUBZ4FYhu1wKPHuLvrzUAky9W6aP 8OwRBsCIl3gtXWm4mInbHDfk+oGEwF82mboi4YWtHZXh17Q8mYoJcMVKafPM4VOQ12 6uGtFdp+CxSV6dURS3GARswswUZaD8tx04nJIMMM= Message-ID: <4E541A49.9050207@delphij.net> Date: Tue, 23 Aug 2011 14:23:21 -0700 From: Xin LI Organization: The FreeBSD Project MIME-Version: 1.0 To: Jilles Tjoelker References: <4E50B5E3.90702@delphij.net> <20110821132045.GA3940@stack.nl> In-Reply-To: <20110821132045.GA3940@stack.nl> OpenPGP: id=3FCA37C1; url=http://www.delphij.net/delphij.asc Content-Type: multipart/mixed; boundary="------------030003050005080606030507" Cc: freebsd-rc@FreeBSD.ORG, d@delphij.net Subject: Re: [PATCH] Don't test if a service is enabled when it's required X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: d@delphij.net List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Aug 2011 21:23:23 -0000 This is a multi-part message in MIME format. --------------030003050005080606030507 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Hi, Thanks for Jilles' comments. I've added a new procedure called fast_depend (poor name perhaps?) with a proposed changeset to all these rc.d scripts that uses force_depend. Comments? Cheers, - -- Xin LI https://www.delphij.net/ FreeBSD - The Power to Serve! Live free or die -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (FreeBSD) iQEcBAEBCAAGBQJOVBpJAAoJEATO+BI/yjfBP0oIANOfSLNtqPhCL4QixTgDOknw UVlMdk1yqr9nYsyC21rQZoGIkKb2a9BplW0ZNbRYmwCZEGhG0JJE4Tm52rhISdqe 1ITd/T+eU1I9lQ37Weo6dEjywCX/1kVl7Hd7i6v0Mmuc3ZTIjwP8ZBKbZj/9P/0C Wd/slxaAzl8m/AOO4MknP4Vq5Dktz1wR8wWItP9fiKHKFFDqv/n7kXE+uAmfBRl7 0X/bUVILVRRTsX7dJIZINwMBNtxHUUlIU/HCu7/T2jLg+SsMW6Z0JaS2w7lenoPk XTZAqk18qPZjkT7L834SNBXnPy1iAEumM8kdOP/YZ7MZfgc8mGhRJ2CR6JrjelE= =9nGD -----END PGP SIGNATURE----- --------------030003050005080606030507 Content-Type: text/plain; name="rc-fastdepend.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="rc-fastdepend.diff" Index: etc/rc.d/amd =================================================================== --- etc/rc.d/amd (revision 225122) +++ etc/rc.d/amd (working copy) @@ -19,16 +19,9 @@ 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 225122) +++ etc/rc.d/ypset (working copy) @@ -20,16 +20,8 @@ { 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 225122) +++ etc/rc.d/mountd (working copy) @@ -19,11 +19,7 @@ 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 225122) +++ etc/rc.d/yppasswdd (working copy) @@ -22,16 +22,9 @@ { 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 225122) +++ etc/rc.d/keyserv (working copy) @@ -19,11 +19,7 @@ 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 225122) +++ etc/rc.d/ypupdated (working copy) @@ -18,16 +18,8 @@ { 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 225122) +++ etc/rc.d/apmd (working copy) @@ -20,11 +20,7 @@ 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 225122) +++ etc/rc.d/nfsd (working copy) @@ -43,30 +43,16 @@ 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 225122) +++ etc/rc.d/lockd (working copy) @@ -30,11 +30,7 @@ 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 225122) +++ etc/rc.d/statd (working copy) @@ -30,11 +30,7 @@ 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 225122) +++ etc/rc.d/ypbind (working copy) @@ -22,11 +22,7 @@ { 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 225122) +++ etc/rc.d/ypserv (working copy) @@ -21,11 +21,7 @@ { 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 225122) +++ etc/rc.d/ypxfrd (working copy) @@ -20,16 +20,8 @@ { 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 225119) +++ etc/rc.subr (working copy) @@ -159,6 +159,29 @@ } # +# fast_depend script [var] [prefix] +# 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". +# $1 - script name +# $2 - variable name if the variable to test is not ${1}_enable +# $3 - prefix path if not the default /etc/rc.d +# +fast_depend() +{ + _script="$1" + _variable="${2:-${1}_enable}" + _prefix="${3:-/etc/rc.d}" + + if { [ -z "${rc_fast}" ] || ! checkyesno ${_variable}; } && + ! ${_prefix}/${_script} forcestatus 1>/dev/null 2>&1 + then + force_depend ${_script} || return 1 + fi +} + +# # reverse_list list # print the list in reverse order # --------------030003050005080606030507--