-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·78 lines (66 loc) · 2.52 KB
/
install.sh
File metadata and controls
executable file
·78 lines (66 loc) · 2.52 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
#!/bin/bash
# install.sh — Install PerspectiveCLI
#
# Usage:
# sudo ./install.sh Install to /usr/local/bin
# sudo ./install.sh --uninstall Remove installed files
#
# Requires sudo because /usr/local/bin is owned by root on macOS.
set -euo pipefail
INSTALL_DIR="/usr/local/bin"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# ── Check sudo ────────────────────────────────────────────────────────
# /usr/local/bin is owned by root on macOS, so we need elevated privileges.
if [ "$(id -u)" -ne 0 ]; then
echo "Error: This script must be run with sudo."
echo ""
echo " sudo $0 ${1:-}"
echo ""
echo "/usr/local/bin is owned by root, so elevated privileges are required."
exit 1
fi
# ── Uninstall ─────────────────────────────────────────────────────────
if [ "${1:-}" = "--uninstall" ]; then
echo "Uninstalling Perspective CLI..."
rm -f "$INSTALL_DIR/perspective"
rm -f "$INSTALL_DIR/mlx.metallib"
echo "Done."
exit 0
fi
# ── Install ───────────────────────────────────────────────────────────
# Check that the binary exists in the same directory as this script
if [ ! -f "$SCRIPT_DIR/perspective" ]; then
echo "Error: 'perspective' binary not found in $SCRIPT_DIR"
echo "Run this script from inside the extracted archive."
exit 1
fi
echo "Installing Perspective CLI to $INSTALL_DIR..."
# Create install directory
mkdir -p "$INSTALL_DIR"
# Copy files
cp "$SCRIPT_DIR/perspective" "$INSTALL_DIR/perspective"
chmod +x "$INSTALL_DIR/perspective"
if [ -f "$SCRIPT_DIR/mlx.metallib" ]; then
cp "$SCRIPT_DIR/mlx.metallib" "$INSTALL_DIR/mlx.metallib"
fi
echo "Done."
echo ""
echo " $INSTALL_DIR/perspective"
if [ -f "$SCRIPT_DIR/mlx.metallib" ]; then
echo " $INSTALL_DIR/mlx.metallib"
fi
echo ""
# Check if install dir is on PATH
if echo "$PATH" | tr ':' '\n' | grep -qx "$INSTALL_DIR"; then
echo "Run 'perspective' to start."
else
echo "Add /usr/local/bin to your PATH by adding this to your ~/.zshrc:"
echo ""
echo " export PATH=\"/usr/local/bin:\$PATH\""
echo ""
echo "Then restart your terminal, or run:"
echo ""
echo " source ~/.zshrc"
fi
echo ""
echo "To uninstall: sudo ./install.sh --uninstall"