diff --git a/caddy/README.txt b/caddy/README.txt new file mode 100644 index 0000000..43c0a65 --- /dev/null +++ b/caddy/README.txt @@ -0,0 +1,3 @@ +Caddy! + +Edit the static site, and the Caddyfile. diff --git a/caddy/_default.env b/caddy/_default.env new file mode 100644 index 0000000..1473fca --- /dev/null +++ b/caddy/_default.env @@ -0,0 +1,8 @@ +# Service settings specific to this server + +# Image settings +IMAGE_REGISTRY="docker.io" +IMAGE_REPO="caddy" + +DATA_VOLUME=caddy_data +CONFIG_VOLUME=caddy_config diff --git a/caddy/backup.sh b/caddy/backup.sh new file mode 100644 index 0000000..810b024 --- /dev/null +++ b/caddy/backup.sh @@ -0,0 +1,11 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars + +_stop_container "$CONTAINER_NAME" + +autobackup "$1" "$2" "volume=$DATA_VOLUME" "volume=$CONFIG_VOLUME" || _die "Failed to create backup" + +_start_container "$CONTAINER_NAME" + +echo "Backup created successfully: $BACKUP_FILE" diff --git a/caddy/config/.template_info.env b/caddy/config/.template_info.env new file mode 100644 index 0000000..ee61c54 --- /dev/null +++ b/caddy/config/.template_info.env @@ -0,0 +1,2 @@ +# Template to use - always required! +TEMPLATE=caddy diff --git a/caddy/config/Caddyfile b/caddy/config/Caddyfile new file mode 100644 index 0000000..9bd0b7a --- /dev/null +++ b/caddy/config/Caddyfile @@ -0,0 +1,6 @@ +# See https://caddyserver.com/docs/caddyfile + +localhost { +root * /srv +file_server +} diff --git a/caddy/config/service.env b/caddy/config/service.env new file mode 100644 index 0000000..c4f3976 --- /dev/null +++ b/caddy/config/service.env @@ -0,0 +1,10 @@ +# Service settings specific to this server +# (can also override anything in the _default.env file in the template to make it specific to this server) +CONTAINER_NAME=caddy +IMAGE_TAG="latest" + +# Scripts will have these environment variables set, plus those in _default.env, plus: +# SERVER, SERVICE, CONFIG_PATH +# CONFIG_PATH points to this directory! + + diff --git a/caddy/config/static/index.html b/caddy/config/static/index.html new file mode 100644 index 0000000..cd8f430 --- /dev/null +++ b/caddy/config/static/index.html @@ -0,0 +1,9 @@ + +
+This is a static site.
+ + \ No newline at end of file diff --git a/caddy/install.sh b/caddy/install.sh new file mode 100644 index 0000000..1ad9eba --- /dev/null +++ b/caddy/install.sh @@ -0,0 +1,17 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "DATA_VOLUME" "CONFIG_VOLUME" "CONFIG_PATH" + +autocreate "volume=$DATA_VOLUME" "volume=$CONFIG_VOLUME" || _die "Failed to autocreate volumes $DATA_VOLUME and $CONFIG_VOLUME" + +_check_docker_installed || _die "Docker test failed, aborting installation..." + +docker pull "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || _die "Failed to pull image $IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" + +[ -f "${CONFIG_PATH}/Caddyfile" ] || _die "Caddyfile not found in ${CONFIG_PATH}!" + +bash ./stop.sh || _die "Failed to stop container ${CONTAINER_NAME}" +_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}" +bash ./start.sh || _die "Failed to start container ${CONTAINER_NAME}" + +echo "Installation of ${CONTAINER_NAME} complete" diff --git a/caddy/logs.sh b/caddy/logs.sh new file mode 100644 index 0000000..c1b820f --- /dev/null +++ b/caddy/logs.sh @@ -0,0 +1,9 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars + +# Main script. +echo "Container ${CONTAINER_NAME} logs:" +_grey_start +docker logs "${CONTAINER_NAME}" +_grey_end diff --git a/caddy/nuke.sh b/caddy/nuke.sh new file mode 100644 index 0000000..5495b27 --- /dev/null +++ b/caddy/nuke.sh @@ -0,0 +1,13 @@ +#!/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. + + +autonuke "volume=$DATA_VOLUME" "volume=$CONFIG_VOLUME" || _die "Failed to nuke" + +echo "Nuking of ${CONTAINER_NAME} complete." diff --git a/caddy/ports.sh b/caddy/ports.sh new file mode 100644 index 0000000..aa08d2d --- /dev/null +++ b/caddy/ports.sh @@ -0,0 +1,6 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" + + +echo 80 +echo 443 diff --git a/caddy/restore.sh b/caddy/restore.sh new file mode 100644 index 0000000..e5c7993 --- /dev/null +++ b/caddy/restore.sh @@ -0,0 +1,17 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars + +# RESTORE SCRIPT + + +# uninstall container before restore +bash ./uninstall.sh || _die "Failed to uninstall service before restore" + +# restore data from backup file +autorestore "$1" "$2" "volume=$DATA_VOLUME" "volume=$CONFIG_VOLUME" || _die "Failed to restore data from backup file" + +# reinstall service +bash ./install.sh || _die "Failed to reinstall service after restore" + +echo "Restore complete! Service is running again." diff --git a/caddy/start.sh b/caddy/start.sh new file mode 100644 index 0000000..5f2ec6f --- /dev/null +++ b/caddy/start.sh @@ -0,0 +1,33 @@ +#!/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. + + + +DOCKER_RUN_CMD="docker run -d \ + --restart unless-stopped \ + --name ${CONTAINER_NAME} \ + -p 80:80 \ + -p 443:443 \ + -p 443:443/udp \ + -v ${CONFIG_PATH}/Caddyfile:/etc/caddy/Caddyfile \ + -v ${DATA_VOLUME}:/data \ + -v ${CONFIG_VOLUME}:/config \ + -v ${CONFIG_PATH}/static:/srv \ + ${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}" + + +if ! _create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then + _die "Failed to start container ${CONTAINER_NAME}" +fi + +# Check if the container is running +if ! _is_container_running "$CONTAINER_NAME"; then + _die "Container ${CONTAINER_NAME} is not running" +fi + +echo "Container ${CONTAINER_NAME} started" diff --git a/caddy/status.sh b/caddy/status.sh new file mode 100644 index 0000000..85d3e27 --- /dev/null +++ b/caddy/status.sh @@ -0,0 +1,15 @@ +#!/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 if the service is running +_is_container_running $CONTAINER_NAME || _die "Service is not running - did not find container $CONTAINER_NAME." + +echo "Service is healthy" +exit 0 diff --git a/caddy/stop.sh b/caddy/stop.sh new file mode 100644 index 0000000..9b83cc5 --- /dev/null +++ b/caddy/stop.sh @@ -0,0 +1,12 @@ +#!/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. + + +_stop_container $CONTAINER_NAME || _die "Failed to stop container ${CONTAINER_NAME}" + +echo "Container ${CONTAINER_NAME} stopped" diff --git a/caddy/uninstall.sh b/caddy/uninstall.sh new file mode 100644 index 0000000..6163001 --- /dev/null +++ b/caddy/uninstall.sh @@ -0,0 +1,18 @@ +#!/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. + + +_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}" +_is_container_running && _die "Couldn't stop existing container" +_is_container_exists && _die "Couldn't remove existing container" + +# remove the image +docker rmi "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || echo "Failed to remove image $IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" + +echo "Uninstallation of ${CONTAINER_NAME} complete." +echo "Local data still in place." diff --git a/example-nginx/README.txt b/example-nginx/README.txt new file mode 100644 index 0000000..4cbd8ba --- /dev/null +++ b/example-nginx/README.txt @@ -0,0 +1 @@ +Caddy diff --git a/example-nginx/_default.env b/example-nginx/_default.env new file mode 100644 index 0000000..a5e0c2d --- /dev/null +++ b/example-nginx/_default.env @@ -0,0 +1,5 @@ +# Service settings specific to this server + +# Image settings +IMAGE_REGISTRY="docker.io" +IMAGE_REPO="nginx" diff --git a/example-nginx/backup.sh b/example-nginx/backup.sh new file mode 100644 index 0000000..5a97acd --- /dev/null +++ b/example-nginx/backup.sh @@ -0,0 +1,10 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars "LOCAL_DATA_FOLDER" "BACKUP_FILE" "TEMP_DIR" "CONTAINER_NAME" + +# Nginx Example Backup Script +# hot backup is fine for nginx website content. + +autobackup "path=${LOCAL_DATA_FOLDER}" || _die "Failed to create backup" + +echo "Backup complete for ${CONTAINER_NAME}" diff --git a/example-nginx/config/.template_info.env b/example-nginx/config/.template_info.env new file mode 100644 index 0000000..ca4a270 --- /dev/null +++ b/example-nginx/config/.template_info.env @@ -0,0 +1,2 @@ +# Template to use - always required! +TEMPLATE=example-nginx diff --git a/example-nginx/config/service.env b/example-nginx/config/service.env new file mode 100644 index 0000000..08ab81d --- /dev/null +++ b/example-nginx/config/service.env @@ -0,0 +1,12 @@ +# Service settings specific to this server +# (can also override anything in the _default.env file in the template to make it specific to this server) +HOST_PORT=60123 +LOCAL_DATA_FOLDER="/home/dropshell/nginx-example-website" +CONTAINER_NAME="example-nginx" +IMAGE_TAG="latest" + +# Scripts will have these environment variables set, plus those in _default.env, plus: +# SERVER, SERVICE, CONFIG_PATH +# CONFIG_PATH points to this directory! + + diff --git a/example-nginx/install.sh b/example-nginx/install.sh new file mode 100644 index 0000000..d0270a9 --- /dev/null +++ b/example-nginx/install.sh @@ -0,0 +1,23 @@ +#!/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 + +# Ensure local data folder exists +autocreate "path=${LOCAL_DATA_FOLDER}" + +echo "Checking Docker installation..." +_check_docker_installed || _die "Docker test failed, aborting installation..." + +echo "Pulling 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" + +echo "Stopping and removing any existing container..." +bash ./stop.sh || _die "Failed to stop container ${CONTAINER_NAME}" +_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}" + +echo "Starting container..." +bash ./start.sh || _die "Failed to start container ${CONTAINER_NAME}" + +echo "Installation complete for service ${CONTAINER_NAME}." diff --git a/example-nginx/logs.sh b/example-nginx/logs.sh new file mode 100644 index 0000000..085f83a --- /dev/null +++ b/example-nginx/logs.sh @@ -0,0 +1,10 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars "CONTAINER_NAME" + +# Nginx Example Logs Script + +echo "Showing logs for ${CONTAINER_NAME}... (Press Ctrl+C to stop)" +_grey_start +_get_container_logs $CONTAINER_NAME +_grey_end diff --git a/example-nginx/nuke.sh b/example-nginx/nuke.sh new file mode 100644 index 0000000..09ae539 --- /dev/null +++ b/example-nginx/nuke.sh @@ -0,0 +1,13 @@ +#!/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. + +# Call uninstall script first +./uninstall.sh + +autonuke "path=${LOCAL_DATA_FOLDER}" || _die "Failed to nuke ${LOCAL_DATA_FOLDER}" + +echo "Nuke complete for service ${CONTAINER_NAME}." diff --git a/example-nginx/ports.sh b/example-nginx/ports.sh new file mode 100644 index 0000000..edb1534 --- /dev/null +++ b/example-nginx/ports.sh @@ -0,0 +1,7 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars "HOST_PORT" + +# Nginx Example Ports Script + +echo $HOST_PORT diff --git a/example-nginx/restore.sh b/example-nginx/restore.sh new file mode 100644 index 0000000..1f5a0c3 --- /dev/null +++ b/example-nginx/restore.sh @@ -0,0 +1,15 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars "LOCAL_DATA_FOLDER" "BACKUP_FILE" "TEMP_DIR" "CONTAINER_NAME" + +# Nginx Example Restore Script + +echo "Uninstalling service before restore..." +bash ./uninstall.sh || _die "Failed to uninstall service before restore" + +autorestore "path=${LOCAL_DATA_FOLDER}" || _die "Failed to restore data folder from backup" + +echo "Restore complete. Reinstalling service..." +bash ./install.sh || _die "Failed to reinstall service after restore" + +echo "Service ${CONTAINER_NAME} restored and reinstalled." diff --git a/example-nginx/start.sh b/example-nginx/start.sh new file mode 100644 index 0000000..40438ac --- /dev/null +++ b/example-nginx/start.sh @@ -0,0 +1,30 @@ +#!/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. + + +[ -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}:80 \ + -v ${LOCAL_DATA_FOLDER}:/usr/share/nginx/html:ro \ + ${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}" + + +if ! _create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then + _die "Failed to start container ${CONTAINER_NAME}" +fi + +# Check if the container is running +if ! _is_container_running "$CONTAINER_NAME"; then + _die "Container ${CONTAINER_NAME} is not running" +fi + +echo "Container ${CONTAINER_NAME} started" diff --git a/example-nginx/status.sh b/example-nginx/status.sh new file mode 100644 index 0000000..86ba20f --- /dev/null +++ b/example-nginx/status.sh @@ -0,0 +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). + +# check if the service is running +_is_container_running $CONTAINER_NAME || _die "Service is not running - did not find container $CONTAINER_NAME." + +echo "Service is healthy" +exit 0 diff --git a/example-nginx/stop.sh b/example-nginx/stop.sh new file mode 100644 index 0000000..f908886 --- /dev/null +++ b/example-nginx/stop.sh @@ -0,0 +1,7 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars "CONTAINER_NAME" + +_stop_container $CONTAINER_NAME || _die "Failed to stop container ${CONTAINER_NAME}" + +echo "Container ${CONTAINER_NAME} stopped" diff --git a/example-nginx/uninstall.sh b/example-nginx/uninstall.sh new file mode 100644 index 0000000..4507a0d --- /dev/null +++ b/example-nginx/uninstall.sh @@ -0,0 +1,13 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars "CONTAINER_NAME" + +# Nginx Example Uninstall Script + +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 + +echo "Service ${CONTAINER_NAME} uninstalled." +echo "Note: This does NOT remove the local data folder. Use nuke.sh for that." diff --git a/simple-object-storage/README.txt b/simple-object-storage/README.txt new file mode 100644 index 0000000..7041ee9 --- /dev/null +++ b/simple-object-storage/README.txt @@ -0,0 +1 @@ +simple-object-storage diff --git a/simple-object-storage/_default.env b/simple-object-storage/_default.env new file mode 100644 index 0000000..a214437 --- /dev/null +++ b/simple-object-storage/_default.env @@ -0,0 +1,12 @@ +# Service settings specific to this server + +# Image settings +IMAGE_REGISTRY="gitea.jde.nz" +IMAGE_REPO="j/simple-object-storage" +IMAGE_TAG="latest" + +# Container settings +CONTAINER_NAME="simple-object-storage" + +# Volume settings +VOLUME_NAME="simple-object-storage" diff --git a/simple-object-storage/backup.sh b/simple-object-storage/backup.sh new file mode 100644 index 0000000..330afce --- /dev/null +++ b/simple-object-storage/backup.sh @@ -0,0 +1,13 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars "VOLUME_NAME" "BACKUP_FILE" "TEMP_DIR" + +# Simple Object Storage Backup Script +# Creates a backup tarball of the volume contents. + + + +# HOT backup is fine for simple-object-storage +autobackup "volume=${VOLUME_NAME}" || _die "Failed to create backup" + +echo "Backup complete: ${BACKUP_FILE}" diff --git a/simple-object-storage/config/.template_info.env b/simple-object-storage/config/.template_info.env new file mode 100644 index 0000000..1c2ba83 --- /dev/null +++ b/simple-object-storage/config/.template_info.env @@ -0,0 +1,2 @@ +# Template to use - always required! +TEMPLATE=simple-object-storage diff --git a/simple-object-storage/config/service.env b/simple-object-storage/config/service.env new file mode 100644 index 0000000..dd27f69 --- /dev/null +++ b/simple-object-storage/config/service.env @@ -0,0 +1,4 @@ +# note the port and write tokens are not set here, they are set in the sos_config.json file. + +CONTAINER_NAME="simple-object-storage" +VOLUME_NAME="simple-object-storage" diff --git a/simple-object-storage/config/sos_config.json b/simple-object-storage/config/sos_config.json new file mode 100644 index 0000000..42d55d7 --- /dev/null +++ b/simple-object-storage/config/sos_config.json @@ -0,0 +1,8 @@ +{ + "write_tokens": [ + "fizzle1", + "fizzle2", + "fizzle3" + ], + "port": 8123 +} diff --git a/simple-object-storage/install.sh b/simple-object-storage/install.sh new file mode 100644 index 0000000..f0fc364 --- /dev/null +++ b/simple-object-storage/install.sh @@ -0,0 +1,25 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars + +# Simple Object Storage Install Script +# Pulls image, creates volume/config, starts container. + +autocreate "volume=${VOLUME_NAME}" + +# check can pull image on remote host and exit if fails +echo "Pulling 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" + +echo "Stopping and removing any existing container..." +bash ./stop.sh || _die "Failed to stop container ${CONTAINER_NAME}" +_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}" +bash ./start.sh || _die "Failed to start container ${CONTAINER_NAME}" +echo "Installation complete for service ${CONTAINER_NAME}." + +# determine port. +command -v jq &> /dev/null || _die "jq could not be found, please install it" +[ -f "${CONFIG_PATH}/sos_config.json" ] || _die "sos_config.json does not exist" +PORT=$(jq -r '.port' "${CONFIG_PATH}/sos_config.json") + +echo "You can access the service at http://${HOST_NAME}:${PORT}" diff --git a/simple-object-storage/logs.sh b/simple-object-storage/logs.sh new file mode 100644 index 0000000..71945d6 --- /dev/null +++ b/simple-object-storage/logs.sh @@ -0,0 +1,13 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars + +# Simple Object Storage Logs Script +# Shows the logs for the running container. + + + +echo "Showing logs for ${CONTAINER_NAME}... (Press Ctrl+C to stop)" +_grey_start +_get_container_logs $CONTAINER_NAME +_grey_end diff --git a/simple-object-storage/nuke.sh b/simple-object-storage/nuke.sh new file mode 100644 index 0000000..9caebee --- /dev/null +++ b/simple-object-storage/nuke.sh @@ -0,0 +1,11 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars + +# Simple Object Storage Nuke Script +# Removes container AND volume. + + +autonuke "volume=${VOLUME_NAME}" || _die "Failed to nuke volume ${VOLUME_NAME}" + +echo "Nuke complete for service ${CONTAINER_NAME}." diff --git a/simple-object-storage/ports.sh b/simple-object-storage/ports.sh new file mode 100644 index 0000000..b3dbbc2 --- /dev/null +++ b/simple-object-storage/ports.sh @@ -0,0 +1,19 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars "CONFIG_PATH" + +# PORT SCRIPT +# The port script is OPTIONAL. +# It is used to return the ports used by the service. +# It is called with the path to the server specific env file as an argument. + + +# Required environment variables + +# determine port. +command -v jq &> /dev/null || _die "jq could not be found, please install it" +[ -f "${CONFIG_PATH}/sos_config.json" ] || _die "sos_config.json does not exist" +PORT=$(jq -r '.port' "${CONFIG_PATH}/sos_config.json") + +echo $PORT + diff --git a/simple-object-storage/restore.sh b/simple-object-storage/restore.sh new file mode 100644 index 0000000..4cf61e4 --- /dev/null +++ b/simple-object-storage/restore.sh @@ -0,0 +1,21 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" || _die "Failed to source _common.sh" +_check_required_env_vars "BACKUP_FILE" "TEMP_DIR" "VOLUME_NAME" "CONTAINER_NAME" + +# Simple Object Storage Restore Script +# Restores data from a backup file. + + + +echo "Uninstalling service before restore..." +bash ./uninstall.sh || _die "Failed to uninstall service before restore" + +echo "Restoring data for ${CONTAINER_NAME} from ${BACKUP_FILE}..." + +autorestore "volume=${VOLUME_NAME}" || _die "Failed to restore data from backup file" + +echo "Restore complete. Reinstalling service..." + +bash ./install.sh || _die "Failed to reinstall service after restore" + +echo "Service ${CONTAINER_NAME} restored and reinstalled." diff --git a/simple-object-storage/ssh.sh b/simple-object-storage/ssh.sh new file mode 100644 index 0000000..b99e9cb --- /dev/null +++ b/simple-object-storage/ssh.sh @@ -0,0 +1,17 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars + +# Simple Object Storage SSH Script +# Opens a shell in the running container. + + + +if ! _is_container_running $CONTAINER_NAME; then + _die "Container ${CONTAINER_NAME} is not running. Can't connect to it." +fi + +echo "Connecting to container ${CONTAINER_NAME}..." +docker exec -it "${CONTAINER_NAME}" /bin/bash + +echo "Disconnected from ${CONTAINER_NAME}" diff --git a/simple-object-storage/start.sh b/simple-object-storage/start.sh new file mode 100644 index 0000000..fc3b8f6 --- /dev/null +++ b/simple-object-storage/start.sh @@ -0,0 +1,38 @@ +#!/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 volume exists. +if ! docker volume inspect "${VOLUME_NAME}" &>/dev/null; then + _die "Docker volume ${VOLUME_NAME} does not exist" +fi + +# determine port. +command -v jq &> /dev/null || _die "jq could not be found, please install it" +[ -f "${CONFIG_PATH}/sos_config.json" ] || _die "sos_config.json does not exist" +PORT=$(jq -r '.port' "${CONFIG_PATH}/sos_config.json") + + +DOCKER_RUN_CMD="docker run -d \ + --restart unless-stopped \ + --name ${CONTAINER_NAME} \ + -p ${PORT}:${PORT} \ + -v ${VOLUME_NAME}:/data/storage \ + -v ${CONFIG_PATH}/sos_config.json:/data/sos_config.json:ro \ + ${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}" + + +if ! _create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then + _die "Failed to start container ${CONTAINER_NAME}" +fi + +# Check if the container is running +if ! _is_container_running "$CONTAINER_NAME"; then + _die "Container ${CONTAINER_NAME} is not running" +fi + +echo "Container ${CONTAINER_NAME} started" diff --git a/simple-object-storage/status.sh b/simple-object-storage/status.sh new file mode 100644 index 0000000..26e96c5 --- /dev/null +++ b/simple-object-storage/status.sh @@ -0,0 +1,22 @@ +#!/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 if the service is running +_is_container_running $CONTAINER_NAME || _die "Service is not running - did not find container $CONTAINER_NAME." + +# determine port. +command -v jq &> /dev/null || _die "jq could not be found, please install it" +[ -f "${CONFIG_PATH}/sos_config.json" ] || _die "sos_config.json does not exist" +PORT=$(jq -r '.port' "${CONFIG_PATH}/sos_config.json") + +# check if the service is healthy +curl -s -X GET http://localhost:${PORT}/status | jq -e '.result == "success"' \ + || _die "Service is not healthy - did not get OK response from /status endpoint." + +echo "Service is healthy" +exit 0 diff --git a/simple-object-storage/stop.sh b/simple-object-storage/stop.sh new file mode 100644 index 0000000..98b8169 --- /dev/null +++ b/simple-object-storage/stop.sh @@ -0,0 +1,12 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars + +# Simple Object Storage Stop Script +# Stops the running container. + + + +echo "Stopping service ${CONTAINER_NAME}..." +_stop_container $CONTAINER_NAME || _die "Failed to stop container ${CONTAINER_NAME}" +echo "Service ${CONTAINER_NAME} stopped." diff --git a/simple-object-storage/uninstall.sh b/simple-object-storage/uninstall.sh new file mode 100644 index 0000000..31fad56 --- /dev/null +++ b/simple-object-storage/uninstall.sh @@ -0,0 +1,19 @@ +#!/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. + + +_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}" +_is_container_running && _die "Couldn't stop existing container" +_is_container_exists && _die "Couldn't remove existing container" + +# remove the image +docker rmi "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || echo "Failed to remove image $IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" + +echo "Uninstallation of ${CONTAINER_NAME} complete." +echo "Data volume ${VOLUME_NAME} still in place." diff --git a/squashkiwi/_default.env b/squashkiwi/_default.env new file mode 100644 index 0000000..d1c0279 --- /dev/null +++ b/squashkiwi/_default.env @@ -0,0 +1,10 @@ +# Application settings +CONTAINER_PORT=8181 + +# Deployment settings +CONTAINER_NAME="squashkiwi" + +# Image settings +IMAGE_REGISTRY="gitea.jde.nz" +IMAGE_REPO="squashkiwi/squashkiwi" +IMAGE_TAG="latest" diff --git a/squashkiwi/backup.sh b/squashkiwi/backup.sh new file mode 100755 index 0000000..cede869 --- /dev/null +++ b/squashkiwi/backup.sh @@ -0,0 +1,13 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER" "BACKUP_FILE" "TEMP_DIR" + +# Stop container before backup +_stop_container "$CONTAINER_NAME" + +autobackup "path=${LOCAL_DATA_FOLDER}" || _die "Failed to create backup" + +# Start container after backup +_start_container "$CONTAINER_NAME" + +echo "Backup created successfully" diff --git a/squashkiwi/config/.template_info.env b/squashkiwi/config/.template_info.env new file mode 100644 index 0000000..ab4665d --- /dev/null +++ b/squashkiwi/config/.template_info.env @@ -0,0 +1,2 @@ +# Template to use - always required! +TEMPLATE=squashkiwi diff --git a/squashkiwi/config/service.env b/squashkiwi/config/service.env new file mode 100644 index 0000000..e9a710a --- /dev/null +++ b/squashkiwi/config/service.env @@ -0,0 +1,6 @@ +# Service settings specific to this server +# (can also override anything in the _basic.env file in the template to make it specific to this server) + +HOST_PORT=80 +LOCAL_DATA_FOLDER="/home/dropshell/example-squashkiwi" +IMAGE_TAG="latest" diff --git a/squashkiwi/install.sh b/squashkiwi/install.sh new file mode 100755 index 0000000..561148b --- /dev/null +++ b/squashkiwi/install.sh @@ -0,0 +1,18 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "CONTAINER_NAME" "LOCAL_DATA_FOLDER" + +autocreate path=$LOCAL_DATA_FOLDER || _die "Failed to create local data folder" + +# Test Docker +_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" + +# remove and restart, as the env may have changed. +bash ./stop.sh || _die "Failed to stop container ${CONTAINER_NAME}" +_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}" +bash ./start.sh || _die "Failed to start container ${CONTAINER_NAME}" + +echo "Installation of ${CONTAINER_NAME} complete" diff --git a/squashkiwi/logs.sh b/squashkiwi/logs.sh new file mode 100755 index 0000000..2efa469 --- /dev/null +++ b/squashkiwi/logs.sh @@ -0,0 +1,8 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars "CONTAINER_NAME" + +echo "Container ${CONTAINER_NAME} logs:" +_grey_start +docker logs "${CONTAINER_NAME}" +_grey_end diff --git a/squashkiwi/nuke.sh b/squashkiwi/nuke.sh new file mode 100755 index 0000000..d3e4cc0 --- /dev/null +++ b/squashkiwi/nuke.sh @@ -0,0 +1,8 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars "LOCAL_DATA_FOLDER" + +autonuke "path=${LOCAL_DATA_FOLDER}" || _die "Failed to nuke ${LOCAL_DATA_FOLDER}" + +echo "Nuke of ${CONTAINER_NAME} complete" + diff --git a/squashkiwi/ports.sh b/squashkiwi/ports.sh new file mode 100755 index 0000000..8178ba0 --- /dev/null +++ b/squashkiwi/ports.sh @@ -0,0 +1,5 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars "HOST_PORT" + +echo $HOST_PORT diff --git a/squashkiwi/restore.sh b/squashkiwi/restore.sh new file mode 100755 index 0000000..5d59bf9 --- /dev/null +++ b/squashkiwi/restore.sh @@ -0,0 +1,18 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER" "BACKUP_FILE" "TEMP_DIR" + +# 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. + +# # Stop container before backup +bash ./uninstall.sh || _die "Failed to uninstall service before restore" + +autorestore "path=${LOCAL_DATA_FOLDER}" || _die "Failed to restore data folder from backup" + +# reinstall service +bash ./install.sh || _die "Failed to reinstall service after restore" + +echo "Restore complete! Service is running again on port $HOST_PORT with restored website." diff --git a/squashkiwi/ssh.sh b/squashkiwi/ssh.sh new file mode 100755 index 0000000..3357154 --- /dev/null +++ b/squashkiwi/ssh.sh @@ -0,0 +1,13 @@ +#!/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." +fi + +echo "Connecting to ${CONTAINER_NAME}..." + +docker exec -it ${CONTAINER_NAME} bash + +echo "Disconnected from ${CONTAINER_NAME}" diff --git a/squashkiwi/start.sh b/squashkiwi/start.sh new file mode 100755 index 0000000..54a6bac --- /dev/null +++ b/squashkiwi/start.sh @@ -0,0 +1,24 @@ +#!/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" + + +DOCKER_RUN_CMD="docker run -d \ + --restart unless-stopped \ + --name ${CONTAINER_NAME} \ + -p ${HOST_PORT}:${CONTAINER_PORT} \ + -v ${LOCAL_DATA_FOLDER}:/skdata \ + ${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}" + + +if ! _create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then + echo "${DOCKER_RUN_CMD}" + _die "Failed to start container ${CONTAINER_NAME}" +fi + +# Check if the container is running +if ! _is_container_running "$CONTAINER_NAME"; then + _die "Container ${CONTAINER_NAME} is not running" +fi + +echo "Container ${CONTAINER_NAME} started, on port ${HOST_PORT}" diff --git a/squashkiwi/status.sh b/squashkiwi/status.sh new file mode 100755 index 0000000..d02d18f --- /dev/null +++ b/squashkiwi/status.sh @@ -0,0 +1,13 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_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." + +# 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 diff --git a/squashkiwi/stop.sh b/squashkiwi/stop.sh new file mode 100755 index 0000000..f908886 --- /dev/null +++ b/squashkiwi/stop.sh @@ -0,0 +1,7 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars "CONTAINER_NAME" + +_stop_container $CONTAINER_NAME || _die "Failed to stop container ${CONTAINER_NAME}" + +echo "Container ${CONTAINER_NAME} stopped" diff --git a/squashkiwi/uninstall.sh b/squashkiwi/uninstall.sh new file mode 100755 index 0000000..f324a25 --- /dev/null +++ b/squashkiwi/uninstall.sh @@ -0,0 +1,16 @@ +#!/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. + + +_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}" +_is_container_running && _die "Couldn't stop existing container" +_is_container_exists && _die "Couldn't remove existing container" + +echo "Uninstallation of ${CONTAINER_NAME} complete." +echo "Local data folder ${LOCAL_DATA_FOLDER} still in place." diff --git a/test_template.sh b/test_template.sh new file mode 100755 index 0000000..a760952 --- /dev/null +++ b/test_template.sh @@ -0,0 +1,96 @@ +#!/bin/bash +SCRIPT_DIR=$(dirname "$0") + +# default config should always work for localhost + +function die() { + echo "$1" + exit 1 +} + +function dashes() { + for ((i=0; i<$1; i++)); do + echo -n "-" + done + echo "" +} + +function centerprint() { + # print $1 centered + local width=$2 + local padding=$(( (width - ${#1}) / 2 )) + for ((i=0; i<$padding; i++)); do + echo -n " " + done + + echo "$1" +} + +function title() { + # determine terminal width + TERMINAL_WIDTH=$(tput cols) + + echo " " + dashes $TERMINAL_WIDTH + centerprint "$1" $TERMINAL_WIDTH + dashes $TERMINAL_WIDTH +} + +# do we have the first argument? +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +TEMPLATE=$(basename "$1") + +if [ ! -d "$SCRIPT_DIR/$TEMPLATE" ]; then + echo "Local Template $TEMPLATE does not exist" + exit 1 +fi + +# for now, we need to build and locally install to test the template. Check if it's up to date. + +title "Checking template $TEMPLATE" + +SERVICE_NAME="test-$TEMPLATE" + +title "Nuking old service" +ds fullnuke localhost $SERVICE_NAME || die "Failed to fullnuke old service" + +title "Creating service" +ds create-service localhost $TEMPLATE $SERVICE_NAME || die "Failed to create service" + +title "Installing service" +ds install localhost $SERVICE_NAME || die "Failed to install service" + +title "Stopping service" +ds stop localhost $SERVICE_NAME || die "Failed to stop service" + +title "Starting service" +ds start localhost $SERVICE_NAME || die "Failed to start service" + +title "Listing services" +ds list localhost || die "Failed to list services" + +title "Backing up service" +ds backup localhost $SERVICE_NAME || die "Failed to backup service" + +title "Restoring service" +ds restore localhost $SERVICE_NAME latest || die "Failed to restore service" + +title "Checking status" +ds status localhost $SERVICE_NAME || die "Failed to check status" + +title "Nuking service" +ds nuke localhost $SERVICE_NAME || die "Failed to nuke service" + +title "Listing services" +ds list localhost || die "Failed to list services" + + +# change to green font +echo -e "\033[32m" +title "ALL TESTS PASSED FOR $TEMPLATE" +echo -e "\033[0m" +echo " " diff --git a/watchtower/_default.env b/watchtower/_default.env new file mode 100644 index 0000000..ee38801 --- /dev/null +++ b/watchtower/_default.env @@ -0,0 +1,11 @@ +# Service settings +CONTAINER_NAME=watchtower + +# Interval in seconds between checks. +# Default is 1800 seconds (30 minutes). +INTERVAL=1800 + +# Image settings +IMAGE_REGISTRY="docker.io" +IMAGE_REPO="containrrr/watchtower" +IMAGE_TAG="latest" diff --git a/watchtower/config/.template_info.env b/watchtower/config/.template_info.env new file mode 100644 index 0000000..8109ee4 --- /dev/null +++ b/watchtower/config/.template_info.env @@ -0,0 +1,3 @@ +# Template to use - always required! +TEMPLATE=watchtower + diff --git a/watchtower/config/config.json b/watchtower/config/config.json new file mode 100644 index 0000000..a5270d1 --- /dev/null +++ b/watchtower/config/config.json @@ -0,0 +1,5 @@ +{ + "auths": { + + } +} diff --git a/watchtower/config/service.env b/watchtower/config/service.env new file mode 100644 index 0000000..7dc17c5 --- /dev/null +++ b/watchtower/config/service.env @@ -0,0 +1,6 @@ +# Service settings specific to this server +# (can also override anything in the _basic.env file in the template to make it specific to this server) + +# Interval in seconds between checks. +# Default is 1800 seconds (30 minutes). +INTERVAL=1800 \ No newline at end of file diff --git a/watchtower/install.sh b/watchtower/install.sh new file mode 100644 index 0000000..cca77cb --- /dev/null +++ b/watchtower/install.sh @@ -0,0 +1,21 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" + +# Watchtower Install Script + +echo "Checking Docker installation..." +_check_docker_installed || _die "Docker test failed, aborting installation..." + +echo "Pulling 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" + +echo "Stopping and removing any existing container..." +# No need to check failure, might not exist +_stop_container $CONTAINER_NAME +_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}" + +echo "Starting container..." +bash ./start.sh $1 || _die "Failed to start container ${CONTAINER_NAME}" + +echo "Installation complete for service ${CONTAINER_NAME}." diff --git a/watchtower/logs.sh b/watchtower/logs.sh new file mode 100644 index 0000000..cb35945 --- /dev/null +++ b/watchtower/logs.sh @@ -0,0 +1,10 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars "CONTAINER_NAME" + +# Watchtower Logs Script + +echo "Showing logs for ${CONTAINER_NAME}... (Press Ctrl+C to stop)" +_grey_start +_get_container_logs $CONTAINER_NAME +_grey_end diff --git a/watchtower/start.sh b/watchtower/start.sh new file mode 100644 index 0000000..89cf7ca --- /dev/null +++ b/watchtower/start.sh @@ -0,0 +1,34 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars + +# Watchtower Start Script + +# Optional arguments (e.g., --cleanup, --monitor-only) +EXTRA_ARGS=$1 + +DOCKER_RUN_CMD="docker run -d \ + --name ${CONTAINER_NAME} \ + --restart=always \ + -v /var/run/docker.sock:/var/run/docker.sock \ + ${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG} \ + --interval ${INTERVAL} ${EXTRA_ARGS}" + +echo "Starting container ${CONTAINER_NAME}..." + +if ! _create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then + # If creation/start failed, attempt to display logs if container exists + if _is_container_exists $CONTAINER_NAME; then + echo "Attempting to get logs from failed container..." + _get_container_logs $CONTAINER_NAME + fi + _die "Failed to start container ${CONTAINER_NAME}" +fi + +# Check if the container is running after successful start command +if ! _is_container_running "$CONTAINER_NAME"; then + _get_container_logs $CONTAINER_NAME # Show logs if it immediately exited + _die "Container ${CONTAINER_NAME} is not running after start attempt" +fi + +echo "Service ${CONTAINER_NAME} started successfully." diff --git a/watchtower/status.sh b/watchtower/status.sh new file mode 100644 index 0000000..d389f10 --- /dev/null +++ b/watchtower/status.sh @@ -0,0 +1,13 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars "CONTAINER_NAME" + +# Watchtower Status Script + +_is_container_running $CONTAINER_NAME || _die "Service is not running - did not find container $CONTAINER_NAME." + +# Optional: Add specific health checks for Watchtower if needed. +# For example, check logs for recent activity or errors. + +echo "Service ${CONTAINER_NAME} is running." +exit 0 diff --git a/watchtower/stop.sh b/watchtower/stop.sh new file mode 100644 index 0000000..7f336ad --- /dev/null +++ b/watchtower/stop.sh @@ -0,0 +1,9 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars + +# Watchtower Stop Script + +echo "Stopping service ${CONTAINER_NAME}..." +_stop_container $CONTAINER_NAME || _die "Failed to stop container ${CONTAINER_NAME}" +echo "Service ${CONTAINER_NAME} stopped." diff --git a/watchtower/uninstall.sh b/watchtower/uninstall.sh new file mode 100644 index 0000000..cb839c2 --- /dev/null +++ b/watchtower/uninstall.sh @@ -0,0 +1,13 @@ +#!/bin/bash +source "${AGENT_PATH}/_common.sh" +_check_required_env_vars + +# Watchtower Uninstall Script + +echo "Uninstalling service ${CONTAINER_NAME}..." +_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}" + +echo "Service ${CONTAINER_NAME} uninstalled." + +# Note: Watchtower doesn't typically have volumes to nuke. +