-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·96 lines (82 loc) · 2.88 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·96 lines (82 loc) · 2.88 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
94
95
96
#!/bin/bash
set -euo pipefail
APP_NAME="Ossue"
BUNDLE_ID="com.eladkaplan.ossue"
REPO="kaplanelad/ossue"
echo "Installing ${APP_NAME}..."
# macOS only
if [ "$(uname)" != "Darwin" ]; then
echo "Error: This install script is for macOS only."
echo "For Linux/Windows, download from: https://github.com/${REPO}/releases"
exit 1
fi
# Detect architecture
ARCH=$(uname -m)
if [ "$ARCH" = "arm64" ]; then
DMG_PATTERN="_aarch64.dmg"
elif [ "$ARCH" = "x86_64" ]; then
DMG_PATTERN="_x64.dmg"
else
echo "Error: Unsupported architecture: ${ARCH}"
exit 1
fi
# Get latest release tag
TAG=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"tag_name": *"([^"]+)".*/\1/')
if [ -z "$TAG" ]; then
echo "Error: Could not determine latest release."
exit 1
fi
echo "Latest release: ${TAG}"
# Find the DMG asset URL
DMG_URL=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"browser_download_url"' | grep "${DMG_PATTERN}" | sed -E 's/.*"browser_download_url": *"([^"]+)".*/\1/')
if [ -z "$DMG_URL" ]; then
echo "Error: Could not find DMG for architecture ${ARCH}."
exit 1
fi
# Download
TMPDIR_PATH=$(mktemp -d)
DMG_PATH="${TMPDIR_PATH}/${APP_NAME}.dmg"
echo "Downloading ${APP_NAME} (${ARCH})..."
curl -fSL --progress-bar -o "$DMG_PATH" "$DMG_URL"
# Mount DMG
echo "Installing..."
MOUNT_POINT=$(hdiutil attach "$DMG_PATH" -nobrowse -noautoopen 2>/dev/null | grep '/Volumes/' | sed 's/.*\/Volumes/\/Volumes/')
if [ -z "$MOUNT_POINT" ]; then
echo "Error: Failed to mount DMG."
rm -rf "$TMPDIR_PATH"
exit 1
fi
# If the app is running, quit it gracefully before replacing
if osascript -e "application id \"${BUNDLE_ID}\" is running" 2>/dev/null | grep -q "true"; then
echo "${APP_NAME} is currently running. Quitting..."
osascript -e "tell application id \"${BUNDLE_ID}\" to quit" 2>/dev/null || true
# Wait up to 5 seconds for graceful shutdown
for i in $(seq 1 10); do
if ! osascript -e "application id \"${BUNDLE_ID}\" is running" 2>/dev/null | grep -q "true"; then
break
fi
sleep 0.5
done
# Force kill if still running
if osascript -e "application id \"${BUNDLE_ID}\" is running" 2>/dev/null | grep -q "true"; then
echo "Force closing ${APP_NAME}..."
pkill -f "${APP_NAME}.app/Contents/MacOS/" 2>/dev/null || true
sleep 1
fi
fi
# Copy to Applications (remove old version if exists)
if [ -d "/Applications/${APP_NAME}.app" ]; then
echo "Removing previous installation..."
rm -rf "/Applications/${APP_NAME}.app"
fi
cp -R "${MOUNT_POINT}/${APP_NAME}.app" /Applications/
# Unmount
hdiutil detach "$MOUNT_POINT" -quiet 2>/dev/null || true
# Clean up
rm -rf "$TMPDIR_PATH"
# Remove quarantine attribute
xattr -cr "/Applications/${APP_NAME}.app" 2>/dev/null || true
echo ""
echo "${APP_NAME} has been installed to /Applications/${APP_NAME}.app"
echo "Opening ${APP_NAME}..."
open "/Applications/${APP_NAME}.app"