From owner-freebsd-rc@FreeBSD.ORG Thu Dec 6 21:10:50 2012 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7BA49CB; Thu, 6 Dec 2012 21:10:50 +0000 (UTC) (envelope-from prvs=680cec957=pschmehl_lists@tx.rr.com) Received: from ip-002.utdallas.edu (ip-002.utdallas.edu [129.110.20.108]) by mx1.freebsd.org (Postfix) with ESMTP id 7BD6B8FC0C; Thu, 6 Dec 2012 21:10:48 +0000 (UTC) X-Group: None X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvIEAEMJwVCBbgogTmdsb2JhbABEFr4vAwEBboIeAQEFOAI/EAsOCi5DFAYBEogQDMJpjDmDYmEDiF+dDoNv X-IronPort-AV: E=Sophos;i="4.84,232,1355119200"; d="scan'208";a="107924467" Received: from zxtm01.utdallas.edu (HELO utd71538.utdallas.edu) ([129.110.10.32]) by ip-002.utdallas.edu with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 Dec 2012 15:10:41 -0600 Date: Thu, 06 Dec 2012 15:10:40 -0600 From: Paul Schmehl To: Chris Rees , Paul Schmehl , freebsd-rc@freebsd.org Subject: Re: rc.subr questions Message-ID: <0FC50D96AC60C2D7BEFC786A@utd71538.campus.ad.utdallas.edu> In-Reply-To: References: X-Mailer: Mulberry/4.1.0a1 (Mac OS X) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline; size=3104 Cc: FreeBSD Ports List X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Paul Schmehl 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: Thu, 06 Dec 2012 21:10:50 -0000 --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_agent.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 -- Paul Schmehl, Senior Infosec Analyst As if it wasn't already obvious, my opinions are my own and not those of my employer. ******************************************* "It is as useless to argue with those who have renounced the use of reason as to administer medication to the dead." Thomas Jefferson "There are some ideas so wrong that only a very intelligent person could believe in them." George Orwell