core: remove dump_config, handle directly in config loader without booting django, don't check database
This commit is contained in:
		| @ -1,15 +0,0 @@ | |||||||
| """Output full config""" |  | ||||||
| from json import dumps |  | ||||||
|  |  | ||||||
| from django.core.management.base import BaseCommand, no_translations |  | ||||||
|  |  | ||||||
| from authentik.lib.config import CONFIG |  | ||||||
|  |  | ||||||
|  |  | ||||||
| class Command(BaseCommand):  # pragma: no cover |  | ||||||
|     """Output full config""" |  | ||||||
|  |  | ||||||
|     @no_translations |  | ||||||
|     def handle(self, *args, **options): |  | ||||||
|         """Check permissions for all apps""" |  | ||||||
|         print(dumps(CONFIG.raw, indent=4)) |  | ||||||
| @ -183,4 +183,7 @@ class ConfigLoader: | |||||||
| CONFIG = ConfigLoader() | CONFIG = ConfigLoader() | ||||||
|  |  | ||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
|  |     if len(argv) < 2: | ||||||
|  |         print(dumps(CONFIG.raw, indent=4)) | ||||||
|  |     else: | ||||||
|         print(CONFIG.y(argv[1])) |         print(CONFIG.y(argv[1])) | ||||||
|  | |||||||
							
								
								
									
										12
									
								
								lifecycle/ak
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								lifecycle/ak
									
									
									
									
									
								
							| @ -1,11 +1,12 @@ | |||||||
| #!/bin/bash -e | #!/bin/bash -e | ||||||
| python -m lifecycle.wait_for_db |  | ||||||
|  |  | ||||||
| function log { | function log { | ||||||
|     printf '{"event": "%s", "level": "info", "logger": "bootstrap"}\n' "$@" > /dev/stderr |     printf '{"event": "%s", "level": "info", "logger": "bootstrap"}\n' "$@" > /dev/stderr | ||||||
| } | } | ||||||
|  |  | ||||||
| log "Bootstrap completed" | function wait_for_db { | ||||||
|  |     python -m lifecycle.wait_for_db | ||||||
|  |     log "Bootstrap completed" | ||||||
|  | } | ||||||
|  |  | ||||||
| function check_if_root { | function check_if_root { | ||||||
|     if [[ $EUID -ne 0 ]]; then |     if [[ $EUID -ne 0 ]]; then | ||||||
| @ -58,6 +59,7 @@ function restore { | |||||||
| MODE_FILE="/tmp/authentik-mode" | MODE_FILE="/tmp/authentik-mode" | ||||||
|  |  | ||||||
| if [[ "$1" == "server" ]]; then | if [[ "$1" == "server" ]]; then | ||||||
|  |     wait_for_db | ||||||
|     echo "server" > $MODE_FILE |     echo "server" > $MODE_FILE | ||||||
|     # We only set prometheus_multiproc_dir for serer, as with the worker it just fills up the disk |     # We only set prometheus_multiproc_dir for serer, as with the worker it just fills up the disk | ||||||
|     export prometheus_multiproc_dir=/dev/shm/ |     export prometheus_multiproc_dir=/dev/shm/ | ||||||
| @ -67,8 +69,10 @@ elif [[ "$1" == "worker" ]]; then | |||||||
|     echo "worker" > $MODE_FILE |     echo "worker" > $MODE_FILE | ||||||
|     check_if_root "celery -A authentik.root.celery worker --autoscale 3,1 -E -B -s /tmp/celerybeat-schedule -Q authentik,authentik_scheduled,authentik_events" |     check_if_root "celery -A authentik.root.celery worker --autoscale 3,1 -E -B -s /tmp/celerybeat-schedule -Q authentik,authentik_scheduled,authentik_events" | ||||||
| elif [[ "$1" == "backup" ]]; then | elif [[ "$1" == "backup" ]]; then | ||||||
|  |     wait_for_db | ||||||
|     python -m manage dbbackup --clean |     python -m manage dbbackup --clean | ||||||
| elif [[ "$1" == "restore" ]]; then | elif [[ "$1" == "restore" ]]; then | ||||||
|  |     wait_for_db | ||||||
|     restore $@ |     restore $@ | ||||||
| elif [[ "$1" == "bash" ]]; then | elif [[ "$1" == "bash" ]]; then | ||||||
|     /bin/bash |     /bin/bash | ||||||
| @ -84,6 +88,8 @@ elif [[ "$1" == "healthcheck" ]]; then | |||||||
|     elif [[ $mode == "worker" ]]; then |     elif [[ $mode == "worker" ]]; then | ||||||
|         celery -A authentik.root.celery inspect ping -d celery@$HOSTNAME --timeout 5 -j |         celery -A authentik.root.celery inspect ping -d celery@$HOSTNAME --timeout 5 -j | ||||||
|     fi |     fi | ||||||
|  | elif [[ "$1" == "dump_config" ]]; then | ||||||
|  |     python -m authentik.lib.config | ||||||
| else | else | ||||||
|     python -m manage "$@" |     python -m manage "$@" | ||||||
| fi | fi | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Jens L
					Jens L