Tidying
This commit is contained in:
@@ -3,21 +3,28 @@ set -euo pipefail
|
||||
|
||||
# Dropshell Run - Execute a service command on the remote server
|
||||
#
|
||||
# Usage: ds_run.sh SERVER SERVICE COMMAND [args...]
|
||||
# Usage: ds_run.sh SERVICE COMMAND [args...]
|
||||
#
|
||||
# Remote directory structure:
|
||||
# DROPSHELL_DIR/
|
||||
# ├── agent/
|
||||
# │ ├── ds_run.sh (this script)
|
||||
# │ └── common.sh
|
||||
# └── services/<service>/
|
||||
# ├── config/
|
||||
# │ └── service.env
|
||||
# └── template/
|
||||
# ├── template_info.env
|
||||
# ├── install.sh, uninstall.sh, etc.
|
||||
# └── config/
|
||||
# └── service.env (template defaults)
|
||||
# // |-- server_info.env
|
||||
# // |-- server.json
|
||||
# // |-- backups
|
||||
# // |-- temp_files
|
||||
# // |-- agent
|
||||
# // | |-- bb64
|
||||
# // | |-- ds_run.sh (this script)
|
||||
# // | |-- common.sh
|
||||
# // | |-- (other agent files)
|
||||
# // |-- services
|
||||
# // |-- service name
|
||||
# // |-- config
|
||||
# // |-- service.env (actual service config)
|
||||
# // |-- template
|
||||
# // |-- (script files)
|
||||
# // |-- template_info.env
|
||||
# // |-- config
|
||||
# // |-- service.env (default service config)
|
||||
# // |-- (other template/example config files)
|
||||
|
||||
# -- Determine paths --
|
||||
SCRIPT_PATH="$(readlink -f "${BASH_SOURCE[0]}")"
|
||||
@@ -37,10 +44,9 @@ if [[ $# -lt 3 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export SERVER="$1"
|
||||
export SERVICE="$2"
|
||||
export DSCOMMAND="$3"
|
||||
shift 3
|
||||
export SERVICE="$1"
|
||||
export DSCOMMAND="$2"
|
||||
shift 2
|
||||
|
||||
# Suppress Docker CLI hints
|
||||
export DOCKER_CLI_HINTS=false
|
||||
@@ -50,6 +56,7 @@ export CONFIG_PATH="${DROPSHELL_DIR}/services/${SERVICE}/config"
|
||||
export TEMPLATE_PATH="${DROPSHELL_DIR}/services/${SERVICE}/template"
|
||||
|
||||
# -- Validate service exists --
|
||||
[[ -f "${DROPSHELL_DIR}/server_info.env" ]] || _die "Missing ${DROPSHELL_DIR}/server_info.env"
|
||||
[[ -d "${CONFIG_PATH}" ]] || _die "Service '${SERVICE}' does not exist on server (missing ${CONFIG_PATH})"
|
||||
|
||||
# -- Load template info (template defaults, loaded first) --
|
||||
@@ -65,6 +72,7 @@ export SERVICE_ENV="${CONFIG_PATH}/service.env"
|
||||
|
||||
# -- Source env files with auto-export (set -a exports all assigned variables) --
|
||||
set -a
|
||||
source "${DROPSHELL_DIR}/server_info.env"
|
||||
source "${TEMPLATE_INFO_ENV}"
|
||||
source "${SERVICE_ENV}"
|
||||
set +a
|
||||
|
||||
Reference in New Issue
Block a user