Date: Sun, 4 Apr 2010 23:45:46 -0400 (EDT) From: "Daniel V. Klein" <dan@klein.com> To: FreeBSD-gnats-submit@FreeBSD.org Cc: "Daniel V. Klein" <dan@klein.com> Subject: conf/145399: rc.d scripts are unable to start/stop programs whose name contains '-' Message-ID: <201004050345.o353jkkU001052@howl.lonewolf.com> Resent-Message-ID: <201004050420.o354K2mI039856@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 145399 >Category: conf >Synopsis: rc.d scripts are unable to start/stop programs whose name contains '-' >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Apr 05 04:20:02 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Daniel V. Klein >Release: FreeBSD 8.0-RELEASE i386 >Organization: >Environment: System: FreeBSD ns.ibp.com 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Sat Nov 21 15:48:17 UTC 2009 root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386 >Description: I wanted to write an rc.d script for Cfengine3 that would start "cf-execd" (and stop a few more programs), and attempted to use the generic start-stop functions (what I tried to do was call my script cfengine3.sh, and in that script define command="/usr/sbin/cf-execd"). However, there is a "feature" in /etc/rc.subr which overwrites the command name if the command has a '-' in it (the actual bug is in the eval which creates the _override_command variable). I found a workaround wherein I created a cfengine3_start() that starts ${_saved_command} and another cfengine3_stop() function to stop the various components that are run by the main daemon (I would have needed this anyway, but the bug was on start). This was no big deal, but it was "interesting" that I can't reference the command "cf-execd" using the standard "start" and "stop" functions. >How-To-Repeat: #!/bin/sh # # REQUIRE: networking syslog # PROVIDE: cfengine3 # # Add the following line to /etc/rc.conf to enable cfengine: # # cfengine3_enable="YES" # . /etc/rc.subr name="cfengine3" command="/usr/sbin/cf-execd" rcvar=`set_rcvar` load_rc_config "$name" cfengine3_enable=${cfengine3_enable-"NO"} run_rc_command "$1" >Fix: #!/bin/sh # # REQUIRE: networking syslog # PROVIDE: cfengine3 # # Add the following line to /etc/rc.conf to enable cfengine: # # cfengine3_enable="YES" # . /etc/rc.subr name="cfengine3" components="cf-execd cf-agent cf-serverd cf-monitord cf-report cf-know" command="/usr/sbin/cf-execd" rcvar=`set_rcvar` # There is a bug in /etc/rc.subr which destroys the command name if the # command has a '-' in it (the bug is in the eval which creates the # _override_command variable. So we write our own kludgy cfengine3_start _saved_command="/var/cfengine/bin/cf-execd" stop_cmd="cfengine3_stop" start_cmd="cfengine3_start" cfengine3_start() { if [ ! -x ${_saved_command} ]; then warn "cannot run $_saved_command" return 1 fi $_saved_command } cfengine3_stop() { echo "Stopping cfengine components: ${components}" pkill ${components} } load_rc_config "$name" cfengine3_enable=${cfengine3_enable-"NO"} run_rc_command "$1" >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004050345.o353jkkU001052>