On Wed, Nov 10, 2010 at 06:53:56PM -0500, Sandra Wittenbrock wrote:
>Hi,
>
>What would be the command to make sure a service (sysctl, firewall, etc)
>is running, and/or restart it when cfengine updates the config files?


I just recently added this snippet for checking a service that may be
"running", but doesn't always have a daemon.  This applies to things
that run from xinetd, for example.  The trick is that cfengine has a
readtcp function that can be used, if you're careful.

Here's the snippet:


<-----------------------------snip----------------------------->
bundle agent rsync {

vars:

     # the first 8 bytes of the rsync protocol are "@RSYNCD:" followed by
     # a space, and a protocol version number (which we don't care about)
     'bytes'      string => '8';
     'rsync_data' string => readtcp('localhost','873',"${const.n}","${bytes}");

classes:

    'runs_rsync' or => {
             "RsyncServers",
     };

     runs_rsync::
         'rsync_is_running' expression => regcmp("^.RSYNCD:$","${rsync_data}");

processes:
        # Doesn't work, since there may not be an rsyncd process!

files:
        # configuration for xinetd and rsync is pretty 
        # standard--copy files into place as needed

commands:

     runs_rsync.!rsync_is_running::
         "/etc/init.d/xinetd restart"
             contain => quiet_no_shell;

}
<-----------------------------snip----------------------------->

-- 
Jesse Becker
NHGRI Linux support (Digicon Contractor)
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to