Skip to content

Commit 1d8ae49

Browse files
authored
Make install script more robust (#1255)
* Add checks for download and file * Edit docs
1 parent a80b44f commit 1d8ae49

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

docs/contribute/locally.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ This guide uses the first option. If you'd like to clone the repository and buil
4040

4141
This downloads the latest binary, makes it executable, and installs it to your user PATH.
4242

43+
To download and install the binary file manually, refer to [Releases](https://github.com/elastic/docs-builder/releases) on GitHub.
44+
4345
2. **Run docs-builder from a docs folder**
4446

4547
Use the `serve` command from any docs folder to start serving the documentation at http://localhost:3000. The path to the `docset.yml` file that you want to build can be specified with `-p`:
@@ -66,16 +68,16 @@ If you get a `Permission denied` error, make sure that you aren't trying to run
6668

6769
This downloads the latest binary, makes it executable, and installs it to your user PATH.
6870

71+
To download and install the binary file manually, refer to [Releases](https://github.com/elastic/docs-builder/releases) on GitHub.
72+
6973
2. **Run docs-builder from a docs folder**
7074

7175
Use the `serve` command from any docs folder to start serving the documentation at http://localhost:3000. The path to the `docset.yml` file that you want to build can be specified with `-p`:
7276

7377
```sh
7478
docs-builder serve
7579
```
76-
77-
To download and install the binary file manually, refer to [Releases](https://github.com/elastic/docs-builder/releases) on GitHub.
78-
80+
7981
:::
8082
::::
8183

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)