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. 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" 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"
Responsible Changed From-To: freebsd-bugs->freebsd-rc Over to maintainer(s).
For bugs matching the following criteria: Status: In Progress Changed: (is less than) 2014-06-01 Reset to default assignee and clear in-progress tags. Mail being skipped
Keyword: patch or patch-ready – in lieu of summary line prefix: [patch] * bulk change for the keyword * summary lines may be edited manually (not in bulk). Keyword descriptions and search interface: <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>