-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·151 lines (134 loc) · 4.15 KB
/
install.sh
File metadata and controls
executable file
·151 lines (134 loc) · 4.15 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/sh
# Ricochet CLI installer
# Usage: curl -fsSL https://raw.githubusercontent.com/ricochet/cli/main/install.sh | sh
set -e
VERSION="${RICOCHET_VERSION:-0.6.1}"
GITHUB_RELEASES_BASE="https://github.com/ricochet-rs/cli/releases/download/v${VERSION}"
S3_BASE_URL="https://hel1.your-objectstorage.com/ricochet-cli/v${VERSION}"
# Detect OS and architecture
OS="$(uname -s)"
ARCH="$(uname -m)"
# Detect Windows (Git Bash, MSYS2, MinGW, Cygwin)
case "${OS}" in
MINGW*|MSYS*|CYGWIN*)
IS_WINDOWS=1
OS="Windows"
;;
*)
IS_WINDOWS=0
;;
esac
# Determine default install directory
if [ -n "${RICOCHET_INSTALL_DIR:-}" ]; then
INSTALL_DIR="${RICOCHET_INSTALL_DIR}"
elif [ "$(id -u)" = "0" ]; then
INSTALL_DIR="/usr/local/bin"
elif [ "${IS_WINDOWS}" = "1" ]; then
INSTALL_DIR="$HOME/bin"
else
INSTALL_DIR="$HOME/.local/bin"
fi
case "${OS}" in
Darwin*)
case "${ARCH}" in
arm64|aarch64)
TARBALL="ricochet-${VERSION}-darwin-arm64.tar.gz"
BINARY_NAME="ricochet"
BASE_URL="${S3_BASE_URL}"
;;
x86_64)
TARBALL="ricochet-${VERSION}-darwin-x86_64.tar.gz"
BINARY_NAME="ricochet"
BASE_URL="${S3_BASE_URL}"
;;
*)
echo "Unsupported macOS architecture: ${ARCH}"
exit 1
;;
esac
;;
Linux*)
case "${ARCH}" in
x86_64)
TARBALL="ricochet-${VERSION}-linux-x86_64.tar.gz"
BINARY_NAME="ricochet-${VERSION}-linux-x86_64"
BASE_URL="${GITHUB_RELEASES_BASE}"
;;
aarch64|arm64)
TARBALL="ricochet-${VERSION}-linux-aarch64.tar.gz"
BINARY_NAME="ricochet-${VERSION}-linux-aarch64"
BASE_URL="${GITHUB_RELEASES_BASE}"
;;
*)
echo "Unsupported Linux architecture: ${ARCH}"
exit 1
;;
esac
;;
Windows)
case "${ARCH}" in
x86_64|x86-64)
TARBALL="ricochet-${VERSION}-windows-x86_64.exe.tar.gz"
BINARY_NAME="ricochet-${VERSION}-windows-x86_64.exe"
BASE_URL="${GITHUB_RELEASES_BASE}"
;;
*)
echo "Unsupported Windows architecture: ${ARCH}"
exit 1
;;
esac
;;
*)
echo "Unsupported operating system: ${OS}"
exit 1
;;
esac
URL="${BASE_URL}/${TARBALL}"
echo "Installing Ricochet CLI v${VERSION} (${OS} ${ARCH})..."
# Create temporary directory
TMP_DIR="$(mktemp -d)"
trap 'rm -rf "${TMP_DIR}"' EXIT
# Download and extract
echo "Downloading from ${URL}..."
if command -v curl > /dev/null 2>&1; then
curl -fsSL "${URL}" -o "${TMP_DIR}/${TARBALL}"
elif command -v wget > /dev/null 2>&1; then
wget -q "${URL}" -O "${TMP_DIR}/${TARBALL}"
else
echo "Error: curl or wget is required"
exit 1
fi
echo "Extracting..."
tar -xzf "${TMP_DIR}/${TARBALL}" -C "${TMP_DIR}"
# Determine final binary name
FINAL_NAME="ricochet"
# Ensure install directory exists
mkdir -p "${INSTALL_DIR}" 2>/dev/null || true
# Move the binary
if [ -w "${INSTALL_DIR}" ]; then
mv "${TMP_DIR}/${BINARY_NAME}" "${INSTALL_DIR}/${FINAL_NAME}"
else
echo "Error: Cannot write to ${INSTALL_DIR}"
echo "Set RICOCHET_INSTALL_DIR to a writable location, or run as root."
exit 1
fi
chmod +x "${INSTALL_DIR}/${FINAL_NAME}"
echo "✓ Ricochet CLI installed successfully!"
echo "Binary installed to: ${INSTALL_DIR}/${FINAL_NAME}"
echo ""
# Check if directory is in PATH
case ":${PATH}:" in
*":${INSTALL_DIR}:"*)
echo "Run 'ricochet --help' to get started."
;;
*)
echo "⚠️ Note: ${INSTALL_DIR} is not in your PATH."
echo ""
echo "To add it, run:"
echo " export PATH=\"\$PATH:${INSTALL_DIR}\""
echo ""
echo "To make it permanent, add that line to your shell profile (~/.bashrc, ~/.zshrc, etc.)."
echo ""
echo "For now, you can run: ${INSTALL_DIR}/${FINAL_NAME} --help"
;;
esac