From c35fabe6e7a143dc7754c6cdaec536d5551ef144 Mon Sep 17 00:00:00 2001 From: John Date: Sun, 27 Apr 2025 13:25:39 +1200 Subject: [PATCH] Update nginx-example --- templates/example/README.txt | 5 +++-- templates/example/_default.env | 3 --- templates/example/backup.sh | 3 --- templates/example/logs.sh | 1 - templates/example/ports.sh | 1 - templates/example/start.sh | 14 +++----------- templates/example/status.sh | 3 --- templates/example/stop.sh | 3 --- templates/example/uninstall.sh | 3 --- 9 files changed, 6 insertions(+), 30 deletions(-) diff --git a/templates/example/README.txt b/templates/example/README.txt index 03d2363..3d4ae2b 100644 --- a/templates/example/README.txt +++ b/templates/example/README.txt @@ -12,11 +12,12 @@ The optional backups script gets a second argument, which is the backup file to Mandatory scripts are: - install.sh - uninstall.sh -- start.sh -- stop.sh Optional standard scripts are: +- start.sh +- stop.sh - backup.sh +- restore.sh - status.sh - ports.sh - logs.sh diff --git a/templates/example/_default.env b/templates/example/_default.env index adf19cd..a5e0c2d 100644 --- a/templates/example/_default.env +++ b/templates/example/_default.env @@ -1,8 +1,5 @@ # Service settings specific to this server -# Application settings -CONTAINER_PORT=8181 - # Image settings IMAGE_REGISTRY="docker.io" IMAGE_REPO="nginx" diff --git a/templates/example/backup.sh b/templates/example/backup.sh index ccceb35..2080983 100644 --- a/templates/example/backup.sh +++ b/templates/example/backup.sh @@ -9,9 +9,6 @@ # If the backup file already exists, the script should exit with a message. source "$(dirname "$0")/_common.sh" -load_env "$1" || die "Failed to load environment variables" - -# Required environment variables check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER" # Get backup file path from second argument diff --git a/templates/example/logs.sh b/templates/example/logs.sh index 09bad2c..209b57b 100644 --- a/templates/example/logs.sh +++ b/templates/example/logs.sh @@ -6,7 +6,6 @@ # It is called with the path to the server specific env file as an argument. source "$(dirname "$0")/_common.sh" -load_env "$1" || die "Failed to load environment variables" # Required environment variables check_required_env_vars "CONTAINER_NAME" diff --git a/templates/example/ports.sh b/templates/example/ports.sh index 6c840a2..e88f668 100644 --- a/templates/example/ports.sh +++ b/templates/example/ports.sh @@ -6,7 +6,6 @@ # It is called with the path to the server specific env file as an argument. source "$(dirname "$0")/_common.sh" -load_env "$1" || die "Failed to load environment variables" # Required environment variables # check_required_env_vars "HOST_PORT" diff --git a/templates/example/start.sh b/templates/example/start.sh index 2e61071..6f26de6 100755 --- a/templates/example/start.sh +++ b/templates/example/start.sh @@ -6,23 +6,15 @@ # It is called with the path to the server specific env file as an argument. source "$(dirname "$0")/_common.sh" -load_env "$1" || die "Failed to load environment variables" - -# Required environment variables check_required_env_vars "CONTAINER_NAME" "HOST_PORT" "CONTAINER_PORT" "LOCAL_DATA_FOLDER" -if [ -d "${LOCAL_DATA_FOLDER}" ]; then - echo "Local data folder ${LOCAL_DATA_FOLDER} exists, skipping data folder creation" -else - echo "Local data folder ${LOCAL_DATA_FOLDER} does not exist, creating..." - mkdir -p "${LOCAL_DATA_FOLDER}" -fi +[ -d "${LOCAL_DATA_FOLDER}" ] || die "Local data folder ${LOCAL_DATA_FOLDER} does not exist." DOCKER_RUN_CMD="docker run -d \ --restart unless-stopped \ --name ${CONTAINER_NAME} \ - -p ${HOST_PORT}:${CONTAINER_PORT} \ - -v ${LOCAL_DATA_FOLDER}:/skdata \ + -p ${HOST_PORT}:80 \ + -v ${LOCAL_DATA_FOLDER}:/usr/share/nginx/html:ro \ ${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}" diff --git a/templates/example/status.sh b/templates/example/status.sh index 82cc387..990d9a7 100644 --- a/templates/example/status.sh +++ b/templates/example/status.sh @@ -8,9 +8,6 @@ # This is an example of a status script that checks if the service is running. source "$(dirname "$0")/_common.sh" -load_env "$1" || die "Failed to load environment variables" - -# Required environment variables check_required_env_vars "CONTAINER_NAME" # check if the service is running diff --git a/templates/example/stop.sh b/templates/example/stop.sh index 68030f6..e1cc8e9 100755 --- a/templates/example/stop.sh +++ b/templates/example/stop.sh @@ -6,9 +6,6 @@ # It is called with the path to the server specific env file as an argument. source "$(dirname "$0")/_common.sh" -load_env "$1" || die "Failed to load environment variables" - -# Required environment variables check_required_env_vars "CONTAINER_NAME" _stop_container $CONTAINER_NAME || die "Failed to stop container ${CONTAINER_NAME}" diff --git a/templates/example/uninstall.sh b/templates/example/uninstall.sh index 4031c68..3477b6f 100644 --- a/templates/example/uninstall.sh +++ b/templates/example/uninstall.sh @@ -6,9 +6,6 @@ # It is called with the path to the server specific env file as an argument. source "$(dirname "$0")/_common.sh" -load_env "$1" || die "Failed to load environment variables" - -# Required environment variables check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" _remove_container $CONTAINER_NAME || die "Failed to remove container ${CONTAINER_NAME}"