let's say on SystemConfiguration:State:/Network/Global/IPv4 I want to
trigger two scripts:
/usr/local/bin/one
/usr/local/bin/two
There are lots of ways we could do this, but all of them are going to
require re-factoring the code.
I feel like this functionality is a pretty strong requirement for
releasing crankd in a pkg.
The question is, how do we lay it out? I'm removing the
encoding/doctype bits from the plist for sanity.
I offer up some examples.
<dict>
<key>SystemConfiguration</key>
<array>
<dict>
<key>State:/Network/Global/IPv4</key>
<dict>
<key>command</key>
<string>/usr/local/sbin/one</string>
</dict>
</dict>
<dict>
<key>State:/Network/Global/IPv4</key>
<dict>
<key>command</key>
<string>/usr/local/sbin/two</string>
</dict>
</dict>
</array>
</dict>
<dict>
<key>SystemConfiguration</key>
<dict>
<key>State:/Network/Global/IPv4</key>
<array>
<dict>
<key>command</key>
<string>/usr/local/sbin/one</string>
</dict>
<dict>
<key>command</key>
<string>/usr/local/sbin/two</string>
</dict>
</dict>
</dict>
<dict>
<key>SystemConfiguration</key>
<dict>
<key>State:/Network/Global/IPv4</key>
<array>
<dict>
<key>command</key>
<array>
<string>/usr/local/sbin/one</string>
<string>/usr/local/sbin/two</string>
</array>
</dict>
</dict>
</dict>
At the moment I'm leaning towards the latter, but would like to
probably not enforce an array, but convert internally to a single
element array if only one element is specified. (and obviously for all
of command, module, etc)
Can anyone think of any good reasons why we'd want to make the array
higher up at State:/Network/Global/IPv4 or even SystemConfiguration ?
> let's say on SystemConfiguration:State:/Network/Global/IPv4 I want to
> trigger two scripts:
>
> /usr/local/bin/one
> /usr/local/bin/two
>
> There are lots of ways we could do this, but all of them are going to
> require re-factoring the code.
>
> I feel like this functionality is a pretty strong requirement for
> releasing crankd in a pkg.
In situations where you are specifying both scripts, why not write a
wrapper? (I'm guessing you have a reason - just not sure what it is)
In situations where you have independent workflows that each want to
tap crankd, it would seem easier to just have multiple instances of
crankd each started with their own config file.
I'm thinking the latter applies to something that someone might write
that builds on crankd. The setup might contain a config, a set of
scripts (or module) and a launchd item. hmm - doing a quick test of
this seems like crankd is using 20mb of real memory - that may be a
limitation of this approach.
Of course making the changes you are suggesting doesn't prevent either
of the above approaches - it just may add complexity rarely used.
As a tool to be built upon - I think the idea of all independently
developed consumers of crankd events trying to share a single config
gets messy.
As far as making the change - I don't think any one way stands out as
the clear winner, so since you are doing the work - I think you should
just pick the one that makes the most sense as you implement the code
changes.
-P
-Greg
I could have sworn I had syntax like that working at some point
(although it might have been #1) - but the above is my preference
since it avoids duplication while allowing you to easily have multiple
action types (e.g. run this command and that function).
I strongly agree on the idea of converting any input into lists - it'd
really complicate the code everywhere else to have to test whether you
have a single item or a list.
Chris
I'm pretty sure it was only working for two different classes of
trigger, ie a module/function + a command.
>
> I strongly agree on the idea of converting any input into lists - it'd
> really complicate the code everywhere else to have to test whether you have
> a single item or a list.
absolutely.
Oh, and while we're on the subject: stick with plists in their
familiar but inelegant syntax or switch to something simple? There's a
certain argument that a crankd.d file should be as simple as this:
source=SystemConfiguration
key=State:/Network/Global/IPv4
command=/foo/bar
Chris
plists really do mean you never have to worry about escaping special
characters :)
On Thu, Aug 20, 2009 at 6:29 PM, Chris Adams<ch...@improbable.org> wrote:
>> I could have sworn I had syntax like that working at some point (although it
> might have been #1) - but the above is my preference since it avoids
> duplication while allowing you to easily have multiple action types (e.g.
> run this command and that function).
I'm pretty sure it was only working for two different classes of
trigger, ie a module/function + a command.
Yes, clay really did send this months ago and we didn't moderate it...
I've added clay as another owner now that chris and I are both pretty much absent...
A few more people at puppet camp expressed interest, so if anyone else wants to own the list....
One day I will write that article...