-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·65 lines (59 loc) · 2.53 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·65 lines (59 loc) · 2.53 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
#!/bin/sh
# Dim0 desktop installer for macOS and Linux.
# curl -fsSL https://raw.githubusercontent.com/vcmf/dim0/main/install.sh | sh
#
# Downloads the newest release for your OS from GitHub. Terminal downloads are not
# Gatekeeper-quarantined, so on macOS this launches with no security prompt (the app
# is ad-hoc signed; a browser .dmg download is not notarized yet and would prompt).
set -eu
REPO="vcmf/dim0"
API="https://api.github.com/repos/$REPO/releases/latest"
say() { printf ' %s\n' "$1"; }
die() { printf '\nDim0 install failed: %s\n' "$1" >&2; exit 1; }
command -v curl >/dev/null 2>&1 || die "curl is required"
printf '\nInstalling Dim0...\n'
json="$(curl -fsSL "$API")" || die "could not reach GitHub"
tag="$(printf '%s' "$json" | grep -oE '"tag_name": *"[^"]+"' | head -1 | sed -E 's/.*"([^"]+)"$/\1/')"
[ -n "${tag:-}" ] && say "latest release: $tag"
os="$(uname -s)"
arch="$(uname -m)"
case "$os" in
Darwin)
[ "$arch" = "arm64" ] || die "only Apple Silicon (arm64) is built right now; yours is $arch"
url="$(printf '%s' "$json" | grep -oE 'https://[^"]+-mac\.zip' | head -1)"
[ -n "$url" ] || die "no macOS build found in $tag"
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
say "downloading $(basename "$url")"
curl -fsSL "$url" -o "$tmp/dim0.zip" || die "download failed"
/usr/bin/ditto -x -k "$tmp/dim0.zip" "$tmp" || die "could not unzip"
[ -d "$tmp/Dim0.app" ] || die "archive did not contain Dim0.app"
dest="/Applications"
[ -w "$dest" ] || dest="$HOME/Applications"
mkdir -p "$dest"
rm -rf "$dest/Dim0.app"
mv "$tmp/Dim0.app" "$dest/Dim0.app"
# Belt-and-suspenders: strip quarantine in case the file ever carried it.
xattr -dr com.apple.quarantine "$dest/Dim0.app" 2>/dev/null || true
say "installed to $dest/Dim0.app"
printf '\nDone. Launch it from Spotlight, or: open "%s/Dim0.app"\n\n' "$dest"
;;
Linux)
url="$(printf '%s' "$json" | grep -oE 'https://[^"]+\.AppImage' | head -1)"
[ -n "$url" ] || die "no Linux build found in $tag"
dest="${DIM0_BIN:-$HOME/.local/bin}"
mkdir -p "$dest"
say "downloading $(basename "$url")"
curl -fsSL "$url" -o "$dest/dim0" || die "download failed"
chmod +x "$dest/dim0"
say "installed to $dest/dim0"
case ":$PATH:" in
*":$dest:"*) : ;;
*) printf '\nNote: %s is not on your PATH. Add it, or run %s/dim0 directly.\n' "$dest" "$dest" ;;
esac
printf '\nDone. Run: dim0\n\n'
;;
*)
die "unsupported OS: $os (this installer covers macOS and Linux; Windows uses install.ps1)"
;;
esac