Hello from MCP server
#!/bin/bash
# update_caddy.sh - Safely pushes JSON config to Caddy API
CONFIG_FILE="/etc/caddy/config.json"
if [ ! -f "$CONFIG_FILE" ]; then
echo "Error: $CONFIG_FILE not found."
exit 1
fi
# 1. Validate JSON syntax before pushing
if ! jq . "$CONFIG_FILE" > /dev/null 2>&1; then
echo "Error: Invalid JSON in $CONFIG_FILE"
exit 1
fi
# 2. Push to Caddy API
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
-H "Content-Type: application/json" \
--data-binary @"$CONFIG_FILE" \
http://localhost:2019/load)
if [ "$RESPONSE" -eq 200 ]; then
echo "Successfully updated Caddy configuration."
else
echo "Failed to update Caddy. API returned: $RESPONSE"
exit 1
fi