diff --git a/README.md b/README.md index f663872..cf155fd 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,13 @@ `love-release.sh` -- Bash script to generate Love 2D game releases ### INSTALLATION -Clone and run as root `install.sh`, or edit `install.sh` to choose -locations in user-space. -Close and reopen your terminal to make completion available, or execute : -`. /etc/bash_completion.d/love-release` + git clone https://github.com/MisterDA/love-release.git + cd love-release + + # Install system-wide + sudo ./install.sh + # Install in user space + ./install.sh ### SYNOPSIS `love-release.sh [-adlmw] [-n project_name] [-r release_dir] [-v love_version] [FILES...]` diff --git a/install.sh b/install.sh index d31cf0c..ffd6e0e 100755 --- a/install.sh +++ b/install.sh @@ -1,16 +1,35 @@ #!/usr/bin/env bash -if [ $UID -ne 0 ]; then - echo "This script must be run as root, or you can change the installation directories by editing it." >&2 - exit 1 +if [ $UID -eq 0 ]; then + read -n 1 -p "Do you wish to install love-release system-wide ? [Y/n]: " yn + case $yn in + [Yy]*|"" ) echo;; + * ) echo -e "\nInstallation aborted."; exit;; + esac + + echo "Installing..." + BINARY_DIR=/usr/bin + INSTALL_DIR=/usr/share/love-release + MANPAGE_DIR=/usr/share/man/man1 + COMPLETION_DIR=$(pkg-config --variable=completionsdir bash-completion) +else + read -n 1 -p "Do you wish to install love-release in your user directory ? [Y/n]: " yn + case $yn in + [Yy]*|"" ) echo;; + * ) echo -e "\nInstallation aborted."; exit;; + esac + + echo "Installing..." + BINARY_DIR="$HOME"/bin + INSTALL_DIR="$HOME"/.local/share/love-release + MANPAGE_DIR="$HOME"/.local/share/man/man1 + COMPLETION_DIR="$HOME"/.bash_completion + + echo "Add these lines to your shell rc file:" + echo " export PATH=\"$BINARY_DIR:\$PATH\"" + echo " export MANPATH=\"$MANPAGE_DIR:\"" fi -echo "Installing..." - -BINARY_DIR=/usr/bin -INSTALL_DIR=/usr/share/love-release -MANPAGE_DIR=/usr/share/man/man1 -COMPLETION_DIR=/etc/bash_completion.d SED_ARG=$(echo "$INSTALL_DIR" | sed -e 's/[\/&]/\\&/g') mkdir -p "$BINARY_DIR"