Skip to content

Commit

Permalink
Merge pull request #37 from peterHoburg/33-add-installupdate-script
Browse files Browse the repository at this point in the history
  • Loading branch information
peterHoburg authored Dec 7, 2024
2 parents 3d7d4f0 + 272b5c3 commit 10121ec
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
46 changes: 46 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
set -euo pipefail

URL="https://github.com/peterHoburg/DRYdock/releases/latest/download/drydock"

BINARY_NAME="drydock"
# Check if the binary is already installed in the PATH
INSTALL_PATH=$(command -v "$BINARY_NAME" 2>/dev/null || true)

if [ -n "$INSTALL_PATH" ]; then
# Binary already exists, replace it where it is
TARGET_DIR=$(dirname "$INSTALL_PATH")
echo "Previous install found $TARGET_DIR. Replacing..."
else
# Binary not found, check if $HOME/bin or $HOME/.local/bin is in the PATH
if [[ ":$PATH:" == *":$HOME/bin:"* ]]; then
TARGET_DIR="$HOME/bin"
elif [[ ":$PATH:" == *":$HOME/.local/bin:"* ]]; then
TARGET_DIR="$HOME/.local/bin"
else
echo "Error: Neither \$HOME/bin nor \$HOME/.local/bin is in your PATH."
echo "Please add one of them to PATH and re-run this script."
exit 1
fi
fi

# Ensure the directory exists
mkdir -p "$TARGET_DIR"

# Check write permissions for the target directory
if [ ! -w "$TARGET_DIR" ]; then
echo "Directory $TARGET_DIR is not writable by the current user."
echo "Please adjust directory permissions before re-running this script."
exit 1
fi

echo "Downloading $BINARY_NAME from $URL to $TARGET_DIR..."
if ! curl -fLo "$TARGET_DIR/$BINARY_NAME" "$URL"; then
echo "Failed to download $URL. Please check the URL and try again."
exit 1
fi

# Make the binary executable
chmod u+x "$TARGET_DIR/$BINARY_NAME"

echo "$BINARY_NAME successfully installed in $TARGET_DIR."
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ DRYdock will then create a compose file with only those services, and run it.


## Installation
* `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`

* `curl -sSL https://raw.githubusercontent.com/peterHoburg/DRYdock/refs/heads/main/INSTALL | bash`
## Update
Same as installing

Expand Down

0 comments on commit 10121ec

Please sign in to comment.