Using File Configuration
To use Power Manager's File Configuration, a file containing requests and associated parameters needs to be created and placed with a specific directory.
The resulting configuration file can then be securely read by Power Manager.
The configuration file is read when Power Manager’s scheduler launches. This is typically moments after the computer starts up.
Additionally, Power Manager reads the configuration file when a Hang Up (HUP) signal is received. This signal based method greatly extends the usefulness of the file configuration approach. It also provides a secure approach without requiring user interaction to authenticate.
Creating Configuration Files
Let’s create a couple of simple configuration file and ask Power Manager to read them.
The easiest way to create these file is to use Power Manager’s pmctl
command line tool. Using macOS’s Terminal.app, change into the tool’s folder with the following command:
cd '/Applications/Power Manager.app/Contents/Tools'
Then pass the desired requests to pmctl
along with the -to-file-configuration
flag set to an output file path. In the example below, the request is to disable the scheduler:
./pmctl -to-file-configuration ~/Desktop/disable-scheduler.plist scheduler.setenabled enabled:boolean=false
The components of the command above are:
./pmctl
: Power Manager’s command line tool;-to-file-configuration ~/Desktop/disable-scheduler.plist
: a flag to save the requests to a file at~/Desktop/disable-scheduler.plist
;scheduler.setenabled
: an API request to set the scheduler’s enabled state;enabled:boolean=false
: an API parameterenabled
set to the boolean value offalse
.
After running the above command, a file has been created at on the desktop (~/Desktop
) called disable-scheduler.plist
.
Let’s create another example to enable the scheduler:
./pmctl -to-file-configuration ~/Desktop/enable-scheduler.plist scheduler.setenabled enabled:boolean=true
These files can also be created using a text editor or Property List tool; the file’s format is a Property List (.plist). Both XML or binary encoded property lists are supported.
Using Configuration Files
With two configuration files created, ~/Desktop/disable-scheduler.plist
and ~/Desktop/enable-scheduler.plist
, let’s next use these files.
To have Power Manager use one of these files on the next start up, follow the steps in Creating the Secure Directory; this section walks through the creation of the required directories and setting the correct permissions.
Let’s use pmctl
to apply the configuration immediately. This approach will delegate the creation the directories, setting up the file, and issuing the Hang Up signal to pmctl
.
First, let’s see what happens if a non-root user attempts this approach. Try running the following command:
./pmctl -as-file-configuration -from-file-configuration ~/Desktop/disable-scheduler.plist -verbose
The -verbose
flag has been included to ensure an error message is printed. Without -verbose
the exit status would indicate an error but nothing is printed to standard error or output.
You should see an error including the message below:
user root (0) is required
This error is reported because the file configuration needs to be set up by a user with administrative privileges of the computer.
Now that we know additional privileges are required, re-run the same command from above with the addition of sudo
:
sudo ./pmctl -as-file-configuration -from-file-configuration ~/Desktop/disable-scheduler.plist -verbose
Before pmctl
is executed, sudo
will ask for your password or credentials. Moments later pmctl
will run and Power Manager’s scheduler will be disabled – as per the request in the configuration file.
To enable the scheduler, issue the same command with the enable-scheduler.plist
file:
sudo ./pmctl -as-file-configuration -from-file-configuration ~/Desktop/enable-scheduler.plist -verbose
This is a simple single request example. It demonstrates how to create the configuration file and how to immediately apply it. The pmctl
tool was used for both steps but it is not essential to either.
This example also showed that root user is required to maintain security.
What was not required in the above above is almost as important. That leads the intended purpose of File Configuration, remote management.
Designed for Management
File Configuration does not require graphical access to the computer. A suitably privileged user with command line access to the computer can set up the required directories and file.
File Configuration can be embedded in a script or as a payload-free installer package. The destination drive need not even be part of a running computer.