-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·57 lines (45 loc) · 1.34 KB
/
install.sh
File metadata and controls
executable file
·57 lines (45 loc) · 1.34 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
#!/bin/sh
set -e
REPO="dualentry/dualentry-cli"
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
get_arch() {
case "$(uname -m)" in
x86_64|amd64) echo "x86_64" ;;
arm64|aarch64) echo "arm64" ;;
*) echo "Unsupported architecture: $(uname -m)" >&2; exit 1 ;;
esac
}
get_os() {
case "$(uname -s)" in
Darwin) echo "macos" ;;
Linux) echo "linux" ;;
*) echo "Unsupported OS: $(uname -s)" >&2; exit 1 ;;
esac
}
OS=$(get_os)
ARCH=$(get_arch)
TARGET="${OS}-${ARCH}"
if [ "$OS" = "linux" ] && [ "$ARCH" = "arm64" ]; then
echo "Linux arm64 is not currently supported." >&2
exit 1
fi
echo "Detecting latest release..."
LATEST=$(curl -s "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed 's/.*: "//;s/".*//')
if [ -z "$LATEST" ]; then
echo "Failed to detect latest release." >&2
exit 1
fi
URL="https://github.com/${REPO}/releases/download/${LATEST}/dualentry-${TARGET}"
TMPFILE=$(mktemp)
echo "Downloading dualentry ${LATEST} for ${TARGET}..."
curl -fSL "$URL" -o "$TMPFILE"
chmod +x "$TMPFILE"
mkdir -p "$INSTALL_DIR"
if [ -w "$INSTALL_DIR" ]; then
mv "$TMPFILE" "$INSTALL_DIR/dualentry"
else
echo "Installing to ${INSTALL_DIR} (requires sudo)..."
sudo mv "$TMPFILE" "$INSTALL_DIR/dualentry"
fi
echo "Installed dualentry to ${INSTALL_DIR}/dualentry"
echo "Run 'dualentry --help' to get started."