commit 26f47d8df0d9939ffb5f379ade882446faf63c94 parent 09f85ce18de67922f2c0a7ed9cbb695e4411dc7a Author: finwo <finwo@pm.me> Date: Mon, 2 Dec 2019 13:20:51 +0100 made install path configurable Diffstat:
| M | install.sh | | | 32 | +++++++++++++++++++++++--------- |
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/install.sh b/install.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# Verify root privileges -if [[ $EUID -ne 0 ]]; then - echo "This script must be run as root" >&2 - exit 1 -fi +# # Verify root privileges +# if [[ $EUID -ne 0 ]]; then +# echo "This script must be run as root" >&2 +# exit 1 +# fi # Print banner cat <<EOF @@ -15,13 +15,27 @@ cat <<EOF EOF +# Default settings +PREFIX=/usr/local + +# Parse arguments +while [ "$#" -gt 0 ]; do + case "$1" in + --prefix) + shift + PREFIX="$1" + ;; + esac + shift +done + # Install repo binary function bin { [ -f "./$1" ] && { echo "Copying $1" - cp "./$1" "/usr/local/bin/$1" - } || curl -L# "https://raw.githubusercontent.com/cdeps/dep/master/dist/$1" > "/usr/local/bin/$1" - chmod +x "/usr/local/bin/$1" + cp "./$1" "$PREFIX/bin/$1" + } || curl -L# "https://raw.githubusercontent.com/cdeps/dep/master/dist/$1" > "$PREFIX/bin/$1" + chmod +x "$PREFIX/bin/$1" } # Ensure our dependencies @@ -30,7 +44,7 @@ command -v curl &>/dev/null || { } # Default install directory -mkdir -p /usr/local/bin +mkdir -p "$PREFIX/bin" # Install our binaries bin dep