Package - Power Manager Daemon
The daemon provides the scheduling capabilities of Power Manager. This package also includes a selection of support files needed by the daemon to perform the schedule’s actions.
Requirements
A restart is required after installing this package.
The restart is needed to ensure the security rights take hold. Our testing found security changes do not propogate as expected until a restart.
Files Installed
/usr/local/powermanager/bin/powermanagerd
/usr/local/powermanager/bin/pmassistant.app
/usr/local/powermanager/bin/safershutdown
/usr/local/powermanager/bin/pmauthctl
/usr/local/powermanager/etc/launchd
/usr/local/powermanager/etc/PowerManager
/usr/local/powermanager/var
Facilities with particular shut down needs can modify the safershutdown script; this script completes a scheduled shut down.
Files Created During Installation
The post installation script installs additional essential files. These files are responsible for launching Power Manager’s daemon on start up.
On Mac OS X 10.4 or later, the following file is installed.
/Library/LaunchDaemons/uk.co.dssw.powermanager.plist
On Mac OS X 10.3.9, the following directory is installed.
/Library/StartupItems/PowerManager/
Scripts
The daemon package performs scripts in preparation for and after installation.
Preparation
The preparation script stops any existing instance of Power Manager. Care is taken to handle both SystemStarter and launchd managed instances of Power Manager’s daemon.
#!/bin/sh
# Must be run as root
# Power Manager 3.5+; launchd managed
if [ -e "/Library/LaunchDaemons/uk.co.dssw.powermanager.plist" ]; then
echo "Stopping powermanagerd through launchctl..."
/bin/launchctl unload /Library/LaunchDaemons/uk.co.dssw.powermanager.plist
fi
# Power Manager 3.0 - 3.2.1
if [ -e "/usr/local/powermanager/bin/powermanagerd" ]; then
echo "Stopping already running powermanagerd..."
/usr/local/powermanager/bin/powermanagerd -k stop
sleep 2
fi
exit 0
Post Installation
The post installation script performs four tasks.
- Sets up a global login item;
- Sets up security rights;
- Copies a job specification for SystemStarter or launchd;
- Launches the daemon process via the appropriate job manager.
The global login item ensures Power Manager can notify each user and has a means of cleanly logging out users.
Security rights are requested and modifications are propogated through to /etc/authorization.
#!/bin/sh
# Part of DssW Power Manager
# Copyright (c) 2007 Dragon Systems Software Limited
# Support: support@dssw.co.uk
#
# This script completes the installation process by copying Mac OS X version
# dependent files and setting up permissions.
### START ### PM3.7.3
# Get the product version's minor version number
OSMINORVERSION=`sw_vers -productVersion | sed 's/^[0-9]*\.\([0-9]*\).*/\1/'`
# If Mac OS X is Panther (10.3) or Tiger (10.4)...
if [ "$OSMINORVERSION" -lt "5" ]; then
# Install a global login item for pmassistant
sudo "$3/usr/local/powermanager/bin/pmassistant.app/Contents/MacOS/pmassistant" -i
echo "Inserted global login item for 'pmassistant.app'"
else
# ...else Leopard (10.5) or Snow Leopard (10.6) or beyond
# Use launchd's per-user functionality to manage pmassistant instances
sudo cp -R "$3/usr/local/powermanager/etc/launchd/uk.co.dssw.pmassistant.plist" "$3/Library/LaunchAgents/."
echo "Installed launchd job ticket for 'pmassistant'"
# Remove any previous global login item for pmassistant
sudo "$3/usr/local/powermanager/bin/pmassistant.app/Contents/MacOS/pmassistant" -r
fi
##
# Remove legacy authentication plug-in
if [ -e "$3/System/Library/CoreServices/SecurityAgentPlugins/pmauth.bundle" ]; then
echo "...removing legacy login window notification"
"$3/System/Library/CoreServices/SecurityAgentPlugins/pmauth.bundle/Contents/MacOS/pmauthctl" -u
rm -rf "$3/System/Library/CoreServices/SecurityAgentPlugins/pmauth.bundle"
fi
# Belt and braces approach to disabling pmauth
if [ -e "$3/usr/local/powermanager/bin/pmauthctl" ]; then
sudo "$3/usr/local/powermanager/bin/pmauthctl" -u
fi
### END ### PM3.7.3
# Set up security rights for administrators
sudo "$3/usr/local/powermanager/bin/powermanagerd" -i
echo "Set up rights for 'powermanagerd'"
# launchd or StartupItems
if [ -e "$3/Library/LaunchDaemons/" ]; then
# launchd, Mac OS X 10.4+
sudo cp -R "$3/usr/local/powermanager/etc/launchd/uk.co.dssw.powermanager.plist" "$3/Library/LaunchDaemons/."
echo "Installed launchd job ticket for 'powermanagerd'"
# remove existing Power Manager StartupItems
if [ -e "$3/Library/StartupItems/PowerManager/" ]; then
sudo /bin/rm -r "$3/Library/StartupItems/PowerManager"
fi
else
# StartupItems, Mac OS X 10.3.9
sudo cp -R "$3/usr/local/powermanager/etc/PowerManager" "$3/Library/StartupItems/."
sudo "$3/Library/StartupItems/PowerManager/PowerManager" start
echo "Installed StartUpItem for 'powermanagerd'"
fi
# Move any PM3.5 - 3.6.2 preferences to the new location
HOSTNAME=`hostname -s`
if [ -e "/var/root/Library/Preferences/uk.co.dssw.powermanager.daemon.$HOSTNAME.plist" ]; then
echo "Updating v3.5 - 3.6.2 preference location."
mv "/var/root/Library/Preferences/uk.co.dssw.powermanager.daemon.$HOSTNAME.plist" '/Library/Preferences/uk.co.dssw.powermanager.daemon.plist'
fi