From owner-freebsd-rc@FreeBSD.ORG Wed Dec 19 20:28:28 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 22630BC1 for ; Wed, 19 Dec 2012 20:28:28 +0000 (UTC) (envelope-from utisoft@gmail.com) Received: from mail-bk0-f46.google.com (mail-bk0-f46.google.com [209.85.214.46]) by mx1.freebsd.org (Postfix) with ESMTP id 9E8158FC14 for ; Wed, 19 Dec 2012 20:28:27 +0000 (UTC) Received: by mail-bk0-f46.google.com with SMTP id q16so1276275bkw.19 for ; Wed, 19 Dec 2012 12:28:26 -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=NitiMy95i2mMmRmDRAzHsZ/i70oW6Gw2QW6qfVHoOgI=; b=HvQCQSXvYWxw7FNdWgnShPAOx71LhbHqMY8utvPIvRxrGZnLuhoDvzgepsCVmtCxUk 7SdVjkWfFA3SfiBBerIDiClidoGBEIjMP3fzadNJYds6hDyeOIFogHPjEVRUeWmNKFKd tDYgjWT/fRDKv54KJlpi8oGZ44GOv1nYlvGwRzhRfULe9aZOsIoBKW4BojRfrPZY4Jl3 u+XreDcaTZxK6dYgrMUva8I/M+235VTmZhHrFFkz5G+4pYjx41qlP6Rqhz5NvbPoLeOz ooaVEBDsdj+rIi5beH+g58OAzBYMUSwZwUwwDW56yxUjbxnNRFzcODhxE5YnmmlRzjJ0 GzPw== MIME-Version: 1.0 Received: by 10.204.130.140 with SMTP id t12mr3312251bks.39.1355947269734; Wed, 19 Dec 2012 12:01:09 -0800 (PST) Received: by 10.204.167.71 with HTTP; Wed, 19 Dec 2012 12:01:09 -0800 (PST) Received: by 10.204.167.71 with HTTP; Wed, 19 Dec 2012 12:01:09 -0800 (PST) In-Reply-To: <6B03BFD5116AADF7BFE21262@utd71538.campus.ad.utdallas.edu> References: <6B03BFD5116AADF7BFE21262@utd71538.campus.ad.utdallas.edu> Date: Wed, 19 Dec 2012 20:01:09 +0000 Message-ID: Subject: Re: Need a clue about overriding default methods From: Chris Rees To: Paul Schmehl Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: freebsd-rc@freebsd.org 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 20:28:28 -0000 On 19 Dec 2012 17:19, "Paul Schmehl" wrote: > > I'm working on an rc.d init script for a port, and I am clearly in need of a clue. > > start, stop and status are not discriminating enough. This is a tcl script, so if I don't use procname="/usr/local/bin/tclsh85", rc.subr can't tell if the daemon is running or not. If I do use procname, it will kill *all* daemons running with tclsh. > > So I need to divert status and stop to make sure they are discriminating enough to only check for *this* daemon and only kill *this* daemon. > > Here's the relevant bits of my script: > > stop_cmd="${name}_stop()" > status_cmd="${name}_status()" > rc_pid=`ps -auxw | grep tclsh | grep pcap_agent | awk '{print $2}'` > > ${name}_status() > { > if [ -n ${rc_pid} ]; then > echo "${name} is running: ${rc_pid}" > else > echo "${name} not running?" > fi > } > ${name}_stop() > { > echo "Testing" > rc_pid=`ps -auxw | grep tclsh | grep pcap_agent | awk '{print $2}'` > if [ ${rc_pid} ]; then > kill -TERM ${rc_pid} > else > echo "${name} not running?" > fi > } > > When I run onestatus, I get nothing from the status function: > > # /usr/local/etc/rc.d/pcap_agent onestatus > /usr/local/etc/rc.d/pcap_agent: DEBUG: checkyesno: pcap_agent_enable is set to YES. > /usr/local/etc/rc.d/pcap_agent: DEBUG: run_rc_command: doit: pcap_agent_status() > > Same thing for onestop: > # /usr/local/etc/rc.d/pcap_agent onestop > /usr/local/etc/rc.d/pcap_agent: DEBUG: checkyesno: pcap_agent_enable is set to YES. > /usr/local/etc/rc.d/pcap_agent: DEBUG: run_rc_command: doit: pcap_agent_stop() > > As you can see, rc.subr is calling the function, but absolutely nothing happens inside that function. I've even tried adding an echo "Hello world!" and that doesn't print. > > I'm sure there some simple syntax thing I'm missing here, but my eyeballs are crossing from reading man (8) rc.subr and the "Practical rc.d scripting in BSD" article by Yar Tikhiy. Use a pidfile. I would give an example, but I'm pushed for time, sorry. If you get stuck I'll help as much as I can :) Chris