diff --git a/bash/main.sh b/bash/main.sh index 90ea527..c89870e 100644 --- a/bash/main.sh +++ b/bash/main.sh @@ -1,25 +1,32 @@ #! /usr/bin/env bash -MAIN_FILE="$(realpath "${BASH_SOURCE[0]}")" -MAIN_ROOT="$(dirname "${MAIN_FILE}")" + +MAIN_BASH_FILE="$(realpath "${BASH_SOURCE[0]}")" + +MAIN_BASH_ROOT="$(dirname "${MAIN_BASH_FILE}")" function link_bashrc { local file='/etc/bash.bashrc' rm --force "${file}" - ln --symbolic "${MAIN_FILE}" "${file}" + ln --symbolic "${MAIN_BASH_FILE}" "${file}" } # import modules function main_import_modules { +local root="${1}" +if [ -d "${root}" ] ; then local IFS=$'\n' - local modules=($(find "${MAIN_ROOT}" -type 'f' -name '*.sh')) + local modules=($(find "${root}" -type 'f' -name '*.sh')) local module for module in "${modules[@]}" ; do - if [ "${module}" != "${MAIN_FILE}" ] ; then + if [ "${module}" != "${MAIN_BASH_FILE}" ] ; then source "${module}" fi done log_trace "${modules[@]}" +else + log_fatal "No directory: ${root}" +fi } # import modules -main_import_modules +main_import_modules "${MAIN_BASH_ROOT}" diff --git a/bash/ovh-rescue.sh b/bash/ovh-rescue.sh index ecc2115..295a95f 100644 --- a/bash/ovh-rescue.sh +++ b/bash/ovh-rescue.sh @@ -91,7 +91,7 @@ if [ "${host}" ] ; then -o 'StrictHostKeyChecking=accept-new' \ "${user_host}" # upload root - rsync --delete --recursive "${MAIN_ROOT}/" "${user_host}:/etc/bash/" + rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/" # call setup # TODO variable ssh "${user_host}" -- "source '/etc/bash/main.sh' ; ovh-rescue-setup"