From e48198af59869fcad2d43bc353d8e362c28010a5 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 17 May 2017 12:57:25 +0200 Subject: [PATCH] bootstrap: - add options to overwrite installation root and config file --- install_pmodules.sh | 48 +++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/install_pmodules.sh b/install_pmodules.sh index 61d7e50..33d4d7d 100755 --- a/install_pmodules.sh +++ b/install_pmodules.sh @@ -1,6 +1,7 @@ #!/bin/bash declare BOOTSTRAP_DIR=$(dirname "$0") +unset PMODULES_ROOT unset PMODULES_HOME unset PMODULES_VERSION @@ -9,30 +10,43 @@ source "${BOOTSTRAP_DIR}/Pmodules/libstd.bash" declare -r BOOTSTRAP_DIR=$(std::get_abspath "${BOOTSTRAP_DIR}") declare -r SRC_DIR="${BOOTSTRAP_DIR}/Pmodules" -std::read_versions "${BOOTSTRAP_DIR}/config/versions.conf" +declare config_file="${BOOTSTRAP_DIR}/config/environment.bash" + +declare opt_force='no' while (( $# > 0 )); do case $1 in - --install-root ) - PMODULES_ROOT="$2" - shift 1 - ;; - --install-root=* ) - PMODULES_ROOT="${1#*=}" - ;; - -* ) - echo "Unknown option: $1" 1>&2 - exit 1 - ;; - * ) - echo "Invalid argument: $1" 1>&2 - exit 1 - ;; + --config ) + config_file="$2" + shift 1 + ;; + --config=* ) + config_file="${1#*=}" + ;; + --install-root ) + PMODULES_ROOT="$2" + shift 1 + ;; + --install-root=* ) + PMODULES_ROOT="${1#*=}" + ;; + -f | --force ) + opt_force='yes' + ;; + -* ) + echo "Unknown option: $1" 1>&2 + exit 1 + ;; + * ) + echo "Invalid argument: $1" 1>&2 + exit 1 + ;; esac shift 1 done -source "${BOOTSTRAP_DIR}/config/environment.bash" +std::read_versions "${BOOTSTRAP_DIR}/config/versions.conf" +source "${config_file}" if [[ ! -d "${PMODULES_ROOT}" ]]; then read -p "The requested root directory does not exist. Create it? [y|N] " -n 1 ans