From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.sysutils.supervision.general/1707 Path: news.gmane.org!not-for-mail From: Robin Bowes Newsgroups: gmane.comp.sysutils.supervision.general Subject: Re: Help with chpst -e Date: Mon, 14 Apr 2008 22:00:15 +0100 Message-ID: References: <20080414083428.GK20279@utopia.intra.guy> <20080414164126.GP20279@utopia.intra.guy> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1208206854 11547 80.91.229.12 (14 Apr 2008 21:00:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 14 Apr 2008 21:00:54 +0000 (UTC) To: supervision@list.skarnet.org Original-X-From: supervision-return-1942-gcsg-supervision=m.gmane.org@list.skarnet.org Mon Apr 14 23:01:31 2008 connect(): Connection refused Return-path: Envelope-to: gcsg-supervision@gmane.org Original-Received: from antah.skarnet.org ([212.85.147.14]) by lo.gmane.org with smtp (Exim 4.50) id 1JlVnI-0008Qs-V3 for gcsg-supervision@gmane.org; Mon, 14 Apr 2008 23:00:53 +0200 Original-Received: (qmail 15579 invoked by uid 76); 14 Apr 2008 21:00:33 -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 15565 invoked from network); 14 Apr 2008 21:00:33 -0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 62 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 84-51-160-74.pambow882.adsl.metronet.co.uk User-Agent: Thunderbird 2.0.0.12 (X11/20080226) In-Reply-To: <20080414164126.GP20279@utopia.intra.guy> X-Enigmail-Version: 0.95.6 Original-Sender: news Xref: news.gmane.org gmane.comp.sysutils.supervision.general:1707 Archived-At: Andras Korn wrote: > On Mon, Apr 14, 2008 at 03:31:16PM +0100, Robin Bowes wrote: > >> And, it would perhaps be less cluttered to do: >> >> #!/bin/sh >> >> if [ "$1" != "have-env" ]; then >> exec chpst -e ./env "$0" have-env >> fi >> >> exec chpst -u "$LOGUSER" svlogd -tt "$LOGDIR" > > Yes, that's even better. :) > OK, here's another refinement. This script: 1. Uses chpst -e to set some vars from ./env (if ./env exists) 2. Uses the name of the service dir as the log user and log dir, if the are not set in ./env 3. Creates the log dir, if it does not exist, and sets permissions #!/bin/sh # if we haven't already done so, check for ./env dir # if it exists, set some env vars if [ "$1" != "have-env" ]; then if [ -d ./env ]; then exec chpst -e ./env "$0" have-env fi fi LOG_PARENT=/var/log # Get the service name logdir=`pwd` svcdir=${logdir%/log} SERVICE_NAME=${svcdir##*/} # Set LOGUSER and LOGDIR to default values if not set in ./env : ${LOGUSER:=${LOG_PARENT}/${SERVICE_NAME}} : ${LOGDIR:=${LOG_PARENT}/${SERVICE_NAME}} # Make sure the log dir exists if [ ! -e "${LOGDIR}" ]; then mkdir -p "${LOGDIR}" fi # Set ownership & permissions on the log dir chown -R ${LOGUSER} "${LOGDIR}" chmod 750 "${LOGDIR}" chmod g+s "${LOGDIR}" # Now run the log process exec chpst -u "${LOGUSER}" svlogd -tt "${LOGDIR}" Any thoughts? R.