-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·70 lines (62 loc) · 2.47 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·70 lines (62 loc) · 2.47 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Install OpenFront Map Watch:
# 1. Build the .app
# 2. Copy it to ~/Applications (created if missing)
# 3. Generate + install a user LaunchAgent so it starts at login
# 4. Start it now
#
# Safe to re-run. If already installed, this updates the binary and reloads.
set -euo pipefail
HERE="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
# 0. Make sure Xcode Command Line Tools are present — needed for swiftc.
# macOS *would* pop up the installer automatically on first xcrun call,
# but the shell process returns before the user clicks Install, so we'd
# crash. Prompt the user up front and wait for them to finish.
if ! /usr/bin/xcrun --find swiftc >/dev/null 2>&1; then
echo "==> Xcode Command Line Tools are required but not installed."
echo " Triggering the installer dialog now..."
/usr/bin/xcode-select --install >/dev/null 2>&1 || true
echo
echo " A macOS dialog should be visible. Click 'Install',"
echo " accept the license, and wait for the download to finish"
echo " (~5-15 minutes, roughly 1 GB)."
echo
read -rp "Press Enter here AFTER the install has completed... "
if ! /usr/bin/xcrun --find swiftc >/dev/null 2>&1; then
echo "swiftc still not found. Try running './install.sh' again." >&2
exit 1
fi
fi
APP_NAME="OpenFront Map Watch"
INSTALL_DIR="$HOME/Applications"
APP="$INSTALL_DIR/$APP_NAME.app"
PLIST_LABEL="com.openfrontmod.mapwatch"
PLIST_DEST="$HOME/Library/LaunchAgents/$PLIST_LABEL.plist"
# 1. Build.
bash "$HERE/build.sh"
# 2. Install.
mkdir -p "$INSTALL_DIR"
rm -rf "$APP"
cp -R "$HERE/dist/$APP_NAME.app" "$APP"
# 3. LaunchAgent.
APP_BIN="$APP/Contents/MacOS/OpenFrontMapWatch"
mkdir -p "$(dirname "$PLIST_DEST")"
sed "s|__APP_BIN__|$APP_BIN|g" \
"$HERE/com.openfrontmod.mapwatch.plist.template" > "$PLIST_DEST"
chmod 644 "$PLIST_DEST"
# 4. (Re)load.
launchctl bootout "gui/$UID/$PLIST_LABEL" >/dev/null 2>&1 || true
# launchd's deregistration is async; give it a beat before bootstrapping,
# otherwise rapid reinstalls can hit "Input/output error (5)".
for _ in 1 2 3; do
if launchctl bootstrap "gui/$UID" "$PLIST_DEST" 2>/dev/null; then break; fi
sleep 1
done
launchctl kickstart -k "gui/$UID/$PLIST_LABEL"
echo
echo "==> Installed"
echo " App: $APP"
echo " LaunchAgent: $PLIST_DEST"
echo " Config: \$HOME/Library/Application Support/openfrontmod/config.json"
echo
echo "Look for 'OF' in your menu bar (top-right). Click it to pick which maps to watch."