Aligning the different parts with the new directory and file structure.
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
# Get all services on the server
|
||||
SCRIPT_DIR="$(dirname "$0")"
|
||||
|
||||
# //------------------------------------------------------------------------------------------------
|
||||
# // remote paths
|
||||
# // DROPSHELL_DIR
|
||||
# // |-- backups
|
||||
@ -19,17 +20,19 @@ SCRIPT_DIR="$(dirname "$0")"
|
||||
# // |-- services
|
||||
# // |-- service name
|
||||
# // |-- config
|
||||
# // |-- service.env
|
||||
# // |-- service.env (actual service config)
|
||||
# // |-- .template_info.env
|
||||
# // |-- template
|
||||
# // |-- _default.env
|
||||
# // |-- (script files)
|
||||
# // |-- config
|
||||
# // |-- service.env
|
||||
# // |-- service.env (default service config)
|
||||
# // |-- .template_info.env
|
||||
# // |-- (other config files for specific server&service)
|
||||
|
||||
# Get all services on the server
|
||||
SERVICES_PATH=$(realpath "${SCRIPT_DIR}/../services/")
|
||||
|
||||
|
||||
CURRENT_OUTPUT=""
|
||||
CURRENT_EXIT_CODE=0
|
||||
|
||||
@ -40,6 +43,15 @@ load_dotenv(){
|
||||
fi
|
||||
}
|
||||
|
||||
_check_required_env_vars_allservicesstatus() {
|
||||
local required_vars=("$@")
|
||||
for var in "${required_vars[@]}"; do
|
||||
if [ -z "${!var}" ]; then
|
||||
_die "Required environment variable $var is not set"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function run_command() {
|
||||
local service_path=$1
|
||||
local command=$2
|
||||
@ -55,13 +67,23 @@ function run_command() {
|
||||
set -a
|
||||
load_dotenv "${service_path}/template/_default.env"
|
||||
load_dotenv "${service_path}/config/service.env"
|
||||
load_dotenv "${service_path}/config/.template_info.env"
|
||||
set +a
|
||||
|
||||
# all_env_vars["CONFIG_PATH"] = remotepath::service_config(server_name,service_name);
|
||||
# all_env_vars["SERVER"] = server_name;
|
||||
# all_env_vars["SERVICE"] = service_name;
|
||||
# all_env_vars["AGENT_PATH"] = remotepath::agent(server_name);
|
||||
# all_env_vars["HOST_NAME"] = server_info.ssh_host;
|
||||
# update the main variables.
|
||||
export CONFIG_PATH="${service_path}/config"
|
||||
# SERVER is correct
|
||||
# SERVER is already set
|
||||
export SERVICE="${SERVICE_NAME}"
|
||||
|
||||
export AGENT_PATH="${SCRIPT_DIR}"
|
||||
# HOST_NAME is already set
|
||||
|
||||
_check_required_env_vars_allservicesstatus "CONFIG_PATH" "SERVER" "SERVICE" "AGENT_PATH" "HOST_NAME" "TEMPLATE"
|
||||
|
||||
if [ "$capture_output" = "true" ]; then
|
||||
# Capture and return output
|
||||
bash "${service_path}/template/${command}.sh" 2>&1
|
||||
|
Reference in New Issue
Block a user