Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

master setup: fix source handling #354

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions setup/checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions setup/helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down Expand Up @@ -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: .*::')
Expand Down
5 changes: 4 additions & 1 deletion setup/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions setup/log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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} ..."
Expand Down
24 changes: 12 additions & 12 deletions setup/system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions setup/tests/tests/test-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=$?
Expand Down
9 changes: 0 additions & 9 deletions setup/tests/tests/test-system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions setup/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions setup/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions setup/updates/update-20230713.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 3 additions & 5 deletions setup/updates/update-20230731.sh
Original file line number Diff line number Diff line change
@@ -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 <<Message
Before running this update, you should make sure to customize the ${SCRIPT_DIR}/setup/conf/doil.conf file according to
Before running this update, you should make sure to customize the ${SCRIPT_DIR}/conf/doil.conf file according to
your needs. For more information, please read the README (https://github.com/conceptsandtraining/doil/blob/master/README.md).
In addition, global instances are always stored in the same place with this update. This place can also be set in the Doil Config.
By default, they are stored under /srv/instances. Current global instances are automatically moved to the directory specified
Expand Down
5 changes: 0 additions & 5 deletions setup/updates/update.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#!/usr/bin/env bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /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
Expand Down