Skip to content

Commit f10c488

Browse files
committed
Added basic install script.
1 parent 3d7d4f0 commit f10c488

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

INSTALL

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
URL="https://github.com/peterHoburg/DRYdock/releases/latest/download/drydock"
5+
6+
BINARY_NAME="drydock"
7+
# Check if the binary is already installed in the PATH
8+
INSTALL_PATH=$(command -v "$BINARY_NAME" 2>/dev/null || true)
9+
10+
if [ -n "$INSTALL_PATH" ]; then
11+
# Binary already exists, replace it where it is
12+
TARGET_DIR=$(dirname "$INSTALL_PATH")
13+
else
14+
# Binary not found, check if $HOME/bin or $HOME/.local/bin is in the PATH
15+
if [[ ":$PATH:" == *":$HOME/bin:"* ]]; then
16+
TARGET_DIR="$HOME/bin"
17+
elif [[ ":$PATH:" == *":$HOME/.local/bin:"* ]]; then
18+
TARGET_DIR="$HOME/.local/bin"
19+
else
20+
echo "Error: Neither \$HOME/bin nor \$HOME/.local/bin is in your PATH."
21+
echo "Please add one of them to PATH and re-run this script."
22+
exit 1
23+
fi
24+
fi
25+
26+
# Ensure the directory exists
27+
mkdir -p "$TARGET_DIR"
28+
29+
# Check write permissions for the target directory
30+
if [ ! -w "$TARGET_DIR" ]; then
31+
echo "Directory $TARGET_DIR is not writable by the current user."
32+
echo "Please adjust directory permissions before re-running this script."
33+
exit 1
34+
fi
35+
36+
echo "Downloading $BINARY_NAME from $URL to $TARGET_DIR..."
37+
if ! curl -fLo "$TARGET_DIR/$BINARY_NAME" "$URL"; then
38+
echo "Failed to download $URL. Please check the URL and try again."
39+
exit 1
40+
fi
41+
42+
# Make the binary executable
43+
chmod u+x "$TARGET_DIR/$BINARY_NAME"
44+
45+
echo "$BINARY_NAME successfully installed in $TARGET_DIR."

0 commit comments

Comments
 (0)