Notes on using CFEngine on Mac OS X 10.3 (Panther). General tips for CFEngine on Mac OS X are available.
Installation
Even with Xcode installed, Mac OS X 10.3 lacks high enough versions of Berkeley DB and OpenSSL. Install from a ports system, or compile local versions of these libraries.
Tips
- Set cfengine class by battery state.
- Trigger runs via set-hostname.
As of Mac OS X 10.3.8, the ioreg command reports the battery capacity.
$ ioreg -l -w0 | grep Capacity
| | | "IOBatteryInfo" = ({"Capacity"=3575,"Amperage"=0,↵
"Cycle Count"=115,"Current"=3574,"Voltage"=16734,"Flags"=838860805,↵
"AbsoluteMaxCapacity"=4200})
| | | | "IOBatteryInfo" = ({"Capacity"=3575,"Amperage"=0,↵
"Cycle Count"=115,"Current"=3574,"Voltage"=16734,"Flags"=838860805,↵
"AbsoluteMaxCapacity"=4200})
A wrapper script could parse the output and detect whether the system is running off the charger, and set the sys_power class via exit codes: 0 if on power, 1 if not. Using the sys_power class, expensive disk actions can be avoided when running on battery power.
classes:
darwin::
sys_power = ( '/var/cfengine/bin/osx-check-power' )
shellcommands:
darwin.sys_power::
"/usr/libexec/locate.updatedb" ifelapsed=1439
One way to trigger cfengine runs is by altering the special set-hostname script to launch cfagent. Under Mac OS X 10.3, this file can be located at /System/Library/SystemConfiguration/Kicker.bundle/Contents/Resources/set-hostname. Run cfagent with --no-splay to avoid delays, or run a specific cfengine configuration file (via --file) to carry out specific actions.
control:
workdir = ( /var/cfengine )
editfiles:
{
/System/Library/SystemConfiguration/Kicker.bundle/Contents/Resources/↵
set-hostname
Backup "single"
BeginGroupIfNoLineContaining "cfagent"
IncrementPointer "-10000"
LocateLineMatching "^[^#].*$"
InsertLine "$(workdir)/bin/cfagent --no-splay &"
EndGroup
}