From owner-freebsd-rc@FreeBSD.ORG Wed Nov 7 21:17:10 2007 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 306EB16A418 for ; Wed, 7 Nov 2007 21:17:10 +0000 (UTC) (envelope-from ccowart@rescomp.berkeley.edu) Received: from hal.rescomp.berkeley.edu (hal.Rescomp.Berkeley.EDU [169.229.70.150]) by mx1.freebsd.org (Postfix) with ESMTP id 1383113C4B6 for ; Wed, 7 Nov 2007 21:17:09 +0000 (UTC) (envelope-from ccowart@rescomp.berkeley.edu) Received: by hal.rescomp.berkeley.edu (Postfix, from userid 1225) id F26FF3C048E; Wed, 7 Nov 2007 13:17:01 -0800 (PST) Date: Wed, 7 Nov 2007 13:17:01 -0800 From: Christopher Cowart To: freebsd-rc@freebsd.org Message-ID: <20071107211701.GP65098@hal.rescomp.berkeley.edu> Mail-Followup-To: freebsd-rc@freebsd.org References: <20071107082837.GM65098@hal.rescomp.berkeley.edu> <20071107084803.6a3564db.wmoran@collaborativefusion.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Pr8rMdbFBWzrOzFq" Content-Disposition: inline In-Reply-To: <20071107084803.6a3564db.wmoran@collaborativefusion.com> Organization: RSSP-IT, UC Berkeley User-Agent: Mutt/1.5.16 (2007-06-09) Subject: Re: Multiple instances of a daemon X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 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, 07 Nov 2007 21:17:10 -0000 --Pr8rMdbFBWzrOzFq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 07, 2007 at 08:48:03AM -0500, Bill Moran wrote: >In response to Christopher Cowart : >> Hello, >>=20 >> I want to be able to use the same rc script to start several instances >> of a daemon. When I've encountered this desire before, I've cp'd the >> script, given it a unique name, and carried on with my business. This is >> a but kludgy and makes updating scripts a manual task. >>=20 >> Today, I realized the arpd port didn't provide an rc script, so I set >> out to write one. I also knew that I was going to be launching several >> different arpd's, so I wanted to figure out a better way to deal with >> this problem. >>=20 >> I thought I'd be clever and use symlinks: >> rc.d $ ls -l arpd* >> -r-xr-xr-x 1 root wheel 486 Nov 7 00:01 arpd >> lrwxr-xr-x 1 root wheel 4 Nov 6 23:32 arpd_vlan665 -> arpd >> lrwxr-xr-x 1 root wheel 4 Nov 6 23:32 arpd_vlan679 -> arpd >>=20 >> Then I wrote my rc script with `name=3D${0##*/}'. Everything was fantast= ic >> doing manual starts and stops. Then I tried rebooting... >>=20 >> After a few boots, some debugging, and a lot of tracing through /etc/rc >> and /etc/rc.subr, I found the problem (or is it a feature?). >> run_rc_script() sources the script. All the talk about not sourcing the >> "current shell" anymore, and I foolishly assumed that meant something >> more like calling the script and less like sourcing it in a subshell. >>=20 >> I would really find it convenient to use the symlink trick shown above, >> because it means a symlink-compatible rc-script can be updated by the >> port or mergemaster, and all the "copies" will "just work." I'd be >> willing to take the time to implement something, but I don't pretend=20 >> to know all the use cases or the motivation behind this design.=20 >>=20 >> One approach could be that run_rc_script() throws the rc script name >> into a variable visible to the sourced script, say _rc_script_name.=20 >> Then name could be something like `${_rc_script_name:-${0##*/}}' or a >> less terse if/then. >>=20 >> Is this a feature other people would like to see, or is it just me? > >The canonical way of doing this has been a "profiles"-enabled rc >script. See the Apache or Slony rc scripts for examples. > >Not sure if your approach might be better. The jail rc script takes a smilar approach. It seems like when somebody wants to "profile" their script, they have to write the logic from scratch (or copy, paste, and tweak). Would a better solution be to=20 provide some default notion of profiling in the rc.subr library so rc=20 scripts can take advantage of it by default?=20 --=20 Chris Cowart Lead Systems Administrator Network & Infrastructure Services, RSSP-IT UC Berkeley --Pr8rMdbFBWzrOzFq Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (FreeBSD) iQIVAwUBRzIrTSPHEDszU3zYAQJZxhAAviiFFa8kFZ40F3PA6ZK3exqukAoODvy0 RLkWGFiPj4YrLrtwoL4nuzy7depJ8HwGDd5DhmvtEiH5QgLg4dc0BChCGLseEolu r53Tc87Uyp+rLJfRCWKIyDO37gbORmajCNFHcOURVt1wbXQaSOydQ9pluNUSACi2 1BnZ/1yWXyH8bERyLc27eqMxJ7DmfvqrTC5pq93T+3TwaeUOODfc99HV+9ZxeXCt G0LMb97j7AKh0DtWs/YnTrTO3HxheRE95DYu72kDRFmcNJcyjl+U1dPptTDkVH6F 3vq1M5bfwAE6C7N2Eo3ZIbxyxuKbRqDolkVXEBHr211/OLZfG74TVvuQy4WLG4Z5 kTs2Ijk35dR6Fr8JPiULL22ynSnhvsfbB+tOlNiPWTatJOvBPQ386+DyWJY9Ch2V MyM/n/LiNzM2+ynyxQhUOEiYbOppd7V9wQbIvIBPB4V4bfiWyxM476lcOVuGIz6Z V6qWhVsnQ72jJqJeIPd9oATer0EYsfkzWp9HAc7DZweQQw1Fstb7yqDRNbQAhNxC LS5CpM4A9IoPQC6OVhltwh6tDObv5lF1gE1wbE4oWEwW+rKG04/jZaWdIvm5913U vkK0PvHj6Ycj2m6pjlnSce3MPoEMKCdsAYqI+0br0wDmLeN05FFS6gU8TZQ2g8s/ v6XlGDBiajU= =S3q8 -----END PGP SIGNATURE----- --Pr8rMdbFBWzrOzFq--