Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·56 lines (50 loc) · 2.14 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·56 lines (50 loc) · 2.14 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
48
49
50
51
52
53
54
55
56
#!/bin/bash
# Builds Fenestra, installs it to ~/Applications, and registers the login agent + watchdog.
# Re-run after every code change. Undo everything with ./restore.sh --uninstall
set -euo pipefail
cd "$(dirname "$0")"
SUPPORT="$HOME/Library/Application Support/Fenestra"
LABEL="local.fenestra.shell"
PLIST="$HOME/Library/LaunchAgents/$LABEL.plist"
APP="$HOME/Applications/Fenestra.app"
echo "Building (Release)..."
xcodebuild -project Fenestra.xcodeproj -target Fenestra -configuration Release SYMROOT="$PWD/build" build \
| grep -E "error:|BUILD (SUCCEEDED|FAILED)" || true
[ -d build/Release/Fenestra.app ] || { echo "Build failed."; exit 1; }
echo "Stopping any running copy..."
launchctl bootout "gui/$UID/$LABEL" 2>/dev/null || true
pkill -x Fenestra 2>/dev/null || true
sleep 1
echo "Installing to $APP"
mkdir -p "$HOME/Applications" "$SUPPORT" "$HOME/Library/LaunchAgents" "$HOME/Library/Logs"
rm -rf "$APP"
ditto build/Release/Fenestra.app "$APP"
for s in restore.sh apply-defaults.sh fenestra-run.sh; do
install -m 755 "Fenestra/Resources/$s" "$SUPPORT/$s"
done
cat > "$PLIST" <<EOF
<?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>$LABEL</string>
<key>AssociatedBundleIdentifiers</key><array><string>local.fenestra.Fenestra</string></array>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>$SUPPORT/fenestra-run.sh</string>
</array>
<key>RunAtLoad</key><true/>
<key>KeepAlive</key><dict><key>SuccessfulExit</key><false/></dict>
<key>ThrottleInterval</key><integer>5</integer>
<key>LimitLoadToSessionType</key><string>Aqua</string>
<key>ProcessType</key><string>Interactive</string>
<key>StandardOutPath</key><string>$HOME/Library/Logs/Fenestra.log</string>
<key>StandardErrorPath</key><string>$HOME/Library/Logs/Fenestra.log</string>
</dict>
</plist>
EOF
echo "Starting Fenestra (and at every login)..."
launchctl enable "gui/$UID/$LABEL"
launchctl bootstrap "gui/$UID" "$PLIST"
echo "Done. To undo: ./restore.sh (or ./restore.sh --uninstall to remove everything)"