Skip to content

Commit 673aef0

Browse files
devm33Copilot
andauthored
Update install.sh
Co-authored-by: Copilot <[email protected]>
1 parent 6990535 commit 673aef0

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

install.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,26 @@ echo "Downloading from: $DOWNLOAD_URL"
2929
DOWNLOAD_DIR="${HOME}/.copilot"
3030
mkdir -p "$DOWNLOAD_DIR"
3131

32-
# Download and extract
32+
# Download and extract with error handling
33+
TMP_TARBALL="$(mktemp)"
3334
if command -v curl >/dev/null 2>&1; then
34-
curl -fsSL "$DOWNLOAD_URL" | tar -xz -C "$DOWNLOAD_DIR"
35+
curl -fsSL "$DOWNLOAD_URL" -o "$TMP_TARBALL"
3536
elif command -v wget >/dev/null 2>&1; then
36-
wget -qO- "$DOWNLOAD_URL" | tar -xz -C "$DOWNLOAD_DIR"
37+
wget -qO "$TMP_TARBALL" "$DOWNLOAD_URL"
3738
else
38-
echo "Error: Neither curl nor wget found. Please install one of them." >&2
39+
echo "Error: Neither curl nor wget found. Please install one of them."
3940
exit 1
4041
fi
4142

43+
# Check that the file is a valid tarball
44+
if ! tar -tzf "$TMP_TARBALL" >/dev/null 2>&1; then
45+
echo "Error: Downloaded file is not a valid tarball or is corrupted."
46+
rm -f "$TMP_TARBALL"
47+
exit 1
48+
fi
49+
50+
tar -xz -C "$DOWNLOAD_DIR" -f "$TMP_TARBALL"
51+
rm -f "$TMP_TARBALL"
4252
if [ "$(id -u 2>/dev/null || echo 1)" -eq 0 ]; then
4353
PREFIX="${PREFIX:-/usr/local}"
4454
else

0 commit comments

Comments
 (0)