main_bash
This commit is contained in:
parent
04ccbd37c4
commit
4c7ad425b2
2 changed files with 14 additions and 7 deletions
19
bash/main.sh
19
bash/main.sh
|
@ -1,25 +1,32 @@
|
||||||
#! /usr/bin/env bash
|
#! /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 {
|
function link_bashrc {
|
||||||
local file='/etc/bash.bashrc'
|
local file='/etc/bash.bashrc'
|
||||||
rm --force "${file}"
|
rm --force "${file}"
|
||||||
ln --symbolic "${MAIN_FILE}" "${file}"
|
ln --symbolic "${MAIN_BASH_FILE}" "${file}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# import modules
|
# import modules
|
||||||
function main_import_modules {
|
function main_import_modules {
|
||||||
|
local root="${1}"
|
||||||
|
if [ -d "${root}" ] ; then
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
local modules=($(find "${MAIN_ROOT}" -type 'f' -name '*.sh'))
|
local modules=($(find "${root}" -type 'f' -name '*.sh'))
|
||||||
local module
|
local module
|
||||||
for module in "${modules[@]}" ; do
|
for module in "${modules[@]}" ; do
|
||||||
if [ "${module}" != "${MAIN_FILE}" ] ; then
|
if [ "${module}" != "${MAIN_BASH_FILE}" ] ; then
|
||||||
source "${module}"
|
source "${module}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
log_trace "${modules[@]}"
|
log_trace "${modules[@]}"
|
||||||
|
else
|
||||||
|
log_fatal "No directory: ${root}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# import modules
|
# import modules
|
||||||
main_import_modules
|
main_import_modules "${MAIN_BASH_ROOT}"
|
||||||
|
|
|
@ -91,7 +91,7 @@ if [ "${host}" ] ; then
|
||||||
-o 'StrictHostKeyChecking=accept-new' \
|
-o 'StrictHostKeyChecking=accept-new' \
|
||||||
"${user_host}"
|
"${user_host}"
|
||||||
# upload root
|
# upload root
|
||||||
rsync --delete --recursive "${MAIN_ROOT}/" "${user_host}:/etc/bash/"
|
rsync --delete --recursive "${MAIN_BASH_ROOT}/" "${user_host}:/etc/bash/"
|
||||||
# call setup
|
# call setup
|
||||||
# TODO variable
|
# TODO variable
|
||||||
ssh "${user_host}" -- "source '/etc/bash/main.sh' ; ovh-rescue-setup"
|
ssh "${user_host}" -- "source '/etc/bash/main.sh' ; ovh-rescue-setup"
|
||||||
|
|
Loading…
Reference in a new issue