diff --git a/templates/example/README.txt b/templates/example/README.txt index c2f052d..03d2363 100644 --- a/templates/example/README.txt +++ b/templates/example/README.txt @@ -1,12 +1,13 @@ DropShell Template Example Shell scripts defined in this folder are run as DropShell commands on the remote server (not locally!). -All scripts are passed the server-specific service environment (SSSE) file as an argument. +All scripts are passed the directory containing the server-specific service environment (SSSE) as an argument +(the environment file, along with any other server and service-specific files, is then in $1/service.env) -The default SSSE file used when a new service is created is in example/service.env. This must exist, +The default SSSE file included when a new service is created is in example/service.env. This must exist, and must at minimum contain the TEMPLATE= variable. -The backups script gets a second argument, which is the backup file to create (a single tgz file). +The optional backups script gets a second argument, which is the backup file to create (a single tgz file). Mandatory scripts are: - install.sh diff --git a/templates/example/_common.sh b/templates/example/_common.sh index 8dfab27..b1e7e6e 100755 --- a/templates/example/_common.sh +++ b/templates/example/_common.sh @@ -27,7 +27,7 @@ load_env() { source "$script_dir/_basic.env" set +a else - echo "Warning: basic.env file not found at $script_dir/_basic.env. Broken template?" + echo "Warning: _basic.env file not found at $script_dir/_basic.env. Broken template?" return 1 fi @@ -35,23 +35,18 @@ load_env() { if [ -z "$1" ]; then echo "Usage: $0 [path_to_env_file]" return 1 - else - # If path is relative, make it absolute using script directory as base - if [[ "$1" != /* ]]; then - env_file="$script_dir/$1" - else - env_file="$1" - fi fi - - if [ -f "$env_file" ]; then - set -a - source "$env_file" - set +a - else - echo "Warning: .env file not found at $env_file" + + env_file="$1/service.env" + + if [ ! -f "$env_file" ]; then + echo "Warning: service.env file not found in $1" return 1 fi + + set -a + source "$env_file" + set +a } grey_start() { diff --git a/templates/watchtower/_common.sh b/templates/watchtower/_common.sh index 8dfab27..b1e7e6e 100755 --- a/templates/watchtower/_common.sh +++ b/templates/watchtower/_common.sh @@ -27,7 +27,7 @@ load_env() { source "$script_dir/_basic.env" set +a else - echo "Warning: basic.env file not found at $script_dir/_basic.env. Broken template?" + echo "Warning: _basic.env file not found at $script_dir/_basic.env. Broken template?" return 1 fi @@ -35,23 +35,18 @@ load_env() { if [ -z "$1" ]; then echo "Usage: $0 [path_to_env_file]" return 1 - else - # If path is relative, make it absolute using script directory as base - if [[ "$1" != /* ]]; then - env_file="$script_dir/$1" - else - env_file="$1" - fi fi - - if [ -f "$env_file" ]; then - set -a - source "$env_file" - set +a - else - echo "Warning: .env file not found at $env_file" + + env_file="$1/service.env" + + if [ ! -f "$env_file" ]; then + echo "Warning: service.env file not found in $1" return 1 fi + + set -a + source "$env_file" + set +a } grey_start() { diff --git a/templates/watchtower/example/config.json b/templates/watchtower/example/config.json new file mode 100644 index 0000000..a5270d1 --- /dev/null +++ b/templates/watchtower/example/config.json @@ -0,0 +1,5 @@ +{ + "auths": { + + } +} diff --git a/templates/watchtower/start.sh b/templates/watchtower/start.sh index f456de1..ac7b67d 100755 --- a/templates/watchtower/start.sh +++ b/templates/watchtower/start.sh @@ -1,6 +1,8 @@ #!/bin/bash source "$(dirname "$0")/_common.sh" -load_env "$1" || die "Failed to load environment variables" + +SERVICE_CONFIG_DIR="$1" +load_env "$SERVICE_CONFIG_DIR" || die "Failed to load environment variables" # Required environment variables check_required_env_vars "CONTAINER_NAME" "INTERVAL" @@ -9,6 +11,7 @@ DOCKER_RUN_CMD="docker run -d \ --restart unless-stopped \ --name ${CONTAINER_NAME} \ -v /var/run/docker.sock:/var/run/docker.sock \ + -v ${SERVICE_CONFIG_DIR}/config.json:/config.json ${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG} \ --interval ${INTERVAL}"