#!/bin/sh
mkdir -p /var/containers/caddy
cp -f ./Caddyfile /var/containers/caddy/Caddyfile
chown -R podman:podman /var/containers/caddy
chmod +x /etc/init.d/caddy.service
rc-update add caddy.service default
rc-service caddy.service start

if [ "$1" = "reload" ]; then
  podman exec caddy caddy reload -c /etc/caddy/Caddyfile
fi