2024-02-14 16:36:01 -03:00
|
|
|
#!/bin/bash
|
|
|
|
|
set -e
|
|
|
|
|
|
2024-07-01 16:37:44 -03:00
|
|
|
# Lets wait for the DNS container to start
|
|
|
|
|
sleep 5
|
|
|
|
|
|
2024-02-14 16:36:01 -03:00
|
|
|
# Starts each WireGuard configuration file found in /etc/wireguard
|
|
|
|
|
shopt -s nullglob
|
|
|
|
|
config_files=(/etc/wireguard/*.conf)
|
|
|
|
|
if [ ${#config_files[@]} -gt 0 ]; then
|
|
|
|
|
for f in "${config_files[@]}"; do
|
|
|
|
|
wg-quick up "$(basename "${f}" .conf)"
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Django startup
|
|
|
|
|
python manage.py migrate --noinput
|
|
|
|
|
python manage.py collectstatic --noinput
|
2026-03-15 10:16:26 -03:00
|
|
|
|
|
|
|
|
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
|
2026-01-13 20:49:32 -03:00
|
|
|
if [[ "${DEV_MODE,,}" == "true" ]]; then
|
2026-01-25 10:52:04 -03:00
|
|
|
echo ""
|
|
|
|
|
echo ""
|
|
|
|
|
echo "================================================================"
|
|
|
|
|
echo "= WARNING: DEV_MODE is enabled. Do not use this in production! ="
|
|
|
|
|
echo "================================================================"
|
|
|
|
|
echo ""
|
|
|
|
|
echo ""
|
|
|
|
|
echo "DEV_MODE=true -> Starting Django runserver"
|
|
|
|
|
exec python manage.py runserver 0.0.0.0:8000
|
2026-01-13 20:49:32 -03:00
|
|
|
else
|
|
|
|
|
echo "Starting Gunicorn"
|
|
|
|
|
exec gunicorn wireguard_webadmin.wsgi:application --bind 0.0.0.0:8000 --workers 2 --threads 2 --timeout 60 --log-level info --capture-output --access-logfile - --error-logfile -
|
|
|
|
|
fi
|