-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-helper.sh
More file actions
executable file
·47 lines (39 loc) · 1.18 KB
/
install-helper.sh
File metadata and controls
executable file
·47 lines (39 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
set -e
APP_PATH="/Applications/ChargeControl.app"
if [ ! -d "$APP_PATH" ]; then
echo "Error: Please copy ChargeControl.app to /Applications first."
exit 1
fi
DAEMON_PLIST="/Library/LaunchDaemons/com.chargecontrol.daemon.plist"
HELPER_BIN="$APP_PATH/Contents/MacOS/ChargeControlDaemon"
echo "Creating and Installing Daemon Plist..."
sudo cat << PLIST > /tmp/com.chargecontrol.daemon.plist
<?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">
<dict>
<key>Label</key>
<string>com.chargecontrol.daemon</string>
<key>Program</key>
<string>$HELPER_BIN</string>
<key>MachServices</key>
<dict>
<key>com.chargecontrol.daemon</key>
<true/>
</dict>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
PLIST
sudo cp /tmp/com.chargecontrol.daemon.plist "$DAEMON_PLIST"
# Fix permissions
sudo chown root:wheel "$DAEMON_PLIST"
sudo chmod 644 "$DAEMON_PLIST"
echo "Loading Daemon..."
sudo launchctl bootout system "$DAEMON_PLIST" 2>/dev/null || true
sudo launchctl bootstrap system "$DAEMON_PLIST"
echo "Done! The background daemon is now running."