Skip to content

Commit c376edf

Browse files
committed
Add checks for download and file
1 parent b133c9d commit c376edf

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

install.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
2-
set -e
2+
set -euo pipefail
33

44
# Determine OS type and architecture
55
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
@@ -56,11 +56,22 @@ fi
5656
echo "Downloading docs-builder for $OS/$ARCH..."
5757

5858
# Download the appropriate binary
59-
curl -LO "https://github.com/elastic/docs-builder/releases/latest/download/$BINARY"
59+
if ! curl -LO "https://github.com/elastic/docs-builder/releases/latest/download/$BINARY"; then
60+
echo "Error: Failed to download $BINARY. Please check your internet connection."
61+
exit 1
62+
fi
63+
64+
# Validate the downloaded file
65+
if [ ! -s "$BINARY" ]; then
66+
echo "Error: Downloaded file $BINARY is missing or empty."
67+
exit 1
68+
fi
6069

6170
# Extract only the docs-builder file to /tmp directory
62-
# Use -o flag to always overwrite files without prompting
63-
unzip -j -o "$BINARY" docs-builder -d /tmp
71+
if ! unzip -j -o "$BINARY" docs-builder -d /tmp; then
72+
echo "Error: Failed to extract docs-builder from $BINARY."
73+
exit 1
74+
fi
6475

6576
# Ensure the binary is executable
6677
chmod +x /tmp/docs-builder

0 commit comments

Comments
 (0)