Some basics working (squashkiwi, dropshell-agent).

This commit is contained in:
Your Name
2025-05-03 23:34:05 +12:00
parent 3d9b1fa6d2
commit 77c7315b0b
50 changed files with 192 additions and 225 deletions

View File

@ -1,11 +1,11 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
check_required_env_vars
_check_required_env_vars
_stop_container "$CONTAINER_NAME"
if ! autobackup volume=$DATA_VOLUME volume=$CONFIG_VOLUME $1 $2; then
die "Failed to create backup"
_die "Failed to create backup"
fi
_start_container "$CONTAINER_NAME"

View File

@ -1,19 +1,19 @@
#!/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"
_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"
_die "Failed to autocreate volumes and paths"
fi
_check_docker_installed || die "Docker test failed, aborting installation..."
_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"
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}!"
[ -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}"
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"

View File

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

View File

@ -1,6 +1,6 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
check_required_env_vars
_check_required_env_vars
# NUKE SCRIPT
# This is run after the uninstall.sh script to delete all data.
@ -9,7 +9,7 @@ check_required_env_vars
if ! autonuke volume=$DATA_VOLUME volume=$CONFIG_VOLUME; then
die "Failed to nuke"
_die "Failed to nuke"
fi
echo "Nuking of ${CONTAINER_NAME} complete."

View File

@ -1,19 +1,19 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
check_required_env_vars
_check_required_env_vars
# RESTORE SCRIPT
# uninstall container before restore
bash ./uninstall.sh || die "Failed to uninstall service before restore"
bash ./uninstall.sh || _die "Failed to uninstall service before restore"
# restore data from backup file
if ! autorestore volume=$DATA_VOLUME volume=$CONFIG_VOLUME "$1" "$2"; then
die "Failed to restore data from backup file"
_die "Failed to restore data from backup file"
fi
# reinstall service
bash ./install.sh || die "Failed to reinstall service after restore"
bash ./install.sh || _die "Failed to reinstall service after restore"
echo "Restore complete! Service is running again."

View File

@ -1,6 +1,6 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
check_required_env_vars
_check_required_env_vars
# START SCRIPT
# The start script is required for all templates.
@ -22,12 +22,12 @@ DOCKER_RUN_CMD="docker run -d \
if ! create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then
die "Failed to start container ${CONTAINER_NAME}"
_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"
_die "Container ${CONTAINER_NAME} is not running"
fi
echo "Container ${CONTAINER_NAME} started"

View File

@ -1,6 +1,6 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
check_required_env_vars
_check_required_env_vars
# STATUS SCRIPT
# The status script is OPTIONAL.
@ -9,7 +9,7 @@ check_required_env_vars
# 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."
_is_container_running $CONTAINER_NAME || _die "Service is not running - did not find container $CONTAINER_NAME."
echo "Service is healthy"
exit 0

View File

@ -1,12 +1,12 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
check_required_env_vars
_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}"
_stop_container $CONTAINER_NAME || _die "Failed to stop container ${CONTAINER_NAME}"
echo "Container ${CONTAINER_NAME} stopped"

View File

@ -1,15 +1,15 @@
#!/bin/bash
source "${AGENT_PATH}/_common.sh"
check_required_env_vars
_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_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"