18 lines
899 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
# Retire the product-owned GUI and duplicate system daemon on package upgrade.
pkill -f '^/Applications/drosync.app/Contents/MacOS/drosync-gui' 2>/dev/null || true
launchctl bootout system/com.drobotics.drosync.daemon 2>/dev/null || true
rm -f /Library/LaunchDaemons/com.drobotics.drosync.daemon.plist
if [[ -f /Applications/drosync.app/Contents/Info.plist ]]; then
bundle_id=$(/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' /Applications/drosync.app/Contents/Info.plist 2>/dev/null || true)
if [[ "$bundle_id" == "com.drobotics.drosync" ]]; then
rm -rf /Applications/drosync.app
fi
fi
console_uid=$(stat -f '%u' /dev/console)
if [[ "$console_uid" -ge 500 ]]; then
launchctl bootout "gui/$console_uid/com.drobotics.drosync.agent" 2>/dev/null || true
launchctl bootstrap "gui/$console_uid" /Library/LaunchAgents/com.drobotics.drosync.agent.plist
fi