65 lines
2.1 KiB
Bash
65 lines
2.1 KiB
Bash
#!/bin/bash
|
|
|
|
# Dropshell Run
|
|
|
|
# Usage:
|
|
|
|
# ds_run.sh SERVER SERVICE COMMAND [param1] [param2] ...
|
|
|
|
# //------------------------------------------------------------------------------------------------
|
|
# // remote paths
|
|
# // DROPSHELL_DIR
|
|
# // |-- server.json
|
|
# // |-- backups
|
|
# // |-- temp_files
|
|
# // |-- agent
|
|
# // | |-- bb64
|
|
# // | |-- (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)
|
|
|
|
# read SERVER, SERVICE from the command line args
|
|
export SERVER=TODO
|
|
export SERVICE=TODO
|
|
export DSCOMMAND=TODO
|
|
export DOCKER_CLI_HINTS=false
|
|
|
|
# we are in the agent directory.
|
|
export AGENT_PATH="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)"
|
|
export DROPSHELL_DIR=TODO
|
|
export CONFIG_PATH="${DROPSHELL_DIR}/services/${SERVICE}/config"
|
|
|
|
source "${AGENT_PATH}/commmon.sh"
|
|
|
|
[ -d ${CONFIG_PATH} ] || _die "Service ${SERVICE} does not exist on the server."
|
|
|
|
export TEMPLATE_INFO_ENV="${DROPSHELL_DIR}/services/${SERVICE}/template/template_info.env"
|
|
[ -f ${TEMPLATE_INFO_ENV} ] || _die "Couldn't find template_info.env at ${TEMPLATE_INFO_ENV}"
|
|
|
|
#read in the TEMPLATE_INFO_ENV, exporting all variables
|
|
source "${TEMPLATE_INFO_ENV}"
|
|
|
|
export SERVICE_ENV="${DROPSHELL_DIR}/services/${SERVICE}/config/service.env"
|
|
[ -f ${SERVICE_ENV} ] || _die "Couldn't find service.env at ${SERVICE_ENV}"
|
|
|
|
# read in the SERVICE_ENV, exporting all varialbes
|
|
source "${SERVICE_ENV}"
|
|
|
|
|
|
## Run the command
|
|
|
|
export COMMAND_TO_RUN="${DROPSHELL_DIR}/services/${SERVICE}/template/${DSCOMMAND}"
|
|
[ -f "${COMMAND_TO_RUN}" ] || COMMAND_TO_RUN="${COMMAND_TO_RUN}.sh"
|
|
[ -f "${COMMAND_TO_RUN}" ] || _die "Couldn't find the command to run: ${COMMAND_TO_RUN}"
|
|
|
|
# ensure all variables are in the environment of the command being run!!
|
|
${COMMAND_TO_RUN}
|