Skip to content

Instantly share code, notes, and snippets.

@keeleysam
Created March 13, 2013 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keeleysam/a948470f777f4f45083c to your computer and use it in GitHub Desktop.
Save keeleysam/a948470f777f4f45083c to your computer and use it in GitHub Desktop.
#!/bin/sh
# $1 has the path to the source package
# $2 has the path to the target folder
# $3 has the path to the target volume
# $USER has the name of the user who launched the installer
# enforcing some critical permissions, just to be sure everything is OK
echo ". . . . . running the postflight script . . . . ."
echo " source path is: $1"
echo " target path is: $2"
echo " target volume path is: $3"
export LCC36P=`dirname "$1"`
echo " path to tools is: $LCC36P"
if [ -e "/System/Library/Extensions/LogitechHIDDevices.kext" ] ; then
/usr/sbin/chown -R root:wheel "/System/Library/Extensions/LogitechHIDDevices.kext"
/bin/chmod -R ug+r,go-w "/System/Library/Extensions/LogitechHIDDevices.kext"
elif [ -e "/System/Library/Extensions/LogicoolHIDDevices.kext" ] ; then
/usr/sbin/chown -R root:wheel "/System/Library/Extensions/LogicoolHIDDevices.kext"
/bin/chmod -R ug+r,go-w "/System/Library/Extensions/LogicoolHIDDevices.kext"
fi
if [ -e "/System/Library/Extensions/LogitechUnifying.kext" ] ; then
/usr/sbin/chown -R root:wheel "/System/Library/Extensions/LogitechUnifying.kext"
/bin/chmod -R ug+r,go-w "/System/Library/Extensions/LogitechUnifying.kext"
elif [ -e "/System/Library/Extensions/LogicoolUnifying.kext" ] ; then
/usr/sbin/chown -R root:wheel "/System/Library/Extensions/LogicoolUnifying.kext"
/bin/chmod -R ug+r,go-w "/System/Library/Extensions/LogicoolUnifying.kext"
fi
if [ -e "/Library/LaunchAgents/com.Logitech.Control Center.Daemon.plist" ] ; then
/usr/sbin/chown -R root:wheel "/Library/LaunchAgents/com.Logitech.Control Center.Daemon.plist"
/bin/chmod -R 644 "/Library/LaunchAgents/com.Logitech.Control Center.Daemon.plist"
fi
if [ -e "/Applications/Utilities/LCC Connection Utility.app" ]; then
/usr/sbin/chown -R root:admin "/Applications/Utilities/LCC Connection Utility.app"
/bin/chmod -R ug+rw,o-w "/Applications/Utilities/LCC Connection Utility.app"
fi
if [ -e "/Applications/Utilities/LCC Uninstaller.app" ]; then
/usr/sbin/chown -R root:admin "/Applications/Utilities/LCC Uninstaller.app"
/bin/chmod -R ug+rw,o-w "/Applications/Utilities/LCC Uninstaller.app"
fi
if [ -e "/Library/Application Support/Logitech.localized" ]; then
/usr/sbin/chown -R root:admin "/Library/Application Support/Logitech.localized"
/bin/chmod -R ug+rw,o-w "/Library/Application Support/Logitech.localized"
fi
if [ -e "/Library/Application Support/Logitech.localized/Logitech Control Center.localized/LCCDaemon.app" ]; then
/usr/sbin/chown root:admin "/Library/Application Support/Logitech.localized/Logitech Control Center.localized/LCCDaemon.app/Contents/Resources/SetPriority"
/bin/chmod u+s "/Library/Application Support/Logitech.localized/Logitech Control Center.localized/LCCDaemon.app/Contents/Resources/SetPriority"
fi
if [ -e "/Library/PreferencePanes/Logitech Control Center.prefPane" ]; then
/usr/sbin/chown -R root:admin "/Library/PreferencePanes/Logitech Control Center.prefPane"
/bin/chmod -R ug+rw,o-w "/Library/PreferencePanes/Logitech Control Center.prefPane"
/bin/chmod ugo+w "/Library/PreferencePanes/Logitech Control Center.prefPane"/Contents/Resources/*.lproj/html/
/bin/chmod ugo+w "/Library/PreferencePanes/Logitech Control Center.prefPane"/Contents/Resources/*.lproj/html/warranty_keyboards.htm
/bin/chmod ugo+w "/Library/PreferencePanes/Logitech Control Center.prefPane"/Contents/Resources/*.lproj/html/warranty_mice.htm
elif [ -e "/Library/PreferencePanes/Logicool Control Center.prefPane" ]; then
/usr/sbin/chown -R root:admin "/Library/PreferencePanes/Logicool Control Center.prefPane"
/bin/chmod -R ug+rw,o-w "/Library/PreferencePanes/Logicool Control Center.prefPane"
/bin/chmod ugo+w "/Library/PreferencePanes/Logicool Control Center.prefPane"/Contents/Resources/*.lproj/html/
/bin/chmod ugo+w "/Library/PreferencePanes/Logicool Control Center.prefPane"/Contents/Resources/*.lproj/html/warranty_keyboards.htm
/bin/chmod ugo+w "/Library/PreferencePanes/Logicool Control Center.prefPane"/Contents/Resources/*.lproj/html/warranty_mice.htm
fi
# Cleanup
if [ -e "$LCC36P/LCC Uninstaller Tool" ] ; then
"$LCC36P/LCC Uninstaller Tool" --postflight
fi
# Install last bits
# "$1/Contents/Resources/RMover" "$1" --postflight
echo "try to run RMover from Scripts"
"$LCC36P/RMover" "$LCC36P" --postflight
# Be sure that the system realizes that something changed, and rebuild extension cache
if [ -f "/Users/$USER/Library/Caches/.ApplePrefPanesCache" ]; then
/bin/rm -f "/Users/$USER/Library/Caches/.ApplePrefPanesCache"
fi
if [ -f "/Users/$USER/Library/Caches/com.apple.preferencepanes.cache" ]; then
/bin/rm -f "/Users/$USER/Library/Caches/com.apple.preferencepanes.cache"
fi
/usr/bin/touch "/Library/PreferencePanes"
/usr/bin/touch "/System/Library/PreferencePanes"
/usr/bin/touch "/Library/Keyboard Layouts"
if [ -f "/System/Library/Extensions.mkext" ]; then
/bin/rm -f "/System/Library/Extensions.mkext"
fi
# make sure drivers are 'loaded' so that the cache will include them
if [ -e "/System/Library/Extensions/LogitechHIDDevices.kext" ] ; then
/sbin/kextload "/System/Library/Extensions/LogitechHIDDevices.kext"
fi
if [ -e "/System/Library/Extensions/LogicoolHIDDevices.kext" ] ; then
/sbin/kextload "/System/Library/Extensions/LogicoolHIDDevices.kext"
fi
if [ -e "/System/Library/Extensions/LogitechUnifying.kext" ] ; then
/sbin/kextload "/System/Library/Extensions/LogitechUnifying.kext"
fi
/usr/bin/touch "/System/Library/Extensions"
# Daemon, launchd & login items
if [ -e "/Library/Application Support/Logitech.localized/Logitech Control Center.localized/LCCDaemon.app" ] ; then
/usr/bin/sudo -u $USER /usr/bin/osascript -e "tell application \"System Events\" to delete (every login item whose path ends with \"LCCDaemon.app\")"
if [ -e "/Library/LaunchAgents/com.Logitech.Control Center.Daemon.plist" ] ; then
/bin/launchctl load -w "/Library/LaunchAgents/com.Logitech.Control Center.Daemon.plist"
else
/usr/bin/sudo -u $USER /usr/bin/osascript -e "tell application \"System Events\" to make new login item with properties { path: \"/Library/Application Support/Logitech.localized/Logitech Control Center.localized/LCCDaemon.app\", hidden: false } at beginning"
fi
fi
# Add eReg to login items
if [ -e "/Library/Application Support/Logitech.localized/Logitech Control Center.localized/Logitech Registration.app" ] ; then
/usr/bin/sudo -u $USER /usr/bin/osascript -e "tell application \"System Events\" to make new login item with properties { path: \"/Library/Application Support/Logitech.localized/Logitech Control Center.localized/Logitech Registration.app\", hidden: false } at end"
elif [ -e "/Library/Application Support/Logitech.localized/Logitech Control Center.localized/Logicool Registration.app" ] ; then
/usr/bin/sudo -u $USER /usr/bin/osascript -e "tell application \"System Events\" to make new login item with properties { path: \"/Library/Application Support/Logitech.localized/Logitech Control Center.localized/Logicool Registration.app\", hidden: false } at end"
fi
# Launch the daemon (no longer needed, handled by launchd)
#if [ -e "/Library/Application Support/Logitech.localized/Logitech Control Center.localized/LCCDaemon.app" ] ; then
# /usr/bin/sudo -u $USER -b /Library/Application\ Support/Logitech.localized/Logitech\ Control\ Center.localized/LCCDaemon.app/Contents/MacOS/LCCDaemon
#fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment