From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.sysutils.supervision.general/730 Path: main.gmane.org!not-for-mail From: Dean Hall Newsgroups: gmane.comp.sysutils.supervision.general Subject: Re: Adding a 'setup' phase to service startup? Date: Wed, 23 Feb 2005 23:40:54 -0500 Message-ID: <421D5AD6.9000107@gmail.com> References: <421AB049.4040403@gmail.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1109219771 30161 80.91.229.2 (24 Feb 2005 04:36:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 24 Feb 2005 04:36:11 +0000 (UTC) Original-X-From: supervision-return-969-gcsg-supervision=m.gmane.org@list.skarnet.org Thu Feb 24 05:36:11 2005 Original-Received: from antah.skarnet.org ([212.85.147.14] ident=qmailr) by ciao.gmane.org with smtp (Exim 4.43) id 1D4AjL-0008HE-47 for gcsg-supervision@gmane.org; Thu, 24 Feb 2005 05:36:03 +0100 Original-Received: (qmail 907 invoked by uid 76); 24 Feb 2005 04:40:14 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Archive: Original-Received: (qmail 901 invoked from network); 24 Feb 2005 04:40:14 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:user-agent:x-accept-language:mime-version:to:subject:references:in-reply-to:x-enigmail-version:x-enigmail-supports:content-type:content-transfer-encoding; b=YgMoJGW9HqUUVhI01PO1yuImetm1mNiHYtXSJqgH+fctv3NxxLuA+m3CqyXGTF9c5JM/5x+YKFj8AAB9bMc/fgMxqbiNiOKhKi75hu8aOcEyTC++altMR6SEo2bhEcZ6LSxPLr/xKw4TuVa9e6W9MoX24/qpVFqAxnSxQOoR/Zo= User-Agent: Mozilla Thunderbird 1.0 (X11/20050124) X-Accept-Language: en-us, en Original-To: supervision@list.skarnet.org In-Reply-To: X-Enigmail-Version: 0.89.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime X-MailScanner-To: gcsg-supervision@gmane.org Xref: main.gmane.org gmane.comp.sysutils.supervision.general:730 X-Report-Spam: http://spam.gmane.org/gmane.comp.sysutils.supervision.general:730 Lars Kellogg-Stedman wrote: >>Although I think runit itself should remain pristine in that it only >>runs the ./run script for a service... I almost forgot. Here's a sample implementation that I'm currently using for dnscache. This is only one method of using sv-tools, but I think it's an elegant one. Also, I think it's one that leaves the most room open for elegant automation and even (for those who like them) GUI tools. (Please keep in mind that I'm running on gentoo, which is very FHS-compliant; some day I'll break out of the FHS shell (again).) # This envdir sets the environment for sv-run. It tells sv-run not to check dependencies and gives it an envdir to fetch before calling ./run-service. -------- `envdir-print /etc/envdir.d/dnscache/meta`: -------- SV_NO_DEPS='1' SV_RUN_ENVDIR='/etc/envdir.d/dnscache/prerun' -------- # This envdir sets the environment for ./run-service. -------- `envdir-print /etc/envdir.d/dnscache/prerun`: -------- ENVDIR='/etc/envdir.d/dnscache/service' SEED='/var/lib/dnscache-seed' USER='dnscache' -------- # This envdir sets the environment for dnscache itself. -------- `envdir-print /etc/envdir.d/dnscache/service`: -------- CACHESIZE='10000000' DATALIMIT='30000000' IP='192.168.0.53' IPSEND='0.0.0.0' ROOT='/etc/service.d/all/dnscache/root' -------- # Obviously, this gets run first: -------- ./run: -------- #!/bin/sh # PATH='/usr/sbin:/usr/bin:/sbin:/bin' exec 2>&1 exec \ envdir /etc/envdir.d/dnscache/meta \ sv-run -------- # After checking dependencies and such, sv-run runs this: -------- ./run-service: -------- #!/bin/sh # # Requires: # - USER # - SEED # PATH='/usr/sbin:/usr/bin:/sbin:/bin' # Create a new random seed. dd if=/dev/urandom of="$SEED" count=1 bs=128 > /dev/null 2>&1 exec 2>&1 exec < "$SEED" exec \ env - PATH="$PATH" \ envuidgid "$USER" \ envdir "$ENVDIR" \ dnscache -------- d