From owner-freebsd-rc@FreeBSD.ORG Mon Oct 1 20:40:12 2007 Return-Path: Delivered-To: freebsd-rc@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C353B16A420 for ; Mon, 1 Oct 2007 20:40:12 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id BE7E713C448 for ; Mon, 1 Oct 2007 20:40:12 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.1/8.14.1) with ESMTP id l91KeCYW097860 for ; Mon, 1 Oct 2007 20:40:12 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id l91KeC2t097859; Mon, 1 Oct 2007 20:40:12 GMT (envelope-from gnats) Date: Mon, 1 Oct 2007 20:40:12 GMT Message-Id: <200710012040.l91KeC2t097859@freefall.freebsd.org> To: freebsd-rc@FreeBSD.org From: Pietro Cerutti Cc: Subject: Re: conf/105568: [patch] Add more flexibility to rc.conf, to choose "_enable" values at startup X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Pietro Cerutti 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: Mon, 01 Oct 2007 20:40:12 -0000 The following reply was made to PR conf/105568; it has been noted by GNATS. From: Pietro Cerutti To: bug-followup@FreeBSD.org, pietro.cerutti@gmail.com Cc: Subject: Re: conf/105568: [patch] Add more flexibility to rc.conf, to choose "_enable" values at startup Date: Mon, 01 Oct 2007 13:42:43 +0200 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig71BA73101BF0FB5456761C13 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable This patch applies against 6.2-STABLE --- rc.subr.orig 2007-10-01 13:21:35.000000000 +0200 +++ rc.subr 2007-10-01 13:37:10.000000000 +0200 @@ -58,6 +58,9 @@ PS=3D"/bin/ps -ww" JID=3D`$PS -p $$ -o jid=3D` +ASK_TIMEOUT=3D"5s" +ASK_DEFAULT=3D"YES" + case ${OSTYPE} in FreeBSD) SYSCTL_W=3D"${SYSCTL}" @@ -123,7 +126,9 @@ # # checkyesno var -# Test $1 variable, and warn if not set to YES or NO. +# Test $1 variable, and warn if not set to YES, NO or ASK. +# If it's "ask", prompt the user to decide wheter to set +# $1 to YES or NO. # Return 0 if it's "yes" (et al), nonzero otherwise. # checkyesno() @@ -141,6 +146,63 @@ [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1 ;; + [Aa][Ss][Kk]) + # "ask" + + # Answer is stored in .ask file + # -> we are shutting down + _file=3D"/var/run/$name.ask" + if [ -f $_file ]; then + read _response < $_file + if checkyesno _response; then + return 0 + else + return 1 + fi + fi + + # Prompt and save answer in .ask file + # -> we are entering multi-user mode + + # Read timeout and default answer fo this daemon + eval _timeout=3D\$${name}_ask_timeout + eval _default=3D\=C3=A0=C3=A0{name}_ask_default + + # Timeout not set for this daemon + # -> revert to global default timeout + if [ ! $_timeout ]; then + _timeout=3D$ASK_TIMEOUT + fi + + # Default answer not set for this daemon + # -> revert to global default answer + if [ ! $_default ]; then + _default=3D$ASK_DEFAULT + fi + + # Read decision from stdin + read -t $_timeout -p "RC_ASK - Enable $name? [yes|no]" _enable + + # If timeout is elapsed, set default answer + if [ $? -eq 1 ]; then + _enable=3D${_response} + fi + + # Call checkyes no on answer + if checkyesno _enable; then + _choice=3D"yes" + _return=3D0 + else + _choice=3D"no" + _return=3D1 + fi + + # Save decision to .ask file + echo "$_choice" > $_file + + return $_return + ;; + *) warn "\$${1} is not set properly - see ${rcvar_manpage}." return 1 --=20 Pietro Cerutti PGP Public Key: http://gahr.ch/pgp --------------enig71BA73101BF0FB5456761C13 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQFHAN04wMJqmJVx944RCmhSAKCS8s4ExqdfiLgNfMxsVOzsnPn7kACdEXzg 1VPh3f5DkPtn+jbXqZWXFzA= =+Gcs -----END PGP SIGNATURE----- --------------enig71BA73101BF0FB5456761C13--