Add export_configs management command for WireGuard and Caddy configurations

This commit is contained in:
Eduardo Silva
2026-03-24 15:18:17 -03:00
parent 018cf1380e
commit d14615a73e
4 changed files with 39 additions and 9 deletions

16
init.sh
View File

@@ -4,6 +4,13 @@ set -e
# Lets wait for the DNS container to start
sleep 5
# Django startup
python manage.py migrate --noinput
python manage.py collectstatic --noinput
# Export WireGuard, firewall and Caddy configs before bringing up interfaces
python manage.py export_configs
# Starts each WireGuard configuration file found in /etc/wireguard
shopt -s nullglob
config_files=(/etc/wireguard/*.conf)
@@ -12,15 +19,6 @@ if [ ${#config_files[@]} -gt 0 ]; then
wg-quick up "$(basename "${f}" .conf)"
done
fi
# Django startup
python manage.py migrate --noinput
python manage.py collectstatic --noinput
if [[ "${CADDY_ENABLED,,}" == "true" ]]; then
echo "Exporting Caddy configuration (auth_policies.json, applications.json, routes.json)..."
python manage.py shell -c "from app_gateway.caddy_config_export import export_caddy_config; export_caddy_config('/caddy_json_export')" || echo "Failed to export Caddy configuration."
fi
if [[ "${DEV_MODE,,}" == "true" ]]; then
echo ""
echo ""