Dropshell basic templates (WIP)
This commit is contained in:
11
watchtower/_default.env
Normal file
11
watchtower/_default.env
Normal file
@ -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"
|
3
watchtower/config/.template_info.env
Normal file
3
watchtower/config/.template_info.env
Normal file
@ -0,0 +1,3 @@
|
||||
# Template to use - always required!
|
||||
TEMPLATE=watchtower
|
||||
|
5
watchtower/config/config.json
Normal file
5
watchtower/config/config.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"auths": {
|
||||
|
||||
}
|
||||
}
|
6
watchtower/config/service.env
Normal file
6
watchtower/config/service.env
Normal file
@ -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
|
21
watchtower/install.sh
Normal file
21
watchtower/install.sh
Normal file
@ -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}."
|
10
watchtower/logs.sh
Normal file
10
watchtower/logs.sh
Normal file
@ -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
|
34
watchtower/start.sh
Normal file
34
watchtower/start.sh
Normal file
@ -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."
|
13
watchtower/status.sh
Normal file
13
watchtower/status.sh
Normal file
@ -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
|
9
watchtower/stop.sh
Normal file
9
watchtower/stop.sh
Normal file
@ -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."
|
13
watchtower/uninstall.sh
Normal file
13
watchtower/uninstall.sh
Normal file
@ -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.
|
||||
|
Reference in New Issue
Block a user