This commit is contained in:
Your Name 2025-05-03 23:18:52 +12:00
parent 2fe7d4c3d9
commit 3d9b1fa6d2
48 changed files with 59 additions and 199 deletions

2
replace_die.sh Normal file
View File

@ -0,0 +1,2 @@
#!/bin/bash
echo "Replacing die with _die in all template scripts..."

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "CONTAINER_NAME" "DATA_VOLUME" "CONFIG_VOLUME" "CONFIG_PATH" check_required_env_vars
_stop_container "$CONTAINER_NAME" _stop_container "$CONTAINER_NAME"

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "DATA_VOLUME" "CONFIG_VOLUME" check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "DATA_VOLUME" "CONFIG_VOLUME" "CONFIG_PATH"
if ! autocreate volume=$DATA_VOLUME volume=$CONFIG_VOLUME; then if ! autocreate volume=$DATA_VOLUME volume=$CONFIG_VOLUME; then
die "Failed to autocreate volumes and paths" die "Failed to autocreate volumes and paths"

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "CONTAINER_NAME" check_required_env_vars
# Main script. # Main script.
echo "Container ${CONTAINER_NAME} logs:" echo "Container ${CONTAINER_NAME} logs:"

View File

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars
# NUKE SCRIPT # NUKE SCRIPT
# This is run after the uninstall.sh script to delete all data. # This is run after the uninstall.sh script to delete all data.
# dropshell handles the configuration files, so we just need to remove # dropshell handles the configuration files, so we just need to remove
# any docker volumes and any custom local data folders. # any docker volumes and any custom local data folders.
check_required_env_vars "CONTAINER_NAME" "DATA_VOLUME" "CONFIG_VOLUME" "CONFIG_PATH"
if ! autonuke volume=$DATA_VOLUME volume=$CONFIG_VOLUME; then if ! autonuke volume=$DATA_VOLUME volume=$CONFIG_VOLUME; then
die "Failed to nuke" die "Failed to nuke"

View File

@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars
# RESTORE SCRIPT # RESTORE SCRIPT
check_required_env_vars "DATA_VOLUME" "CONFIG_VOLUME" "CONFIG_PATH"
# uninstall container before restore # uninstall container before restore
bash ./uninstall.sh || die "Failed to uninstall service before restore" bash ./uninstall.sh || die "Failed to uninstall service before restore"

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars
# START SCRIPT # START SCRIPT
# The start script is required for all templates. # The start script is required for all templates.
# It is used to start the service on the server. # It is used to start the service on the server.
check_required_env_vars "CONTAINER_NAME" "DATA_VOLUME" "CONFIG_VOLUME"
DOCKER_RUN_CMD="docker run -d \ DOCKER_RUN_CMD="docker run -d \

View File

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars
# STATUS SCRIPT # STATUS SCRIPT
# The status script is OPTIONAL. # The status script is OPTIONAL.
# It is used to return the status of the service (0 is healthy, 1 is unhealthy). # It is used to return the status of the service (0 is healthy, 1 is unhealthy).
# This is an example of a status script that checks if the service is running. # This is an example of a status script that checks if the service is running.
check_required_env_vars "CONTAINER_NAME"
# check if the service is running # check if the service is running
_is_container_running $CONTAINER_NAME || die "Service is not running - did not find container $CONTAINER_NAME." _is_container_running $CONTAINER_NAME || die "Service is not running - did not find container $CONTAINER_NAME."

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars
# STOP SCRIPT # STOP SCRIPT
# The stop script is required for all templates. # The stop script is required for all templates.
# It is used to stop the service on the server. # It is used to stop the service on the server.
check_required_env_vars "CONTAINER_NAME"
_stop_container $CONTAINER_NAME || die "Failed to stop container ${CONTAINER_NAME}" _stop_container $CONTAINER_NAME || die "Failed to stop container ${CONTAINER_NAME}"

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars
# UNINSTALL SCRIPT # UNINSTALL SCRIPT
# The uninstall script is required for all templates. # The uninstall script is required for all templates.
# It is used to uninstall the service from the server. # It is used to uninstall the service from the server.
check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
_remove_container $CONTAINER_NAME || die "Failed to remove container ${CONTAINER_NAME}" _remove_container $CONTAINER_NAME || die "Failed to remove container ${CONTAINER_NAME}"
_is_container_running && die "Couldn't stop existing container" _is_container_running && die "Couldn't stop existing container"

View File

@ -164,7 +164,7 @@ _check_required_env_vars() {
local required_vars=("$@") local required_vars=("$@")
for var in "${required_vars[@]}"; do for var in "${required_vars[@]}"; do
if [ -z "${!var}" ]; then if [ -z "${!var}" ]; then
_die "Required environment variable $var is not set in your service.env file" _die "Required environment variable $var is not set"
fi fi
done done
} }

View File

@ -1,12 +1,10 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "LOCAL_DATA_FOLDER"
# Nginx Example Backup Script # Nginx Example Backup Script
_check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
# hot backup is fine for nginx website content. # hot backup is fine for nginx website content.
autobackup "path=${LOCAL_DATA_FOLDER}" $1 $2 || _die "Failed to create backup" autobackup "path=${LOCAL_DATA_FOLDER}" $1 $2 || _die "Failed to create backup"
echo "Backup complete: ${BACKUP_FILE}" echo "Backup complete"

View File

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "LOCAL_DATA_FOLDER" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "CONTAINER_NAME"
# Nginx Example Install Script # Nginx Example Install Script
# Load service environment variables # Load service environment variables
source ./service.env source ./service.env
_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "LOCAL_DATA_FOLDER"
# Ensure local data folder exists # Ensure local data folder exists
if [ ! -d "${LOCAL_DATA_FOLDER}" ]; then if [ ! -d "${LOCAL_DATA_FOLDER}" ]; then

View File

@ -1,13 +1,9 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "CONTAINER_NAME"
# Nginx Example Logs Script # Nginx Example Logs Script
# Load service environment variables
source ./service.env
_check_required_env_vars "CONTAINER_NAME"
echo "Showing logs for ${CONTAINER_NAME}... (Press Ctrl+C to stop)" echo "Showing logs for ${CONTAINER_NAME}... (Press Ctrl+C to stop)"
_grey_start _grey_start
_get_container_logs $CONTAINER_NAME _get_container_logs $CONTAINER_NAME

View File

@ -1,14 +1,10 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "LOCAL_DATA_FOLDER" "CONTAINER_NAME"
# Nginx Example Nuke Script # Nginx Example Nuke Script
# Removes container and local data folder. # Removes container and local data folder.
# Load service environment variables
source ./service.env
_check_required_env_vars "LOCAL_DATA_FOLDER" "CONTAINER_NAME"
# Call uninstall script first # Call uninstall script first
./uninstall.sh ./uninstall.sh

View File

@ -1,18 +1,7 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "HOST_PORT"
# Nginx Example Ports Script # Nginx Example Ports Script
# Load service environment variables
source ./service.env
# This template uses HOST_PORT directly if set
# check_required_env_vars "HOST_PORT"
if [ -n "$HOST_PORT" ]; then
echo $HOST_PORT echo $HOST_PORT
else
# Default or logic to determine port if not in env
echo 80 # Default Nginx port
fi

View File

@ -1,40 +1,15 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "LOCAL_DATA_FOLDER"
# Nginx Example Restore Script # Nginx Example Restore Script
# Load service environment variables
source ./service.env
_check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
BACKUP_FILE="$1" BACKUP_FILE="$1"
if [ -z "$BACKUP_FILE" ]; then
_die "Backup file path not provided"
fi
if [ ! -f "$BACKUP_FILE" ]; then
_die "Backup file $BACKUP_FILE does not exist"
fi
echo "Uninstalling service before restore..." echo "Uninstalling service before restore..."
bash ./uninstall.sh || _die "Failed to uninstall service before restore" bash ./uninstall.sh || _die "Failed to uninstall service before restore"
echo "Removing existing data folder ${LOCAL_DATA_FOLDER}..." autorestore "path=${LOCAL_DATA_FOLDER}" $1 $2 || _die "Failed to restore data folder from backup"
# Use root remove in case of permission issues
_root_remove_tree "$LOCAL_DATA_FOLDER"
[ ! -d "$LOCAL_DATA_FOLDER" ] || _die "Failed to delete $LOCAL_DATA_FOLDER"
mkdir -p "$LOCAL_DATA_FOLDER"
[ -d "$LOCAL_DATA_FOLDER" ] || _die "Failed to create $LOCAL_DATA_FOLDER"
chmod 777 "$LOCAL_DATA_FOLDER" # Ensure permissions
echo "Restoring data from ${BACKUP_FILE} to ${LOCAL_DATA_FOLDER}..."
# Assuming backup is a simple tarball of the folder contents
tar -xzf "$BACKUP_FILE" -C "$LOCAL_DATA_FOLDER" --strip-components=1
if [ $? -ne 0 ]; then
_die "Failed to restore data folder from backup"
fi
echo "Restore complete. Reinstalling service..." echo "Restore complete. Reinstalling service..."
bash ./install.sh || _die "Failed to reinstall service after restore" bash ./install.sh || _die "Failed to reinstall service after restore"

View File

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER" "HOST_PORT" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
# START SCRIPT # START SCRIPT
# The start script is required for all templates. # The start script is required for all templates.
# It is used to start the service on the server. # It is used to start the service on the server.
# It is called with the path to the server specific env file as an argument. # It is called with the path to the server specific env file as an argument.
check_required_env_vars "CONTAINER_NAME" "HOST_PORT" "LOCAL_DATA_FOLDER"
[ -d "${LOCAL_DATA_FOLDER}" ] || die "Local data folder ${LOCAL_DATA_FOLDER} does not exist." [ -d "${LOCAL_DATA_FOLDER}" ] || die "Local data folder ${LOCAL_DATA_FOLDER} does not exist."

View File

@ -1,21 +1,13 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "CONTAINER_NAME"
# STATUS SCRIPT # STATUS SCRIPT
# The status script is OPTIONAL. # The status script is OPTIONAL.
# It is used to return the status of the service (0 is healthy, 1 is unhealthy). # It is used to return the status of the service (0 is healthy, 1 is unhealthy).
# It is called with the path to the server specific env file as an argument.
# This is an example of a status script that checks if the service is running.
check_required_env_vars "CONTAINER_NAME"
# check if the service is running # check if the service is running
_is_container_running $CONTAINER_NAME || die "Service is not running - did not find container $CONTAINER_NAME." _is_container_running $CONTAINER_NAME || die "Service is not running - did not find container $CONTAINER_NAME."
# check if the service is healthy
# curl -s -X GET http://localhost:${HOST_PORT}/health | grep -q "OK" \
# || die "Service is not healthy - did not get OK response from /health endpoint."
echo "Service is healthy" echo "Service is healthy"
exit 0 exit 0

View File

@ -1,11 +1,5 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
# STOP SCRIPT
# The stop script is required for all templates.
# It is used to stop the service on the server.
# It is called with the path to the server specific env file as an argument.
check_required_env_vars "CONTAINER_NAME" check_required_env_vars "CONTAINER_NAME"
_stop_container $CONTAINER_NAME || die "Failed to stop container ${CONTAINER_NAME}" _stop_container $CONTAINER_NAME || die "Failed to stop container ${CONTAINER_NAME}"

View File

@ -1,21 +1,13 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "CONTAINER_NAME"
# Nginx Example Uninstall Script # Nginx Example Uninstall Script
# Load service environment variables
source ./service.env
_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "LOCAL_DATA_FOLDER"
echo "Uninstalling service ${CONTAINER_NAME}..." echo "Uninstalling service ${CONTAINER_NAME}..."
_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}" _remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}"
if _is_container_running $CONTAINER_NAME; then _die "Couldn't stop existing container"; fi if _is_container_running $CONTAINER_NAME; then _die "Couldn't stop existing container"; fi
if _is_container_exists $CONTAINER_NAME; then _die "Couldn't remove existing container"; fi if _is_container_exists $CONTAINER_NAME; then _die "Couldn't remove existing container"; fi
# Optional: Remove image?
# echo "Removing image ${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}..."
# docker rmi "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || echo "Warning: Failed to remove image (might be in use)"
echo "Service ${CONTAINER_NAME} uninstalled." echo "Service ${CONTAINER_NAME} uninstalled."
# Note: This does NOT remove the local data folder. Use nuke.sh for that. echo "Note: This does NOT remove the local data folder. Use nuke.sh for that."

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars
# Simple Object Storage Backup Script # Simple Object Storage Backup Script
# Creates a backup tarball of the volume contents. # Creates a backup tarball of the volume contents.
_check_required_env_vars "CONTAINER_NAME" "VOLUME_NAME"
# HOT backup is fine for simple-object-storage # HOT backup is fine for simple-object-storage
autobackup "volume=${VOLUME_NAME}" $1 $2 || _die "Failed to create backup" autobackup "volume=${VOLUME_NAME}" $1 $2 || _die "Failed to create backup"

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars
# Simple Object Storage Install Script # Simple Object Storage Install Script
# Pulls image, creates volume/config, starts container. # Pulls image, creates volume/config, starts container.
_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "VOLUME_NAME" "HOST_NAME"
autocreate "volume=${VOLUME_NAME}" autocreate "volume=${VOLUME_NAME}"

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars
# Simple Object Storage Logs Script # Simple Object Storage Logs Script
# Shows the logs for the running container. # Shows the logs for the running container.
_check_required_env_vars "CONTAINER_NAME"
echo "Showing logs for ${CONTAINER_NAME}... (Press Ctrl+C to stop)" echo "Showing logs for ${CONTAINER_NAME}... (Press Ctrl+C to stop)"
_grey_start _grey_start

View File

@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars
# Simple Object Storage Nuke Script # Simple Object Storage Nuke Script
# Removes container AND volume. # Removes container AND volume.
_check_required_env_vars "CONTAINER_NAME" "VOLUME_NAME"
autonuke "volume=${VOLUME_NAME}" autonuke "volume=${VOLUME_NAME}"

View File

@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars
# PORT SCRIPT # PORT SCRIPT
# The port script is OPTIONAL. # The port script is OPTIONAL.
@ -8,7 +9,6 @@ source "${AGENT_PATH}/_common.sh"
# Required environment variables # Required environment variables
check_required_env_vars "CONFIG_PATH"
# determine port. # determine port.
command -v jq &> /dev/null || die "jq could not be found, please install it" command -v jq &> /dev/null || die "jq could not be found, please install it"

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" || _die "Failed to source _common.sh" source "${AGENT_PATH}/_common.sh" || _die "Failed to source _common.sh"
check_required_env_vars
# Simple Object Storage Restore Script # Simple Object Storage Restore Script
# Restores data from a backup file. # Restores data from a backup file.
_check_required_env_vars "CONTAINER_NAME" "VOLUME_NAME"
echo "Uninstalling service before restore..." echo "Uninstalling service before restore..."
bash ./uninstall.sh || _die "Failed to uninstall service before restore" bash ./uninstall.sh || _die "Failed to uninstall service before restore"

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars
# Simple Object Storage SSH Script # Simple Object Storage SSH Script
# Opens a shell in the running container. # Opens a shell in the running container.
_check_required_env_vars "CONTAINER_NAME"
if ! _is_container_running $CONTAINER_NAME; then if ! _is_container_running $CONTAINER_NAME; then
_die "Container ${CONTAINER_NAME} is not running. Can't connect to it." _die "Container ${CONTAINER_NAME} is not running. Can't connect to it."

View File

@ -1,10 +1,10 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "CONTAINER_NAME" "VOLUME_NAME" "CONFIG_PATH" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
# Simple Object Storage Start Script # Simple Object Storage Start Script
# Creates and starts the container using environment variables. # Creates and starts the container using environment variables.
check_required_env_vars "CONTAINER_NAME" "VOLUME_NAME" "CONFIG_PATH"
# check volume exists. # check volume exists.
if ! docker volume inspect "${VOLUME_NAME}" &>/dev/null; then if ! docker volume inspect "${VOLUME_NAME}" &>/dev/null; then

View File

@ -1,10 +1,10 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars
# STATUS SCRIPT # STATUS SCRIPT
# This is an example of a status script that checks if the service is running. # This is an example of a status script that checks if the service is running.
check_required_env_vars "CONTAINER_NAME"
# check if the service is running # check if the service is running
_is_container_running $CONTAINER_NAME || die "Service is not running - did not find container $CONTAINER_NAME." _is_container_running $CONTAINER_NAME || die "Service is not running - did not find container $CONTAINER_NAME."

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars
# Simple Object Storage Stop Script # Simple Object Storage Stop Script
# Stops the running container. # Stops the running container.
_check_required_env_vars "CONTAINER_NAME"
echo "Stopping service ${CONTAINER_NAME}..." echo "Stopping service ${CONTAINER_NAME}..."
_stop_container $CONTAINER_NAME || _die "Failed to stop container ${CONTAINER_NAME}" _stop_container $CONTAINER_NAME || _die "Failed to stop container ${CONTAINER_NAME}"

View File

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars
# UNINSTALL SCRIPT # UNINSTALL SCRIPT
# The uninstall script is required for all templates. # The uninstall script is required for all templates.
# It is used to uninstall the service from the server. # It is used to uninstall the service from the server.
# It is called with the path to the server specific env file as an argument. # It is called with the path to the server specific env file as an argument.
check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "VOLUME_NAME"
_remove_container $CONTAINER_NAME || die "Failed to remove container ${CONTAINER_NAME}" _remove_container $CONTAINER_NAME || die "Failed to remove container ${CONTAINER_NAME}"
_is_container_running && die "Couldn't stop existing container" _is_container_running && die "Couldn't stop existing container"

View File

@ -1,29 +1,13 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
# Get backup file path from argument
BACKUP_FILE="$1"
if [ -z "$BACKUP_FILE" ]; then
die "Backup file path not provided"
fi
# Check if backup file already exists
if [ -f "$BACKUP_FILE" ]; then
die "Backup file $BACKUP_FILE already exists"
fi
# Stop container before backup # Stop container before backup
_stop_container "$CONTAINER_NAME" _stop_container "$CONTAINER_NAME"
# Create backup of data folder autobackup "path=${LOCAL_DATA_FOLDER}" $1 $2 || _die "Failed to create backup"
# We include the parent folder in the backup paths (.), and strip on restore.
echo "Creating backup of $LOCAL_DATA_FOLDER..."
if ! tar zcvf "$BACKUP_FILE" -C "$LOCAL_DATA_FOLDER" .; then
_start_container "$CONTAINER_NAME"
die "Failed to create backup"
fi
# Start container after backup # Start container after backup
_start_container "$CONTAINER_NAME" _start_container "$CONTAINER_NAME"
echo "Backup created successfully: $BACKUP_FILE" echo "Backup created successfully"

View File

@ -1,29 +1,11 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
_check_required_env_vars "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
check_required_env_vars \ autocreate path=$LOCAL_DATA_FOLDER || _die "Failed to create local data folder"
"IMAGE_REGISTRY" \
"IMAGE_REPO" \
"IMAGE_TAG" \
"CONTAINER_NAME" \
"LOCAL_DATA_FOLDER"
# Create local data folder if it doesn't exist
if [ -d "${LOCAL_DATA_FOLDER}" ]; then
echo "Local data folder ${LOCAL_DATA_FOLDER} exists, using existing data."
else
echo "Local data folder ${LOCAL_DATA_FOLDER} does not exist, creating..."
mkdir -p "${LOCAL_DATA_FOLDER}"
fi
# Test Docker # Test Docker
_check_docker_installed || die "Docker test failed, aborting installation..." _check_docker_installed || _die "Docker test failed, aborting installation..."
# Create deploy and data folders
[ -z "$LOCAL_DATA_FOLDER" ] && die "LOCAL_DATA_FOLDER is not set"
create_folder "$LOCAL_DATA_FOLDER"
# check can pull image on remote host and exit if fails # check can pull image on remote host and exit if fails
docker pull "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || die "Failed to pull image $IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" docker pull "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || die "Failed to pull image $IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG"

View File

@ -1,11 +1,8 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "CONTAINER_NAME"
# check required env vars
check_required_env_vars \
"CONTAINER_NAME"
echo "Container ${CONTAINER_NAME} logs:" echo "Container ${CONTAINER_NAME} logs:"
grey_start _grey_start
docker logs "${CONTAINER_NAME}" docker logs "${CONTAINER_NAME}"
grey_end _grey_end

View File

@ -1,6 +1,5 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "HOST_PORT" check_required_env_vars "HOST_PORT"
echo $HOST_PORT echo $HOST_PORT

View File

@ -1,39 +1,16 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
# RESTORE SCRIPT # RESTORE SCRIPT
# The restore script is OPTIONAL. # The restore script is OPTIONAL.
# It is used to restore the service on the server from a backup file. # It is used to restore the service on the server from a backup file.
# It is called with one argument: the path to the backup file. # It is called with one argument: the path to the backup file.
check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
# Get backup file path from first argument
BACKUP_FILE="$1"
if [ -z "$BACKUP_FILE" ]; then
die "Backup file path not provided"
fi
# Check if backup file already exists
if [ ! -f "$BACKUP_FILE" ]; then
die "Backup file $BACKUP_FILE does not exist"
fi
# # Stop container before backup # # Stop container before backup
bash ./uninstall.sh || die "Failed to uninstall service before restore" bash ./uninstall.sh || die "Failed to uninstall service before restore"
# Remove existing data folder autorestore "path=${LOCAL_DATA_FOLDER}" $1 $2 || die "Failed to restore data folder from backup"
echo "Deleting ALL data in $LOCAL_DATA_FOLDER."
_root_remove_tree "$LOCAL_DATA_FOLDER"
[ ! -d "$LOCAL_DATA_FOLDER" ] || die "Failed to delete $LOCAL_DATA_FOLDER"
mkdir -p "$LOCAL_DATA_FOLDER"
[ -d "$LOCAL_DATA_FOLDER" ] || die "Failed to create $LOCAL_DATA_FOLDER"
# Restore data folder from backup
# --strip-components=1 removes the parent folder in the tgz from the restore paths.
if ! tar xzvf "$BACKUP_FILE" -C "$LOCAL_DATA_FOLDER" --strip-components=1; then
die "Failed to restore data folder from backup"
fi
# reinstall service # reinstall service
bash ./install.sh || die "Failed to reinstall service after restore" bash ./install.sh || die "Failed to reinstall service after restore"

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "CONTAINER_NAME"
if ! _is_container_running "$CONTAINER_NAME"; then if ! _is_container_running "$CONTAINER_NAME"; then
die "Container ${CONTAINER_NAME} is not running. Can't connect to it." die "Container ${CONTAINER_NAME} is not running. Can't connect to it."

View File

@ -1,14 +1,6 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "CONTAINER_NAME" "HOST_PORT" "CONTAINER_PORT" "LOCAL_DATA_FOLDER" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
check_required_env_vars \
"CONTAINER_NAME" \
"HOST_PORT" \
"CONTAINER_PORT" \
"LOCAL_DATA_FOLDER" \
"IMAGE_REGISTRY" \
"IMAGE_REPO" \
"IMAGE_TAG"
DOCKER_RUN_CMD="docker run -d \ DOCKER_RUN_CMD="docker run -d \

View File

@ -1,9 +1,6 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "CONTAINER_NAME" "HOST_PORT"
check_required_env_vars \
"CONTAINER_NAME" \
"HOST_PORT"
# check if the service is running # check if the service is running
_is_container_running $CONTAINER_NAME || die "Service is not running - did not find container $CONTAINER_NAME." _is_container_running $CONTAINER_NAME || die "Service is not running - did not find container $CONTAINER_NAME."

View File

@ -1,8 +1,6 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "CONTAINER_NAME"
check_required_env_vars \
"CONTAINER_NAME"
_stop_container $CONTAINER_NAME || die "Failed to stop container ${CONTAINER_NAME}" _stop_container $CONTAINER_NAME || die "Failed to stop container ${CONTAINER_NAME}"

View File

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
# UNINSTALL SCRIPT # UNINSTALL SCRIPT
# The uninstall script is required for all templates. # The uninstall script is required for all templates.
# It is used to uninstall the service from the server. # It is used to uninstall the service from the server.
# It is called with the path to the server specific env file as an argument. # It is called with the path to the server specific env file as an argument.
check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
_remove_container $CONTAINER_NAME || die "Failed to remove container ${CONTAINER_NAME}" _remove_container $CONTAINER_NAME || die "Failed to remove container ${CONTAINER_NAME}"
_is_container_running && die "Couldn't stop existing container" _is_container_running && die "Couldn't stop existing container"

View File

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
# Watchtower Install Script # Watchtower Install Script
# Load service environment variables # Load service environment variables
source ./service.env source ./service.env
_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
echo "Checking Docker installation..." echo "Checking Docker installation..."
_check_docker_installed || _die "Docker test failed, aborting installation..." _check_docker_installed || _die "Docker test failed, aborting installation..."

View File

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "CONTAINER_NAME"
# Watchtower Logs Script # Watchtower Logs Script
# Load service environment variables # Load service environment variables
source ./service.env source ./service.env
_check_required_env_vars "CONTAINER_NAME"
echo "Showing logs for ${CONTAINER_NAME}... (Press Ctrl+C to stop)" echo "Showing logs for ${CONTAINER_NAME}... (Press Ctrl+C to stop)"
_grey_start _grey_start

View File

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars
# Watchtower Start Script # Watchtower Start Script
# Load service environment variables # Load service environment variables
source ./service.env source ./service.env
_check_required_env_vars "CONTAINER_NAME" "INTERVAL"
# Optional arguments (e.g., --cleanup, --monitor-only) # Optional arguments (e.g., --cleanup, --monitor-only)
EXTRA_ARGS=$1 EXTRA_ARGS=$1

View File

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars "CONTAINER_NAME"
# Watchtower Status Script # Watchtower Status Script
# Load service environment variables # Load service environment variables
source ./service.env source ./service.env
_check_required_env_vars "CONTAINER_NAME"
_is_container_running $CONTAINER_NAME || _die "Service is not running - did not find container $CONTAINER_NAME." _is_container_running $CONTAINER_NAME || _die "Service is not running - did not find container $CONTAINER_NAME."

View File

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars
# Watchtower Stop Script # Watchtower Stop Script
# Load service environment variables # Load service environment variables
source ./service.env source ./service.env
_check_required_env_vars "CONTAINER_NAME"
echo "Stopping service ${CONTAINER_NAME}..." echo "Stopping service ${CONTAINER_NAME}..."
_stop_container $CONTAINER_NAME || _die "Failed to stop container ${CONTAINER_NAME}" _stop_container $CONTAINER_NAME || _die "Failed to stop container ${CONTAINER_NAME}"

View File

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
source "${AGENT_PATH}/_common.sh" source "${AGENT_PATH}/_common.sh"
check_required_env_vars
# Watchtower Uninstall Script # Watchtower Uninstall Script
# Load service environment variables # Load service environment variables
source ./service.env source ./service.env
_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
echo "Uninstalling service ${CONTAINER_NAME}..." echo "Uninstalling service ${CONTAINER_NAME}..."
_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}" _remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}"