From 7c038bacc958a6e06f7d95f1df70a879d31faec1 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 15 Jan 2026 12:50:28 +1300 Subject: [PATCH] Add 16 files --- caddy-static/config/service.env | 14 ++++++++++++++ caddy-static/install.sh | 21 +++++++++++++++++++++ caddy-static/logs.sh | 7 +++++++ caddy-static/start.sh | 23 +++++++++++++++++++++++ caddy-static/status.sh | 11 +++++++++++ caddy-static/stop.sh | 11 +++++++++++ caddy-static/template_info.env | 8 ++++++++ caddy-static/uninstall.sh | 12 ++++++++++++ 8 files changed, 107 insertions(+) create mode 100644 caddy-static/config/service.env create mode 100755 caddy-static/install.sh create mode 100755 caddy-static/logs.sh create mode 100755 caddy-static/start.sh create mode 100755 caddy-static/status.sh create mode 100755 caddy-static/stop.sh create mode 100644 caddy-static/template_info.env create mode 100755 caddy-static/uninstall.sh diff --git a/caddy-static/config/service.env b/caddy-static/config/service.env new file mode 100644 index 0000000..f01b136 --- /dev/null +++ b/caddy-static/config/service.env @@ -0,0 +1,14 @@ +# Caddy Static - Simple HTTP static file server +# https://caddyserver.com/ + +# Server Settings +SSH_USER="dropshell" + +# Container name +CONTAINER_NAME=caddy-static + +# Port to serve on +HTTP_PORT=8080 + +# Directory on host to serve (must exist) +STATIC_DIR=/path/to/static/files diff --git a/caddy-static/install.sh b/caddy-static/install.sh new file mode 100755 index 0000000..0ca15ed --- /dev/null +++ b/caddy-static/install.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# shellcheck disable=SC1091 +source "${AGENT_PATH}/common.sh" + +_check_required_env_vars "CONTAINER_NAME" "HTTP_PORT" "STATIC_DIR" + +# Verify static directory exists +[ -d "${STATIC_DIR}" ] || _die "Static directory does not exist: ${STATIC_DIR}" + +# Pull the image +echo "Pulling Caddy image..." +docker pull caddy:alpine || _die "Failed to pull Caddy image" + +# Stop existing container if running +bash "$(dirname "${BASH_SOURCE[0]}")/stop.sh" 2>/dev/null || true + +# Start the service +bash "$(dirname "${BASH_SOURCE[0]}")/start.sh" || _die "Failed to start container" + +echo "Installation complete for ${CONTAINER_NAME}." +echo "Static files served at http://localhost:${HTTP_PORT}" diff --git a/caddy-static/logs.sh b/caddy-static/logs.sh new file mode 100755 index 0000000..9c3f8ad --- /dev/null +++ b/caddy-static/logs.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# shellcheck disable=SC1091 +source "${AGENT_PATH}/common.sh" + +_check_required_env_vars "CONTAINER_NAME" + +docker logs -f "$CONTAINER_NAME" diff --git a/caddy-static/start.sh b/caddy-static/start.sh new file mode 100755 index 0000000..a131f3f --- /dev/null +++ b/caddy-static/start.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# shellcheck disable=SC1091 +source "${AGENT_PATH}/common.sh" + +_check_required_env_vars "CONTAINER_NAME" "HTTP_PORT" "STATIC_DIR" + +# Verify static directory exists +[ -d "${STATIC_DIR}" ] || _die "Static directory does not exist: ${STATIC_DIR}" + +# Remove existing container if stopped +_remove_container "$CONTAINER_NAME" 2>/dev/null || true + +# Start Caddy with file-server command +docker run -d \ + --name "${CONTAINER_NAME}" \ + --restart unless-stopped \ + -p "${HTTP_PORT}:80" \ + -v "${STATIC_DIR}:/srv:ro" \ + caddy:alpine \ + caddy file-server --root /srv --listen :80 \ + || _die "Failed to start container" + +echo "Started ${CONTAINER_NAME} on port ${HTTP_PORT}" diff --git a/caddy-static/status.sh b/caddy-static/status.sh new file mode 100755 index 0000000..369ca66 --- /dev/null +++ b/caddy-static/status.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# shellcheck disable=SC1091 +source "${AGENT_PATH}/common.sh" + +_check_required_env_vars "CONTAINER_NAME" + +if _is_container_running "$CONTAINER_NAME"; then + echo "Running" +else + echo "Stopped" +fi diff --git a/caddy-static/stop.sh b/caddy-static/stop.sh new file mode 100755 index 0000000..3d18508 --- /dev/null +++ b/caddy-static/stop.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# shellcheck disable=SC1091 +source "${AGENT_PATH}/common.sh" + +_check_required_env_vars "CONTAINER_NAME" + +echo "Stopping ${CONTAINER_NAME}..." + +_stop_container "$CONTAINER_NAME" + +echo "Stopped ${CONTAINER_NAME}." diff --git a/caddy-static/template_info.env b/caddy-static/template_info.env new file mode 100644 index 0000000..5a8b9f2 --- /dev/null +++ b/caddy-static/template_info.env @@ -0,0 +1,8 @@ +# Template info - AUTO GENERATED, DO NOT EDIT +TEMPLATE=caddy-static +REQUIRES_HOST_ROOT=false +REQUIRES_DOCKER=true +REQUIRES_DOCKER_ROOT=false + +# Default container name +CONTAINER_NAME=caddy-static diff --git a/caddy-static/uninstall.sh b/caddy-static/uninstall.sh new file mode 100755 index 0000000..06487b3 --- /dev/null +++ b/caddy-static/uninstall.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# shellcheck disable=SC1091 +source "${AGENT_PATH}/common.sh" + +_check_required_env_vars "CONTAINER_NAME" + +echo "Uninstalling ${CONTAINER_NAME}..." + +_remove_container "$CONTAINER_NAME" + +echo "Uninstallation of ${CONTAINER_NAME} complete." +echo "Static files preserved at original location."