.
This commit is contained in:
parent
2fe7d4c3d9
commit
3d9b1fa6d2
2
replace_die.sh
Normal file
2
replace_die.sh
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
echo "Replacing die with _die in all template scripts..."
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
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"
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
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
|
||||
die "Failed to autocreate volumes and paths"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars "CONTAINER_NAME"
|
||||
check_required_env_vars
|
||||
|
||||
# Main script.
|
||||
echo "Container ${CONTAINER_NAME} logs:"
|
||||
|
@ -1,12 +1,12 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars
|
||||
|
||||
# NUKE SCRIPT
|
||||
# This is run after the uninstall.sh script to delete all data.
|
||||
# dropshell handles the configuration files, so we just need to remove
|
||||
# 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
|
||||
die "Failed to nuke"
|
||||
|
@ -1,9 +1,9 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars
|
||||
|
||||
# RESTORE SCRIPT
|
||||
|
||||
check_required_env_vars "DATA_VOLUME" "CONFIG_VOLUME" "CONFIG_PATH"
|
||||
|
||||
# uninstall container before restore
|
||||
bash ./uninstall.sh || die "Failed to uninstall service before restore"
|
||||
|
@ -1,11 +1,11 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars
|
||||
|
||||
# START SCRIPT
|
||||
# The start script is required for all templates.
|
||||
# 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 \
|
||||
|
@ -1,12 +1,12 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars
|
||||
|
||||
# STATUS SCRIPT
|
||||
# The status script is OPTIONAL.
|
||||
# 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.
|
||||
check_required_env_vars "CONTAINER_NAME"
|
||||
|
||||
# check if the service is running
|
||||
_is_container_running $CONTAINER_NAME || die "Service is not running - did not find container $CONTAINER_NAME."
|
||||
|
@ -1,11 +1,11 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars
|
||||
|
||||
# STOP SCRIPT
|
||||
# The stop script is required for all templates.
|
||||
# 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}"
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars
|
||||
|
||||
# UNINSTALL SCRIPT
|
||||
# The uninstall script is required for all templates.
|
||||
# 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}"
|
||||
_is_container_running && die "Couldn't stop existing container"
|
||||
|
@ -164,7 +164,7 @@ _check_required_env_vars() {
|
||||
local required_vars=("$@")
|
||||
for var in "${required_vars[@]}"; do
|
||||
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
|
||||
done
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars "LOCAL_DATA_FOLDER"
|
||||
|
||||
# Nginx Example Backup Script
|
||||
|
||||
_check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
|
||||
|
||||
# hot backup is fine for nginx website content.
|
||||
|
||||
autobackup "path=${LOCAL_DATA_FOLDER}" $1 $2 || _die "Failed to create backup"
|
||||
|
||||
echo "Backup complete: ${BACKUP_FILE}"
|
||||
echo "Backup complete"
|
||||
|
@ -1,12 +1,12 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars "LOCAL_DATA_FOLDER" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "CONTAINER_NAME"
|
||||
|
||||
# Nginx Example Install Script
|
||||
|
||||
|
||||
# Load service environment variables
|
||||
source ./service.env
|
||||
_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "LOCAL_DATA_FOLDER"
|
||||
|
||||
# Ensure local data folder exists
|
||||
if [ ! -d "${LOCAL_DATA_FOLDER}" ]; then
|
||||
|
@ -1,13 +1,9 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars "CONTAINER_NAME"
|
||||
|
||||
# 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)"
|
||||
_grey_start
|
||||
_get_container_logs $CONTAINER_NAME
|
||||
|
@ -1,14 +1,10 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars "LOCAL_DATA_FOLDER" "CONTAINER_NAME"
|
||||
|
||||
# Nginx Example Nuke Script
|
||||
# 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
|
||||
./uninstall.sh
|
||||
|
||||
|
@ -1,18 +1,7 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars "HOST_PORT"
|
||||
|
||||
# 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
|
||||
else
|
||||
# Default or logic to determine port if not in env
|
||||
echo 80 # Default Nginx port
|
||||
fi
|
||||
echo $HOST_PORT
|
||||
|
@ -1,40 +1,15 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars "LOCAL_DATA_FOLDER"
|
||||
|
||||
# Nginx Example Restore Script
|
||||
|
||||
|
||||
# Load service environment variables
|
||||
source ./service.env
|
||||
_check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
|
||||
|
||||
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..."
|
||||
bash ./uninstall.sh || _die "Failed to uninstall service before restore"
|
||||
|
||||
echo "Removing existing data folder ${LOCAL_DATA_FOLDER}..."
|
||||
# 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
|
||||
autorestore "path=${LOCAL_DATA_FOLDER}" $1 $2 || _die "Failed to restore data folder from backup"
|
||||
|
||||
echo "Restore complete. Reinstalling service..."
|
||||
bash ./install.sh || _die "Failed to reinstall service after restore"
|
||||
|
@ -1,12 +1,12 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER" "HOST_PORT" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
|
||||
|
||||
# START SCRIPT
|
||||
# The start script is required for all templates.
|
||||
# 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.
|
||||
|
||||
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."
|
||||
|
||||
|
@ -1,21 +1,13 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars "CONTAINER_NAME"
|
||||
|
||||
# STATUS SCRIPT
|
||||
# The status script is OPTIONAL.
|
||||
# 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
|
||||
_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"
|
||||
exit 0
|
||||
|
@ -1,11 +1,5 @@
|
||||
#!/bin/bash
|
||||
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"
|
||||
|
||||
_stop_container $CONTAINER_NAME || die "Failed to stop container ${CONTAINER_NAME}"
|
||||
|
@ -1,21 +1,13 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars "CONTAINER_NAME"
|
||||
|
||||
# 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}..."
|
||||
_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_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."
|
||||
# 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."
|
||||
|
@ -1,11 +1,11 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars
|
||||
|
||||
# Simple Object Storage Backup Script
|
||||
# Creates a backup tarball of the volume contents.
|
||||
|
||||
|
||||
_check_required_env_vars "CONTAINER_NAME" "VOLUME_NAME"
|
||||
|
||||
# HOT backup is fine for simple-object-storage
|
||||
autobackup "volume=${VOLUME_NAME}" $1 $2 || _die "Failed to create backup"
|
||||
|
@ -1,11 +1,11 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars
|
||||
|
||||
# Simple Object Storage Install Script
|
||||
# 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}"
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars
|
||||
|
||||
# Simple Object Storage Logs Script
|
||||
# Shows the logs for the running container.
|
||||
|
||||
|
||||
_check_required_env_vars "CONTAINER_NAME"
|
||||
|
||||
echo "Showing logs for ${CONTAINER_NAME}... (Press Ctrl+C to stop)"
|
||||
_grey_start
|
||||
|
@ -1,9 +1,9 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars
|
||||
|
||||
# Simple Object Storage Nuke Script
|
||||
# Removes container AND volume.
|
||||
|
||||
|
||||
_check_required_env_vars "CONTAINER_NAME" "VOLUME_NAME"
|
||||
autonuke "volume=${VOLUME_NAME}"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars
|
||||
|
||||
# PORT SCRIPT
|
||||
# The port script is OPTIONAL.
|
||||
@ -8,7 +9,6 @@ source "${AGENT_PATH}/_common.sh"
|
||||
|
||||
|
||||
# Required environment variables
|
||||
check_required_env_vars "CONFIG_PATH"
|
||||
|
||||
# determine port.
|
||||
command -v jq &> /dev/null || die "jq could not be found, please install it"
|
||||
|
@ -1,11 +1,11 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh" || _die "Failed to source _common.sh"
|
||||
check_required_env_vars
|
||||
|
||||
# Simple Object Storage Restore Script
|
||||
# Restores data from a backup file.
|
||||
|
||||
|
||||
_check_required_env_vars "CONTAINER_NAME" "VOLUME_NAME"
|
||||
|
||||
echo "Uninstalling service before restore..."
|
||||
bash ./uninstall.sh || _die "Failed to uninstall service before restore"
|
||||
|
@ -1,11 +1,11 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars
|
||||
|
||||
# Simple Object Storage SSH Script
|
||||
# Opens a shell in the running container.
|
||||
|
||||
|
||||
_check_required_env_vars "CONTAINER_NAME"
|
||||
|
||||
if ! _is_container_running $CONTAINER_NAME; then
|
||||
_die "Container ${CONTAINER_NAME} is not running. Can't connect to it."
|
||||
|
@ -1,10 +1,10 @@
|
||||
#!/bin/bash
|
||||
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
|
||||
# Creates and starts the container using environment variables.
|
||||
|
||||
check_required_env_vars "CONTAINER_NAME" "VOLUME_NAME" "CONFIG_PATH"
|
||||
|
||||
# check volume exists.
|
||||
if ! docker volume inspect "${VOLUME_NAME}" &>/dev/null; then
|
||||
|
@ -1,10 +1,10 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars
|
||||
|
||||
# STATUS SCRIPT
|
||||
|
||||
# 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
|
||||
_is_container_running $CONTAINER_NAME || die "Service is not running - did not find container $CONTAINER_NAME."
|
||||
|
@ -1,11 +1,11 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars
|
||||
|
||||
# Simple Object Storage Stop Script
|
||||
# Stops the running container.
|
||||
|
||||
|
||||
_check_required_env_vars "CONTAINER_NAME"
|
||||
|
||||
echo "Stopping service ${CONTAINER_NAME}..."
|
||||
_stop_container $CONTAINER_NAME || _die "Failed to stop container ${CONTAINER_NAME}"
|
||||
|
@ -1,12 +1,12 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars
|
||||
|
||||
# UNINSTALL SCRIPT
|
||||
# The uninstall script is required for all templates.
|
||||
# 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.
|
||||
|
||||
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}"
|
||||
_is_container_running && die "Couldn't stop existing container"
|
||||
|
@ -1,29 +1,13 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
|
||||
# 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
|
||||
check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
|
||||
|
||||
# Stop container before backup
|
||||
_stop_container "$CONTAINER_NAME"
|
||||
|
||||
# Create backup of data folder
|
||||
# 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
|
||||
autobackup "path=${LOCAL_DATA_FOLDER}" $1 $2 || _die "Failed to create backup"
|
||||
|
||||
# Start container after backup
|
||||
_start_container "$CONTAINER_NAME"
|
||||
|
||||
echo "Backup created successfully: $BACKUP_FILE"
|
||||
echo "Backup created successfully"
|
||||
|
@ -1,29 +1,11 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
_check_required_env_vars "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
|
||||
|
||||
check_required_env_vars \
|
||||
"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
|
||||
|
||||
autocreate path=$LOCAL_DATA_FOLDER || _die "Failed to create local data folder"
|
||||
|
||||
# Test Docker
|
||||
_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_docker_installed || _die "Docker test failed, aborting installation..."
|
||||
|
||||
# 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"
|
||||
|
@ -1,11 +1,8 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
|
||||
# check required env vars
|
||||
check_required_env_vars \
|
||||
"CONTAINER_NAME"
|
||||
check_required_env_vars "CONTAINER_NAME"
|
||||
|
||||
echo "Container ${CONTAINER_NAME} logs:"
|
||||
grey_start
|
||||
_grey_start
|
||||
docker logs "${CONTAINER_NAME}"
|
||||
grey_end
|
||||
_grey_end
|
||||
|
@ -1,6 +1,5 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
|
||||
check_required_env_vars "HOST_PORT"
|
||||
|
||||
|
||||
echo $HOST_PORT
|
||||
|
@ -1,39 +1,16 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
|
||||
|
||||
# RESTORE SCRIPT
|
||||
# The restore script is OPTIONAL.
|
||||
# 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.
|
||||
|
||||
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
|
||||
bash ./uninstall.sh || die "Failed to uninstall service before restore"
|
||||
|
||||
# Remove existing data folder
|
||||
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
|
||||
autorestore "path=${LOCAL_DATA_FOLDER}" $1 $2 || die "Failed to restore data folder from backup"
|
||||
|
||||
# reinstall service
|
||||
bash ./install.sh || die "Failed to reinstall service after restore"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
|
||||
check_required_env_vars "CONTAINER_NAME"
|
||||
|
||||
if ! _is_container_running "$CONTAINER_NAME"; then
|
||||
die "Container ${CONTAINER_NAME} is not running. Can't connect to it."
|
||||
|
@ -1,14 +1,6 @@
|
||||
#!/bin/bash
|
||||
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 \
|
||||
|
@ -1,9 +1,6 @@
|
||||
#!/bin/bash
|
||||
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
|
||||
_is_container_running $CONTAINER_NAME || die "Service is not running - did not find container $CONTAINER_NAME."
|
||||
|
@ -1,8 +1,6 @@
|
||||
#!/bin/bash
|
||||
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}"
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER"
|
||||
|
||||
# UNINSTALL SCRIPT
|
||||
# The uninstall script is required for all templates.
|
||||
# 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.
|
||||
|
||||
check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
|
||||
|
||||
_remove_container $CONTAINER_NAME || die "Failed to remove container ${CONTAINER_NAME}"
|
||||
_is_container_running && die "Couldn't stop existing container"
|
||||
|
@ -1,12 +1,12 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
|
||||
|
||||
# Watchtower Install Script
|
||||
|
||||
|
||||
# Load service environment variables
|
||||
source ./service.env
|
||||
_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
|
||||
|
||||
echo "Checking Docker installation..."
|
||||
_check_docker_installed || _die "Docker test failed, aborting installation..."
|
||||
|
@ -1,12 +1,12 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars "CONTAINER_NAME"
|
||||
|
||||
# Watchtower 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)"
|
||||
_grey_start
|
||||
|
@ -1,12 +1,12 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars
|
||||
|
||||
# Watchtower Start Script
|
||||
|
||||
|
||||
# Load service environment variables
|
||||
source ./service.env
|
||||
_check_required_env_vars "CONTAINER_NAME" "INTERVAL"
|
||||
|
||||
# Optional arguments (e.g., --cleanup, --monitor-only)
|
||||
EXTRA_ARGS=$1
|
||||
|
@ -1,12 +1,12 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars "CONTAINER_NAME"
|
||||
|
||||
# Watchtower Status Script
|
||||
|
||||
|
||||
# Load service environment variables
|
||||
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."
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars
|
||||
|
||||
# Watchtower Stop Script
|
||||
|
||||
|
||||
# Load service environment variables
|
||||
source ./service.env
|
||||
_check_required_env_vars "CONTAINER_NAME"
|
||||
|
||||
echo "Stopping service ${CONTAINER_NAME}..."
|
||||
_stop_container $CONTAINER_NAME || _die "Failed to stop container ${CONTAINER_NAME}"
|
||||
|
@ -1,12 +1,12 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/_common.sh"
|
||||
check_required_env_vars
|
||||
|
||||
# Watchtower Uninstall Script
|
||||
|
||||
|
||||
# Load service environment variables
|
||||
source ./service.env
|
||||
_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
|
||||
|
||||
echo "Uninstalling service ${CONTAINER_NAME}..."
|
||||
_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user