From owner-freebsd-ports@FreeBSD.ORG Fri Dec 7 07:20:30 2012 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AF5B2AA1; Fri, 7 Dec 2012 07:20:30 +0000 (UTC) (envelope-from utisoft@gmail.com) Received: from mail-bk0-f54.google.com (mail-bk0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id 04C028FC0C; Fri, 7 Dec 2012 07:20:29 +0000 (UTC) Received: by mail-bk0-f54.google.com with SMTP id je9so71122bkc.13 for ; Thu, 06 Dec 2012 23:20:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=vP6yrZrfvckIR1zkb6RlONPIMdNdd/wn1B2WoLrgtYY=; b=EWnHxm3YoTMTNUcRmE8FAcQ94XR/40N+e2MIT+wVWznTr+S6xG0CrlP8YCZxqFeOZU dgmyusBf7gpXe2LZNBB6me+rf663kpgFlIcvu4KciaeqSjxggwGvnxfQuaV5M3LntVHA 8HFB1J/6msvIPqoqY2lHZ4XyU73xQi6nJQrEMPSsFNG3/9uLgO0lcs/yjzNB1MeEGAg7 kmYvW4HeyQHKeGYPYSttDz5H3D3fgHyNPMe4udpUqsP2/svPSpYoF7d6sxnWONVTXT/+ f9i7n0tv33iS9DN7xovAGorExX3WL4jdqui1TQhnRblFiO4NjOOwnzks/3VUyMzGoRsH 3pFw== Received: by 10.204.130.140 with SMTP id t12mr1630086bks.39.1354864828696; Thu, 06 Dec 2012 23:20:28 -0800 (PST) MIME-Version: 1.0 Sender: utisoft@gmail.com Received: by 10.204.167.71 with HTTP; Thu, 6 Dec 2012 23:19:58 -0800 (PST) In-Reply-To: <42524AACF8B3EE83929D0673@utd71538.campus.ad.utdallas.edu> References: <0FC50D96AC60C2D7BEFC786A@utd71538.campus.ad.utdallas.edu> <42524AACF8B3EE83929D0673@utd71538.campus.ad.utdallas.edu> From: Chris Rees Date: Fri, 7 Dec 2012 07:19:58 +0000 X-Google-Sender-Auth: ARso9eKawRTRsHyOBlDXAN-ZMbE Message-ID: Subject: Re: rc.subr questions To: Paul Schmehl Content-Type: text/plain; charset=ISO-8859-1 Cc: "freebsd-rc@freebsd.org" , FreeBSD Ports List X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Dec 2012 07:20:30 -0000 On 6 December 2012 21:50, Paul Schmehl wrote: > --On December 6, 2012 9:30:04 PM +0000 Chris Rees wrote: > >> On 6 December 2012 21:10, Paul Schmehl wrote: >>> >>> --On December 6, 2012 8:45:50 PM +0000 Chris Rees >>> wrote: >>> >>>> [CC rc@] >>>> >>>> On 6 December 2012 20:36, Paul Schmehl wrote: >>>>> >>>>> >>>>> I'm trying to figure out how to get an rc.subr script to start and >>>>> stop a script. >>>>> >>>>> This works from the commandline (to start it): >>>>> tclsh /usr/local/bin/dir/script -D -c /usr/local/etc/conffile >>>>> >>>>> I've tried various combinations of: >>>>> >>>>> command_interpreter >>>>> argument_precmd >>>>> command_args >>>>> >>>>> but I keep getting this error: >>>>> unknown directive '/usr/local/bin/sguil-sensor/pads_agent.tcl' >>>>> >>>>> Doesn't matter if I make that string the val for command and don't use >>>>> command_interpreter or do use command_interpreter. >>>>> >>>>> I've read the man page over and over, but I'm clueless as to how to use >>>>> run_rc_script, which I *think* is the right way to call this script. >>>>> >>>> >>>> Make the script executable >>> >>> >>> >>> It is. >>> >>> >>> , put a shebang in; #!/usr/bin/env tclsh >>> >>> Here's the current script's starting lines: >>> >>> # !/bin/sh >>> # Run tcl from users PATH \ >>> exec tclsh "$0" "$@" >>>> >>>> >>>> >>>> # !/bin/sh >>>> >>>> >>>> . /etc/rc.subr >>>> >>>> name=tclshexample >>>> rcvar=tclshexample_enable >>>> >>>> load_rc_config $name >>>> >>>> : ${tclshexample_enable=YES} >>>> >>>> command="/usr/local/bin/dir/script" >>>> command_interpreter=tclsh >>>> command_args="-D -c /usr/local/etc/conffile" >>>> >>>> run_rc_command $@ >>>> >>>> http://www.bayofrum.net/~crees/scratch/tclshexample >>>> >>>> Would be much easier if you were to provide specifics or the actual >>>> script :) >>>> >>>> Chris >>>> >>> >>> Here's the rc script I'm working on. >>> >>> . /etc/rc.subr >>> >>> load_rc_config pads_agent >>> >>> # set defaults >>> >>> pads_agent_enable=${pads_agent_enable:-"NO"} >>> pads_agent_conf=${pads_agent_conf:-"/usr/local/etc/sguil-sensor/pads_age >>> nt.conf"} pads_agent_flags="${pads_agent_flags}:-"-D -c >>> ${pads_agent_conf}" >>> >>> name="pads_agent" >>> rcvar=pads_agent_enable >>> >>> command="/usr/local/bin/sguil-sensor/pads_agent.tcl" >>> command_interpreter="tclsh" >>> command_args=${pads_agent_flags} >>> >>> run_rc_command "$@" >>> >>> Here's the error I'm getting when I run start: >>> >>> /usr/local/etc/rc.d/pads_agent: WARNING: $command_interpreter tclsh != >>> /bin/sh >>> Starting pads_agent. >>> /usr/local/etc/rc.d/pads_agent: WARNING: $command_interpreter tclsh != >>> /bin/sh >>> /usr/local/etc/rc.d/pads_agent: unknown directive >>> '/usr/local/bin/sguil-sensor/pads_agent.tcl'. >>> Usage: /usr/local/etc/rc.d/pads_agent >>> [fast|force|one|quiet](start|stop|restart|rcvar|status|poll) >>> /usr/local/etc/rc.d/pads_agent: WARNING: failed to start pads_agent >>> >>> I tried changing the interpreter to "/bin/sh" but I got the same error. >>> >>> Here's the perms on the script: >>> >>> # ls -lsa /usr/local/bin/sguil-sensor/pads_agent.tcl >>> 12 -r-xr-xr-x 1 root wheel 11662 Dec 6 18:31 >>> /usr/local/bin/sguil-sensor/pads_agent.tcl >> >> >> The problem is I think that the idiomatic tclsh syntax is to use the >> # !/bin/sh shebang followed by some compat stuff... which doesn't play >> >> nicely with rc's idea of how scripts should look. >> >> If instead we use procname, that should work better. >> >> http://www.bayofrum.net/~crees/scratch/tclshexample2 >> >> Does your tclsh script daemonise? > > > It's supposed to, but it fails. Let's cease this discussion for now while I > do some troubleshooting. I think I have bigger problems than just the > rc.subr stuff, and I don't want to waste any more of your time. > I hope you manage to fix it. When you have, I'm happy to continue helping you with the rc script. Good luck, Chris