(echo "" > /home/soenke/docker/caddy/newCaddyfile)
(cd "/home/soenke/docker/" )
echo "Collecting Caddyfileparts"
for dir in *; do
  if [ -d "$dir" ]; then
    ( cd "$dir" && cat Caddyfilepart >> /home/soenke/docker/caddy/newCaddyfile)
  fi
  echo -en '\n' >> /home/soenke/docker/caddy/newCaddyfile
done

( cd "/home/soenke/docker/caddy/" )

echo "Replace Caddyfile"

( mv /home/soenke/docker/caddy/Caddyfile /home/soenke/docker/caddy/Caddyfile.bak)
( mv /home/soenke/docker/caddy/newCaddyfile /home/soenke/docker/caddy/Caddyfile)

echo "Restart Caddy"
( cd "/home/soenke/docker/caddy/" && docker compose down && docker compose pull && docker compose up -d)
