Michael Kingsbury wrote:

> We're about to move to a new location, and I want a rule where if date
> is later than 13-Apr-05, define class PostMove. I don't see a good
> way other than contructing a huge concatinated rule to cover all the
> bases. Am I missing something obvious?

This works for me:

    #!/usr/sbin/cfagent -qvKf
    
    control:
        curtime = ( ExecResult(/bin/date +%s) )
        actionsequence = ( shellcommands )
    
    classes:
        # Tried using IsGreaterThan, but it didn't work
        # Got: Internal function (isgreaterthan) not recognized
        # I'm not running the most recent cfengine
        # Maybe it is a recent feature
        #after_date = ( IsGreaterThan(${curtime},1112817306) )
        after_date = ( ReturnsZero(/usr/bin/test ${curtime} -gt 1112817306) )
    
    shellcommands:
        after_date::
            "/bin/echo after date"

And in case you don't like mucking with %s format dates, here are a
couple of perl one-liners that might help:

    $ perl -e 'print localtime("1112817306")."\n"'
    Wed Apr  6 14:55:06 2005
    $ perl -e 'use HTTP::Date; print str2time("Wed Apr  6 14:55:06 2005")."\n"'
    1112817306

Best,
Brendan

_______________________________________________
Help-cfengine mailing list
Help-cfengine@gnu.org
http://lists.gnu.org/mailman/listinfo/help-cfengine

Reply via email to