22 lines
801 B
Bash
Executable File
22 lines
801 B
Bash
Executable File
#!/usr/bin/env bash
|
|
###############################################################################
|
|
# caddy service.init — runs before Caddy container starts
|
|
# Ensures the Caddyfile and fragments/ directory exist where the container
|
|
# expects them (relative to this service directory).
|
|
###############################################################################
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
FRAGMENTS_DIR="${SCRIPT_DIR}/fragments"
|
|
|
|
log() { echo -e "\e[32m[CADDY-INIT]\e[0m $*"; }
|
|
|
|
mkdir -p "${FRAGMENTS_DIR}"
|
|
log "Fragments directory ready: ${FRAGMENTS_DIR}"
|
|
|
|
if [[ ! -f "${SCRIPT_DIR}/Caddyfile" ]]; then
|
|
echo -e "\e[31m[CADDY-INIT][ERROR]\e[0m Caddyfile missing at ${SCRIPT_DIR}/Caddyfile"
|
|
exit 1
|
|
fi
|
|
log "Caddyfile present at ${SCRIPT_DIR}/Caddyfile"
|