Tidy
This commit is contained in:
parent
d9a082bc3f
commit
6d400e3751
@ -4,11 +4,11 @@
|
||||
|
||||
Automated system-wide installation:
|
||||
```
|
||||
curl -fsSL https://gitea.jde.nz/public/dehydrate/releases/download/latest/install.sh | bash
|
||||
curl -fsSL https://gitea.jde.nz/public/dehydrate/releases/download/latest/install.sh | sudo bash
|
||||
```
|
||||
To download just the dehydrate executable:
|
||||
```
|
||||
curl -fsSL -o dehydrate https://gitea.jde.nz/public/dehydrate/releases/download/latest/dehydrate.amd64 && chmod a+x bb64
|
||||
curl -fsSL -o dehydrate https://gitea.jde.nz/public/dehydrate/releases/download/latest/dehydrate.amd64 && chmod a+x dehydrate
|
||||
```
|
||||
|
||||
## How it Works
|
||||
|
36
install.sh
36
install.sh
@ -3,24 +3,23 @@ set -e
|
||||
|
||||
PROJECT="dehydrate"
|
||||
|
||||
# RUN AS ROOT
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 0. see if we were passed a folder to install to
|
||||
# -----------------------------------------------------------------------------
|
||||
INSTALL_DIR="$1"
|
||||
if [[ -z "$INSTALL_DIR" ]]; then
|
||||
INSTALL_DIR="/usr/local/bin"
|
||||
else
|
||||
echo "Installing $PROJECT to $INSTALL_DIR"
|
||||
if [[ ! -d "$INSTALL_DIR" ]]; then
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
fi
|
||||
fi
|
||||
|
||||
# 0. see if we were passed a user to chown to
|
||||
# -----------------------------------------------------------------------------
|
||||
CHOWN_USER="$2"
|
||||
if [[ -z "$CHOWN_USER" ]]; then
|
||||
CHOWN_USER=$(id -u)
|
||||
fi
|
||||
echo "Installing $PROJECT to $INSTALL_DIR"
|
||||
|
||||
# 1. Determine architecture
|
||||
# -----------------------------------------------------------------------------
|
||||
@ -35,27 +34,18 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 3. Download the appropriate binary to a temp directory
|
||||
# 3. Download the appropriate binary
|
||||
# -----------------------------------------------------------------------------
|
||||
TMPDIR=$(mktemp -d)
|
||||
trap 'rm -rf "$TMPDIR"' EXIT
|
||||
URL="https://gitea.jde.nz/public/$PROJECT/releases/download/latest/$BIN"
|
||||
echo "Downloading $BIN from $URL..."
|
||||
|
||||
curl -fsSL -o "$TMPDIR/$PROJECT" "$URL"
|
||||
URL="https://gitea.jde.nz/public/$PROJECT/releases/download/latest/$BIN"
|
||||
echo "Downloading $BIN from $URL to $TMPDIR..."
|
||||
|
||||
curl -fsSL -o "$INSTALL_DIR/$PROJECT" "$URL"
|
||||
|
||||
# 4. Make it executable
|
||||
# -----------------------------------------------------------------------------
|
||||
chmod +x "$TMPDIR/$PROJECT"
|
||||
|
||||
# 5. Move to /usr/local/bin
|
||||
# -----------------------------------------------------------------------------
|
||||
docker run --rm -v "$TMPDIR:/tmp" -v "$INSTALL_DIR:/target" alpine sh -c "cp /tmp/$PROJECT /target/$PROJECT; chown $CHOWN_USER /target/$PROJECT"
|
||||
rm "$TMPDIR/$PROJECT"
|
||||
chmod +x "$INSTALL_DIR/$PROJECT"
|
||||
|
||||
# 6. Print success message
|
||||
# -----------------------------------------------------------------------------
|
||||
echo "$PROJECT installed successfully to $INSTALL_DIR/$PROJECT (arch $ARCH)"
|
||||
echo " "
|
||||
echo "Update $PROJECT in future with:"
|
||||
echo " $PROJECT -u"
|
||||
|
Loading…
x
Reference in New Issue
Block a user