-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall.command
More file actions
executable file
·93 lines (80 loc) · 2.51 KB
/
Copy pathInstall.command
File metadata and controls
executable file
·93 lines (80 loc) · 2.51 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
set -euo pipefail
APP_NAME="Sentinel.app"
DEST="/Applications/$APP_NAME"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SOURCE_APP="$SCRIPT_DIR/$APP_NAME"
SOURCE_ZIP="$SCRIPT_DIR/Sentinel.app.zip"
TMP_DIR=""
BACKUP=""
cleanup() {
if [[ -n "${TMP_DIR:-}" && -d "$TMP_DIR" ]]; then
rm -rf "$TMP_DIR"
fi
}
trap cleanup EXIT
echo "=========================================="
echo " Sentinel — Install to Applications"
echo "=========================================="
echo
if [[ ! -d "$SOURCE_APP" ]]; then
if [[ -f "$SOURCE_ZIP" ]]; then
TMP_DIR="$(mktemp -d)"
echo "[1/4] Extracting Sentinel.app..."
ditto -x -k "$SOURCE_ZIP" "$TMP_DIR"
SOURCE_APP="$TMP_DIR/$APP_NAME"
else
echo "❌ Sentinel.app was not found next to Install.command."
echo " Put Sentinel.app (or Sentinel.app.zip) in the same folder and run again."
exit 1
fi
else
echo "[1/4] Found Sentinel.app."
fi
if [[ ! -d "$SOURCE_APP" ]]; then
echo "❌ The archive did not contain Sentinel.app at its top level."
exit 1
fi
if [[ -f "$SOURCE_APP/Contents/Info.plist" ]]; then
BUNDLE_ID="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' "$SOURCE_APP/Contents/Info.plist" 2>/dev/null || true)"
if [[ "$BUNDLE_ID" != "dev.sentinel.mac" ]]; then
echo "❌ Unexpected bundle identifier: ${BUNDLE_ID:-missing}"
echo " Refusing to install a bundle that is not Sentinel."
exit 1
fi
else
echo "❌ Sentinel.app is missing Contents/Info.plist."
exit 1
fi
echo "[2/4] Verifying app bundle..."
if ! codesign --verify --deep --strict "$SOURCE_APP" 2>/dev/null; then
echo "⚠️ Signature verification did not pass."
echo " This build may be ad-hoc signed. Installation can continue, but macOS may show a security prompt."
fi
if [[ -e "$DEST" ]]; then
BACKUP="/Applications/.Sentinel.previous.$(date +%Y%m%d%H%M%S).app"
echo "[3/4] Backing up the currently installed Sentinel..."
mv "$DEST" "$BACKUP"
else
echo "[3/4] No existing Sentinel installation found."
fi
install_failed=0
if ! ditto "$SOURCE_APP" "$DEST"; then
install_failed=1
fi
if [[ "$install_failed" -ne 0 || ! -d "$DEST" ]]; then
echo "❌ Installation failed."
rm -rf "$DEST" 2>/dev/null || true
if [[ -n "$BACKUP" && -d "$BACKUP" ]]; then
mv "$BACKUP" "$DEST"
echo " Previous Sentinel installation was restored."
fi
exit 1
fi
if [[ -n "$BACKUP" && -d "$BACKUP" ]]; then
rm -rf "$BACKUP"
fi
echo "[4/4] Installed successfully: $DEST"
echo
open "$DEST"
echo "✅ Sentinel is now in /Applications and has been opened."