Date: Wed, 7 Nov 2007 00:28:37 -0800 From: Christopher Cowart <ccowart@rescomp.berkeley.edu> To: freebsd-rc@FreeBSD.org Subject: Multiple instances of a daemon Message-ID: <20071107082837.GM65098@hal.rescomp.berkeley.edu>
next in thread | raw e-mail | index | archive | help
--+4tyMlGyR6ddaJz2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, 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. 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. 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 Then I wrote my rc script with `name=3D${0##*/}'. Everything was fantastic doing manual starts and stops. Then I tried rebooting... 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. 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 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. Is this a feature other people would like to see, or is it just me? --=20 Chris Cowart Lead Systems Administrator Network & Infrastructure Services, RSSP-IT UC Berkeley --+4tyMlGyR6ddaJz2 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (FreeBSD) iQIVAwUBRzF3NSPHEDszU3zYAQJfQQ/+LeYMACS5nAvkf+A4L5bxH6hn8U7tN5GY MczWkPNcrge/b15oIZun6Nko+b6tetH/ZcurWM/JtdY2ZrAMn+RX0KP3bgUq5dOQ gbl6crU4cThFP2Y3XrX3lHflXMtFqSYdWjctWrgrUdHyrYxZm2ObaAjmiqu+7+Bx pcYW5CNaUOWk+Ah8gwAVsIuOM1buICBExItIo47fqZTCDpI784eZnbLVbs/JCStn e+gDGFbVA7ygeTttsDTzmuchzLpBoJyiX9i1PI1vXiCHgylWs3rKFUsQ6wVbLCZT zpmYhLXwjkzuaI2LC/+hnW0n31czX6CbmId+sLv4iOqnH7jn1H6WmpvSNQKiT5SN rrWGmvkZSGQgcqi6K2JglOv6HHD6tAywgbLaKCbXXRg17GYxHVypmQy5IxP0UbOp Yj/KGGEYyIBHHGXvUGO6X4cmtCmuLUllEJl/drPIi4o76Y5koMPMuzwWARIGilKP EzofEQ7Eu8TL76/mAOTizzemki2CLpeKaiwB6yzSMRYZIgaLG4wtQXrSPgGTeLsj FVJfTR6BDh7/t2bLbK/4f2kwTNLaWejjsFRmRqGWiujK5RCb2d85Qk4OM6rbmEkt AzF0lYbhk5ELGUaAi1iICuUK666ngs4TK6UOcceA6hJ9UnpfpgNqoLmJbS4HXrwW Uz6TXdEVB3Q= =5ElB -----END PGP SIGNATURE----- --+4tyMlGyR6ddaJz2--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071107082837.GM65098>