Skip to content

Commit 10121ec

Browse files
authored
Merge pull request #37 from peterHoburg/33-add-installupdate-script
2 parents 3d7d4f0 + 272b5c3 commit 10121ec

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

INSTALL

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
echo "Previous install found $TARGET_DIR. Replacing..."
14+
else
15+
# Binary not found, check if $HOME/bin or $HOME/.local/bin is in the PATH
16+
if [[ ":$PATH:" == *":$HOME/bin:"* ]]; then
17+
TARGET_DIR="$HOME/bin"
18+
elif [[ ":$PATH:" == *":$HOME/.local/bin:"* ]]; then
19+
TARGET_DIR="$HOME/.local/bin"
20+
else
21+
echo "Error: Neither \$HOME/bin nor \$HOME/.local/bin is in your PATH."
22+
echo "Please add one of them to PATH and re-run this script."
23+
exit 1
24+
fi
25+
fi
26+
27+
# Ensure the directory exists
28+
mkdir -p "$TARGET_DIR"
29+
30+
# Check write permissions for the target directory
31+
if [ ! -w "$TARGET_DIR" ]; then
32+
echo "Directory $TARGET_DIR is not writable by the current user."
33+
echo "Please adjust directory permissions before re-running this script."
34+
exit 1
35+
fi
36+
37+
echo "Downloading $BINARY_NAME from $URL to $TARGET_DIR..."
38+
if ! curl -fLo "$TARGET_DIR/$BINARY_NAME" "$URL"; then
39+
echo "Failed to download $URL. Please check the URL and try again."
40+
exit 1
41+
fi
42+
43+
# Make the binary executable
44+
chmod u+x "$TARGET_DIR/$BINARY_NAME"
45+
46+
echo "$BINARY_NAME successfully installed in $TARGET_DIR."

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ DRYdock will then create a compose file with only those services, and run it.
1313

1414

1515
## Installation
16-
* `export DRYDOCK_DIR="<dir on path>" && rm -f $DRYDOCK_DIR/drydock && touch $DRYDOCK_DIR/drydock && wget https://github.com/peterHoburg/DRYdock/releases/latest/download/drydock -O $DRYDOCK_DIR/drydock && chmod +x $DRYDOCK_DIR/drydock`
17-
16+
* `curl -sSL https://raw.githubusercontent.com/peterHoburg/DRYdock/refs/heads/main/INSTALL | bash`
1817
## Update
1918
Same as installing
2019

0 commit comments

Comments
 (0)