From owner-freebsd-rc@FreeBSD.ORG Wed Dec 19 22:48:03 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 E7EEAB24; Wed, 19 Dec 2012 22:48:03 +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 4909F8FC0C; Wed, 19 Dec 2012 22:48:02 +0000 (UTC) Received: by mail-bk0-f54.google.com with SMTP id je9so1302117bkc.41 for ; Wed, 19 Dec 2012 14:47:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=2R9cYSBSfR6SyhI5wiYYaA68M1jInso686g1Ml/xvp0=; b=Kvnn9J7qZM45GOYw4+lOJIUmQ2PcYkNV6Ci0B81I4dWjaoubzCcrh0MnkxibNTuHsS PySK1svnajqybndvVVNa03xG5gwZs6Iu6myYx8cljQMoVozR1wS67YM04+4L4fk3EsKZ LJ8HqNiHeGE6YuQUpzn0ENXHLlQlun48SMoUvUEEs+XdMYf4/LXytyb6kFv8nMl0ADw1 KkJBpE4PQwqLMwnqejvXA+e3eR6cD4GYcRORH04XrBJ3dNxRpTlXkVjTrTeo8ywEMK4r zk0H+nNB9Ig7eepKA98kltV0t8vE+HAS52SRmn75nKbMGMHQp6kQjF+HPEtY2xCegR+O Ydng== MIME-Version: 1.0 Received: by 10.204.4.131 with SMTP id 3mr3421921bkr.25.1355957276223; Wed, 19 Dec 2012 14:47:56 -0800 (PST) Received: by 10.204.167.71 with HTTP; Wed, 19 Dec 2012 14:47:56 -0800 (PST) In-Reply-To: <66E78C5BBEC1BC01C9A7E292@localhost> References: <66E78C5BBEC1BC01C9A7E292@localhost> Date: Wed, 19 Dec 2012 22:47:56 +0000 Message-ID: Subject: Re: Can't get start_precmd to do *anything* From: Chris Rees To: Paul Schmehl Content-Type: text/plain; charset=ISO-8859-1 Cc: FreeBSD RC List , FreeBSD Questions List X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list 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: Wed, 19 Dec 2012 22:48:04 -0000 On 19/12/2012, Paul Schmehl wrote: > I'm working on an rc.d init script for a port, and I am clearly in need of > a clue. > > I have a daemon that requires that a FIFO exist before it will start. The > FIFO is defined in the daemon's conf file. I could just point that out to > the user using "warn", but I thought it would be nicer to simply take care > of it programmatically. > > So I created this: > > start_precmd="${name}_ck4fifo()" Is this a copy/paste error, or is your function actually called _ck4fifo or _ch4fifo? > ${name}_ch4fifo() I'm surprised sh isn't choking on this, you can't use ${name} in a function name. Indirecting it is a waste of processing time, if I'm honest; just use start_precmd=pads_agent_prestart pads_agent_prestart() { do_something } We always have search and replace in case you choose to modify $name :) Chris > { > . ${pads_agent_conf} > echo "Checking to see if ${PADS_FIFO} exists......" > if [ ! -p ${PADS_FIFO} ]; then > echo "${PADS_FIFO} did not exist. Creating it now....." > `/usr/bin/mkfifo ${PADS_FIFO} > else > echo "${PADS_FIFO} already exists." > fi > } > > When I run the init script with rc_debug enabled, it calls the > start_precmd, but absolutely nothing happens. I don't even get the echos. > > # /usr/local/etc/rc.d/pads_agent onestart > /usr/local/etc/rc.d/pads_agent: DEBUG: checkyesno: pads_agent_enable is set > > to YES. > /usr/local/etc/rc.d/pads_agent: DEBUG: run_rc_command: start_precmd: > pads_agent_ck4fifo() > Starting pads_agent. > /usr/local/etc/rc.d/pads_agent: DEBUG: run_rc_command: doit: > /usr/local/bin/sguil-sensor/pads_agent.tcl -D -c > /usr/local/etc/sguil-sensor/pads_agent.conf > [root@buttercup4 /usr/ports/security/sguil-sensor-update/sguil-sensor]# > Error: Unable to read > /var/data/nsm/sguil-sensor/buttercup4.utdallas.edu/pads.fifo > > I even tried this but got the same result. > > ${name}_ch4fifo() > { > warn "You must create PADS_FIFO before starting ${name}." > warn "Set PADS_FIFO in the ${pads_agent_conf} file." > } > > The warn messages aren't in the messages file either, which is expected > behavior. > > What the heck is going on here? Is something wrong with rc.subr on this > host? Am I missing something? > > -- > 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 > > _______________________________________________ > freebsd-rc@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-rc > To unsubscribe, send any mail to "freebsd-rc-unsubscribe@freebsd.org" > > -- Chris Rees | FreeBSD Developer crees@FreeBSD.org | http://people.freebsd.org/~crees