From owner-freebsd-rc@FreeBSD.ORG Wed Aug 11 00:08:01 2004 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7B64F16A4CE for ; Wed, 11 Aug 2004 00:08:01 +0000 (GMT) Received: from odin.ac.hmc.edu (Odin.AC.HMC.Edu [134.173.32.75]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5A82C43D3F for ; Wed, 11 Aug 2004 00:08:01 +0000 (GMT) (envelope-from brdavis@odin.ac.hmc.edu) Received: from odin.ac.hmc.edu (IDENT:brdavis@localhost.localdomain [127.0.0.1]) by odin.ac.hmc.edu (8.12.10/8.12.10) with ESMTP id i7B080OF016359; Tue, 10 Aug 2004 17:08:01 -0700 Received: (from brdavis@localhost) by odin.ac.hmc.edu (8.12.10/8.12.3/Submit) id i7B080e8016358; Tue, 10 Aug 2004 17:08:00 -0700 Date: Tue, 10 Aug 2004 17:08:00 -0700 From: Brooks Davis To: Jon Passki Message-ID: <20040811000800.GA5987@Odin.AC.HMC.Edu> References: <20040807214302.73783.qmail@web50307.mail.yahoo.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ReaqsoxgOBHFXBhH" Content-Disposition: inline In-Reply-To: <20040807214302.73783.qmail@web50307.mail.yahoo.com> User-Agent: Mutt/1.5.4i cc: freebsd-rc@freebsd.org Subject: Re: Feature request to rc.d: managing subsets of scripts X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list 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: Wed, 11 Aug 2004 00:08:01 -0000 --ReaqsoxgOBHFXBhH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Aug 07, 2004 at 02:43:02PM -0700, Jon Passki wrote: > Hello All, >=20 > I wish accomplish the following with rc.d scripts: >=20 > 1) Scripts can be assigned to a subset; > 2) Subsets can be ordered, with this order honored by rcorder; > 3) Subsets can be independently started and stopped after the > initial system startup; >=20 > For me, the usage would be in situations where I have a bunch of > interdependent scripts that would need a stop/start when for > example I'm remounting a file system or reassigning daemons to a > different network interface. This way, I could assign scripts to > subsets if I know that they utilize common interfaces or mounts.=20 > It is implied that if a script wasn't placed in a subset it should > continue to function even though it may depend on or be a dependent > of a subset that was stopped. It is the responsibility of the > sysadmin to properly segment subsets. >=20 > 1) & 2) can be accomplished with the REQUIRE, PROVIDE and BEFORE > lines. This would also make me alter each rc.d script I wish to > manage, but that is acceptable. It's unknown to me if subsets > should be disjointed. >=20 > It isn't obvious to me, though, if 3) could work that way. I still > would see rcorder doing it's magic, but it would need a filter to > only order that subset. The KEYWORD line could be used in addition > to the other lines, but adds some redundancy. According to [1], > rcorder logically OR's keep list switches. It would have to AND > them in this case to handle a) the FreeBSD switch and b) more > importantly, manage more than one subset. I want this feature. What I want it for is to have a set of scripts that run before the standard ones so initdiskless can add scripts to /etc/rc.d (and thus I can keep /etc/rc.d stock). What I'm planning to do is to add a -K option to rcorder which will make keywords evaluate ANDed. Keywords will still be passed with -k, just the evaluation function will change. Here's a patch for rcorder that adds this function. A patch to /etc/rc is also needed to handle the subsets. I'm not 100% sure how to do this given my desire to have an "early" set that runs before everything. Maybe we should just hardcode that one. -- Brooks =3D=3D=3D=3D //depot/user/brooks/cleanup/sbin/rcorder/rcorder.8#2 - /home/b= rooks/working/freebsd/p4/cleanup/sbin/rcorder/rcorder.8 =3D=3D=3D=3D @@ -39,6 +39,7 @@ .Nd print a dependency ordering of interdependent files .Sh SYNOPSIS .Nm +.Op Fl K .Op Fl k Ar keep .Op Fl s Ar skip .Ar @@ -92,12 +93,23 @@ .Pp The options are as follows: .Bl -tag -width indent +.It Fl K +Require all keywords in the +.Dq "keep list" +to be in each file. +The default is to require one or more. .It Fl k Add the specified keyword to the .Dq "keep list" . If any .Fl k -option is given, only those files containing the matching keyword are list= ed. +option is given, only those files containing one or more of the matching +keyword are listed. +The +.Fl K +option causes all keywords in the +.Dq "keep list" +to be required. .It Fl s Add the specified keyword to the .Dq "skip list" . =3D=3D=3D=3D //depot/user/brooks/cleanup/sbin/rcorder/rcorder.c#1 - /home/b= rooks/working/freebsd/p4/cleanup/sbin/rcorder/rcorder.c =3D=3D=3D=3D @@ -69,6 +69,7 @@ #define KEYWORDS_STR "# KEYWORDS:" #define KEYWORDS_LEN (sizeof(KEYWORDS_STR) - 1) =20 +int keyword_or =3D 1; int exit_code; int file_count; char **file_list; @@ -155,7 +156,7 @@ { int ch; =20 - while ((ch =3D getopt(argc, argv, "dk:s:")) !=3D -1) + while ((ch =3D getopt(argc, argv, "dKk:s:")) !=3D -1) switch (ch) { case 'd': #ifdef DEBUG @@ -164,6 +165,9 @@ warnx("debugging not compiled in, -d ignored"); #endif break; + case 'K': + keyword_or =3D 0; + break; case 'k': strnode_add(&keep_list, optarg, 0); break; @@ -704,13 +708,25 @@ strnodelist *s; strnodelist *k; =20 - for (s =3D keep_list; s; s =3D s->next) - for (k =3D fnode->keyword_list; k; k =3D k->next) - if (strcmp(k->s, s->s) =3D=3D 0) - return (1); + for (s =3D keep_list; s; s =3D s->next) { + for (k =3D fnode->keyword_list; k; k =3D k->next) { + if (strcmp(k->s, s->s) =3D=3D 0) { + if (keyword_or) + return (1); + else + break; + } + } + if (!keyword_or && k =3D=3D NULL) + return (0); + } =20 - /* an empty keep_list means every one */ - return (!keep_list); + if (keyword_or) { + /* an empty keep_list means every one */ + return (!keep_list); + } else { + return (1); + } } =20 /* --=20 Any statement of the form "X is the one, true Y" is FALSE. PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4 --ReaqsoxgOBHFXBhH Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQFBGWNfXY6L6fI4GtQRAtTfAJwNtTm5IwrxHn7vpl+TBaQLMoeEEgCgsE2b M6cxpa85PDBUOHqTWwYlehg= =i71T -----END PGP SIGNATURE----- --ReaqsoxgOBHFXBhH--