#!/usr/bin/env bash set -e echo "pnpm version: $(pnpm --version)" echo "hugo version: $(hugo version)" echo "git version: $(git -v)" echo "curl version: $(curl -V)" echo "opencode version: $(opencode --version)" echo 'Ensure opencode config dir exists.' mkdir -p "${OPENCODE_CONFIG_DIR:-/app/.config/opencode}" GIT_PATH="/app/repo" if [[ -n "$GIT_URL" ]]; then if [[ ! -d "$GIT_PATH" ]]; then echo "Cloning git repo: $GIT_URL (shallow clone)" git clone --depth 1 "$GIT_URL" "$GIT_PATH" else echo "Pull git repo: $GIT_URL" git -C "$GIT_PATH" reset --hard git -C "$GIT_PATH" pull fi if [[ -f "$GIT_PATH/.gitmodules" ]]; then echo 'Found .gitmodules, initializing submodules (shallow).' git -C "$GIT_PATH" submodule init git -C "$GIT_PATH" submodule update --recursive --depth 1 fi else echo 'GIT_URL not set, skipping git clone/pull.' fi if [[ -f "${GIT_PATH}/task" ]]; then if [[ -z "$TASK_COMMANDS" ]]; then echo 'Error: TASK_COMMANDS environment variable is required.' >&2 exit 1 fi echo 'Ensure task file is executable.' chmod +x "${GIT_PATH}/task" cd "$GIT_PATH" COMMANDS=$(echo "$TASK_COMMANDS" | tr "," "\n") for COMMAND in $COMMANDS; do echo "Run task command: $COMMAND" ./task "$COMMAND" done fi echo 'Template Caddyfile.' cat > /etc/caddy/Caddyfile <