diff --git a/setup/checks.sh b/setup/checks.sh index 7af5dd11..f34489ef 100644 --- a/setup/checks.sh +++ b/setup/checks.sh @@ -13,11 +13,6 @@ # /ᐠ。‸。ᐟ\ # Thanks to Concepts and Training for supporting doil -# get additional helper -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -source ${SCRIPT_DIR}/helper.sh - - function doil_check_doil_artifacts() { if [[ -d /etc/doil || -d /usr/local/lib/doil || -d /usr/local/share/doil || -d /home/$SUDO_USER/.doil || -f /usr/local/bin/doil || -d /var/log/doil ]] then diff --git a/setup/helper.sh b/setup/helper.sh index fa862d14..a3821b2f 100644 --- a/setup/helper.sh +++ b/setup/helper.sh @@ -13,10 +13,6 @@ # /ᐠ。‸。ᐟ\ # Thanks to Concepts and Training for supporting doil -# get the environment -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -source ${SCRIPT_DIR}/env.sh - doil_get_conf() { CONFIG=${1} VALUE="" @@ -101,7 +97,7 @@ function doil_perform_update() { exit fi - for UPDATE_FILE in $(find ./setup/updates/ -type f -name "update-*") + for UPDATE_FILE in $(find ${SCRIPT_DIR}/updates/ -type f -name "update-*") do source ${UPDATE_FILE} for UPDATE in $(set | grep -E '^doil_update.* \(\)' | sed -e 's: .*::') diff --git a/setup/install.sh b/setup/install.sh index 13aab187..fc0e2e21 100755 --- a/setup/install.sh +++ b/setup/install.sh @@ -16,11 +16,14 @@ # get the helper SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -source ${SCRIPT_DIR}/check_requirements.sh source ${SCRIPT_DIR}/checks.sh source ${SCRIPT_DIR}/log.sh source ${SCRIPT_DIR}/system.sh +source ${SCRIPT_DIR}/check_requirements.sh +source ${SCRIPT_DIR}/updates/update.sh source ${SCRIPT_DIR}/helper.sh +source ${SCRIPT_DIR}/env.sh +source ${SCRIPT_DIR}/colors.sh check_requirements diff --git a/setup/log.sh b/setup/log.sh index 9ab16936..6f0c0cb2 100644 --- a/setup/log.sh +++ b/setup/log.sh @@ -13,9 +13,6 @@ # /ᐠ。‸。ᐟ\ # Thanks to Concepts and Training for supporting doil -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -source ${SCRIPT_DIR}/colors.sh - doil_status_send_message() { exec >>/dev/tty 2>&1 echo -n "${1} ..." diff --git a/setup/system.sh b/setup/system.sh index d50e4409..2c06d186 100644 --- a/setup/system.sh +++ b/setup/system.sh @@ -143,7 +143,7 @@ function doil_system_add_user_to_doil_group() { } function doil_system_create_folder() { - GLOBAL_INSTANCES_PATH=$(cat ./setup/conf/doil.conf | grep "global_instances_path" | cut -d '=' -f 2-) + GLOBAL_INSTANCES_PATH=$(cat ${SCRIPT_DIR}/conf/doil.conf | grep "global_instances_path" | cut -d '=' -f 2-) if [ ! -d "${GLOBAL_INSTANCES_PATH}" ] then mkdir -p "${GLOBAL_INSTANCES_PATH}" @@ -183,22 +183,22 @@ function doil_system_create_folder() { } function doil_system_copy_doil() { - cp setup/doil.sh /usr/local/bin/doil - cp -r setup/templates/mail /usr/local/lib/doil/server/ - cp -r setup/templates/proxy /usr/local/lib/doil/server/ - cp -r setup/templates/salt /usr/local/lib/doil/server/ - cp -r setup/templates/php /usr/local/lib/doil/server/ - cp -r setup/templates/minion /usr/local/share/doil/templates - cp -r setup/templates/base /usr/local/share/doil/templates - cp -r app /usr/local/lib/doil - cp -r setup/stack /usr/local/share/doil + cp ${SCRIPT_DIR}/doil.sh /usr/local/bin/doil + cp -r ${SCRIPT_DIR}/templates/mail /usr/local/lib/doil/server/ + cp -r ${SCRIPT_DIR}/templates/proxy /usr/local/lib/doil/server/ + cp -r ${SCRIPT_DIR}/templates/salt /usr/local/lib/doil/server/ + cp -r ${SCRIPT_DIR}/templates/php /usr/local/lib/doil/server/ + cp -r ${SCRIPT_DIR}/templates/minion /usr/local/share/doil/templates + cp -r ${SCRIPT_DIR}/templates/base /usr/local/share/doil/templates + cp -r ${SCRIPT_DIR}/../app /usr/local/lib/doil + cp -r ${SCRIPT_DIR}/stack /usr/local/share/doil return 0 } function doil_system_setup_config() { - cp setup/conf/doil.conf /etc/doil/doil.conf + cp ${SCRIPT_DIR}/conf/doil.conf /etc/doil/doil.conf if [ ! -f /etc/doil/repositories.json ] then @@ -230,7 +230,7 @@ function doil_system_setup_ip() { } function doil_system_setup_access() { - GLOBAL_INSTANCES_PATH=$(cat ./setup/conf/doil.conf | grep "global_instances_path" | cut -d '=' -f 2-) + GLOBAL_INSTANCES_PATH=$(cat ${SCRIPT_DIR}/conf/doil.conf | grep "global_instances_path" | cut -d '=' -f 2-) chown -R root:doil "${GLOBAL_INSTANCES_PATH}" chown -R root:doil /usr/local/lib/doil diff --git a/setup/tests/tests/test-helper.sh b/setup/tests/tests/test-helper.sh index 1cae9db8..a9e9c491 100755 --- a/setup/tests/tests/test-helper.sh +++ b/setup/tests/tests/test-helper.sh @@ -18,6 +18,7 @@ test_doil_check_host() { test_doil_check_docker_version() { source ./setup/checks.sh + source ./setup/helper.sh doil_check_docker_version local CHECK=$? diff --git a/setup/tests/tests/test-system.sh b/setup/tests/tests/test-system.sh index 79388277..5a3aa14a 100755 --- a/setup/tests/tests/test-system.sh +++ b/setup/tests/tests/test-system.sh @@ -45,15 +45,6 @@ test_doil_system_setup_config() { assert_string_contains "0" "${CHECK}" } -test_doil_system_setup_ip() { - source ./setup/system.sh - - doil_system_setup_ip - local CHECK=$? - - assert_string_contains "0" "${CHECK}" -} - test_doil_system_setup_access() { source ./setup/system.sh diff --git a/setup/uninstall.sh b/setup/uninstall.sh index a7db73bc..d20f33f7 100755 --- a/setup/uninstall.sh +++ b/setup/uninstall.sh @@ -19,7 +19,11 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) source ${SCRIPT_DIR}/checks.sh source ${SCRIPT_DIR}/log.sh source ${SCRIPT_DIR}/system.sh +source ${SCRIPT_DIR}/check_requirements.sh +source ${SCRIPT_DIR}/updates/update.sh source ${SCRIPT_DIR}/helper.sh +source ${SCRIPT_DIR}/env.sh +source ${SCRIPT_DIR}/colors.sh function delete() { ALL=$1 diff --git a/setup/update.sh b/setup/update.sh index 3f3eab56..563c5a55 100755 --- a/setup/update.sh +++ b/setup/update.sh @@ -20,6 +20,10 @@ source ${SCRIPT_DIR}/checks.sh source ${SCRIPT_DIR}/log.sh source ${SCRIPT_DIR}/system.sh source ${SCRIPT_DIR}/check_requirements.sh +source ${SCRIPT_DIR}/updates/update.sh +source ${SCRIPT_DIR}/helper.sh +source ${SCRIPT_DIR}/env.sh +source ${SCRIPT_DIR}/colors.sh echo "This update will stop all running doil instances. Please ensure to save relevant files." read -r -p "Do you want to continue update? [y/N] " RESPONSE diff --git a/setup/updates/update-20230713.sh b/setup/updates/update-20230713.sh index 35e1ef97..5e89406f 100644 --- a/setup/updates/update-20230713.sh +++ b/setup/updates/update-20230713.sh @@ -1,8 +1,6 @@ #!/usr/bin/env bash -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) - -source ${SCRIPT_DIR}/update.sh +source ${SCRIPT_DIR}/updates/update.sh doil_update_20230713() { update diff --git a/setup/updates/update-20230731.sh b/setup/updates/update-20230731.sh index 5c1cf17d..a2206956 100644 --- a/setup/updates/update-20230731.sh +++ b/setup/updates/update-20230731.sh @@ -1,14 +1,12 @@ #!/usr/bin/env bash -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) - -source ${SCRIPT_DIR}/update.sh +source ${SCRIPT_DIR}/updates/update.sh doil_update_20230731() { - GLOBAL_INSTANCES_PATH=$(cat ./setup/conf/doil.conf | grep "global_instances_path" | cut -d '=' -f 2-) + GLOBAL_INSTANCES_PATH=$(cat ${SCRIPT_DIR}/conf/doil.conf | grep "global_instances_path" | cut -d '=' -f 2-) cat < /dev/null && pwd ) - -source ${SCRIPT_DIR}/../system.sh -source ${SCRIPT_DIR}/../log.sh - update() { doil_status_send_message_nl "Stopping all services" doil_system_stop_instances