-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathinstall.sh
More file actions
104 lines (90 loc) · 2.49 KB
/
Copy pathinstall.sh
File metadata and controls
104 lines (90 loc) · 2.49 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
97
98
99
100
101
102
103
104
#!/bin/sh
set -e
REPO="ericzakariasson/duster"
# Detect OS and architecture
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case "$OS" in
darwin) OS="macos" ;;
linux) OS="linux" ;;
*) echo "Unsupported OS: $OS"; exit 1 ;;
esac
case "$ARCH" in
x86_64) ARCH="x86_64" ;;
arm64|aarch64) ARCH="arm64" ;;
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac
# Linux only has x86_64 builds
if [ "$OS" = "linux" ]; then
ARCH="x86_64"
fi
ASSET="duster-${OS}-${ARCH}.tar.gz"
URL="https://github.com/${REPO}/releases/latest/download/${ASSET}"
echo "Downloading duster for ${OS}-${ARCH}..."
curl -fsSL "$URL" -o /tmp/duster.tar.gz
tar -xzf /tmp/duster.tar.gz -C /tmp
rm /tmp/duster.tar.gz
# Try to install to /usr/local/bin, fall back to ~/.local/bin
INSTALL_DIR=""
if [ -w "/usr/local/bin" ]; then
INSTALL_DIR="/usr/local/bin"
mv /tmp/duster "$INSTALL_DIR/duster"
elif command -v sudo >/dev/null 2>&1 && sudo -n true 2>/dev/null; then
# sudo available without password
INSTALL_DIR="/usr/local/bin"
sudo mv /tmp/duster "$INSTALL_DIR/duster"
sudo chmod +x "$INSTALL_DIR/duster"
else
# Fall back to user directory
INSTALL_DIR="$HOME/.local/bin"
mkdir -p "$INSTALL_DIR"
mv /tmp/duster "$INSTALL_DIR/duster"
chmod +x "$INSTALL_DIR/duster"
fi
echo "Installed to ${INSTALL_DIR}/duster"
# Check if install dir is in PATH
add_to_path() {
SHELL_NAME=$(basename "$SHELL")
case "$SHELL_NAME" in
zsh)
PROFILE="$HOME/.zshrc"
;;
bash)
if [ -f "$HOME/.bashrc" ]; then
PROFILE="$HOME/.bashrc"
else
PROFILE="$HOME/.bash_profile"
fi
;;
fish)
PROFILE="$HOME/.config/fish/config.fish"
mkdir -p "$(dirname "$PROFILE")"
;;
*)
PROFILE="$HOME/.profile"
;;
esac
if [ -f "$PROFILE" ] || [ "$SHELL_NAME" = "fish" ]; then
if ! grep -q "$INSTALL_DIR" "$PROFILE" 2>/dev/null; then
echo "" >> "$PROFILE"
echo "# Added by duster installer" >> "$PROFILE"
if [ "$SHELL_NAME" = "fish" ]; then
echo "set -gx PATH \"$INSTALL_DIR\" \$PATH" >> "$PROFILE"
else
echo "export PATH=\"$INSTALL_DIR:\$PATH\"" >> "$PROFILE"
fi
echo "Added $INSTALL_DIR to PATH in $PROFILE"
fi
fi
}
if ! echo "$PATH" | tr ':' '\n' | grep -qx "$INSTALL_DIR"; then
echo ""
add_to_path
echo ""
echo "Restart your terminal or run:"
echo " export PATH=\"$INSTALL_DIR:\$PATH\""
fi
echo ""
echo "✓ duster installed successfully!"
echo ""
echo "Run 'duster --help' to get started."