File Configuration
Power Manager's Scheduler provides a method of updating the configuration through Property List, `.plist` files. This method can be used to distribute schedules, licence codes, and other settings where access to the Mac is restricted.
On launch, Power Manager’s Scheduler looks for a configuration file in a specific location. If the file exists, and has changed since the last launch, then the enclosed set of requests are issued.
The configuration file can contain any valid pmdctl
API request. This allows a configuration file to set up Power Manager precisely as desired, without needing a network connection.
Configuration file location on macOS:
/Library/Application Support/Power Manager/Configuration/pmd.plist
The pmd.plist
file is checked and loaded at launch.
We use the File Configuration method to support the creation of installers containing custom schedules and licence details.
Security
To ensure Power Manager’s security, the configuration file and the location must have specific ownership and access permissions set. The Scheduler will not use a configuration file unless the security requirements are met:
- The file must be owned by
root
. - Only the owner may have write permission to the file.
- Only the owner may have write permission to the parent folder,
Configuration
. - The file must not be executable.
- The file must be a regular file.
- The parent folder,
Configuration
, must be a regular directory. - The file and the file’s parent directory must not be symbolic links.
The file configuration permissions and file layout must match:
drwxr-xr-x root:wheel Configuration
-rw-r----- root:wheel Configuration/pmd.plist
Creating the Secure Directory
Use the following shell script to set the correct parent directory and file permissions:
cd '/Library/Application Support/Power Manager/'
sudo mkdir Configuration
sudo cp ~/Desktop/pmd.plist Configuration/.
sudo chown -R root:wheel Configuration
sudo chmod 640 Configuration/pmd.plist
sudo chmod 755 Configuration
Applying a Configuration File
The configuration file is automatically checked and applied when Power Manager’s Scheduler is launched. This normally occurs when the Mac is powered on or restarted.
To avoid needing to restart the Mac each time the configuration file is updated, Power Manager’s Scheduler supports a manual alternative.
The Scheduler can be asked to check the configuration file by sending a Hang Up (HUP
) signal. HUP is a UNIX signal. On receiving a HUP signal, the Scheduler will check the configuration file for changes, and apply the contents if appropriate.
Below is a shell command for sending a Hang Up (HUP) signal to the uk.co.dssw.powermanager.pmd
process:
sudo killall -HUP uk.co.dssw.powermanager.pmd
We support this method to create configuration only installers that do not need a restart.
See using File Configuration for an guide to creating and using configuration files.
File Format
The configuration file is binary or XML Property List formatted. The file’s root object must be an array.
The array contains dictionary items. Each dictionary item represents an API request.
The request dictionary has only two entries:
Key | Type | Value |
---|---|---|
request | string | API request |
parameters | dictionary | parameter key/value pairs (optional) |
Each request dictionary in the configuration file is read, encoded as an API request, and issued. If a request fails, the remaining requests in the configuration file are skipped.
Below is an example configuration file containing two requests:
- set the notification period to 10 minutes (900 seconds);
- set the warning period to 10 seconds.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>request</key>
<string>notifications.setnotifyperiod</string>
<key>parameters</key>
<dict>
<key>seconds</key>
<integer>900</integer>
</dict>
</dict>
<dict>
<key>request</key>
<string>notifications.setwarningperiod</string>
<key>parameters</key>
<dict>
<key>seconds</key>
<integer>10</integer>
</dict>
</dict>
</array>
</plist>