2020-09-09 22:14:59 +00:00
|
|
|
#!/bin/bash -e
|
|
|
|
python -m lifecycle.wait_for_db
|
2020-10-03 18:36:36 +00:00
|
|
|
printf '{"event": "Bootstrap completed", "level": "info", "logger": "bootstrap", "command": "%s"}\n' "$@" > /dev/stderr
|
2021-05-13 18:11:49 +00:00
|
|
|
|
|
|
|
function check_if_root {
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
|
|
printf '{"event": "Not running as root, disabling permission fixes", "level": "info", "logger": "bootstrap", "command": "%s"}\n' "$@" > /dev/stderr
|
2021-05-13 20:55:35 +00:00
|
|
|
$1
|
2021-05-13 18:11:49 +00:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
SOCKET="/var/run/docker.sock"
|
|
|
|
if [[ -e "$SOCKET" ]]; then
|
|
|
|
# Get group ID of the docker socket, so we can create a matching group and
|
|
|
|
# add ourselves to it
|
|
|
|
DOCKER_GID=$(stat -c '%g' $SOCKET)
|
2021-05-13 22:50:20 +00:00
|
|
|
getent group $DOCKER_GID || groupadd -f -g $DOCKER_GID docker
|
2021-05-13 18:11:49 +00:00
|
|
|
usermod -a -G $DOCKER_GID authentik
|
|
|
|
fi
|
|
|
|
# Fix permissions of backups and media
|
|
|
|
chown -R authentik:authentik /media /backups
|
2021-05-22 18:47:05 +00:00
|
|
|
chpst -u authentik:authentik:docker env HOME=/authentik $1
|
2021-05-13 18:11:49 +00:00
|
|
|
}
|
|
|
|
|
2020-09-09 22:14:59 +00:00
|
|
|
if [[ "$1" == "server" ]]; then
|
2021-04-18 12:47:50 +00:00
|
|
|
python -m lifecycle.migrate
|
2021-05-02 22:49:16 +00:00
|
|
|
/authentik-proxy
|
2020-09-09 22:14:59 +00:00
|
|
|
elif [[ "$1" == "worker" ]]; then
|
2021-05-13 20:55:35 +00:00
|
|
|
check_if_root "celery -A authentik.root.celery worker --autoscale 3,1 -E -B -s /tmp/celerybeat-schedule -Q authentik,authentik_scheduled,authentik_events"
|
2020-10-03 18:36:36 +00:00
|
|
|
elif [[ "$1" == "backup" ]]; then
|
|
|
|
python -m manage dbbackup --clean
|
|
|
|
elif [[ "$1" == "restore" ]]; then
|
|
|
|
python -m manage dbrestore ${@:2}
|
|
|
|
elif [[ "$1" == "bash" ]]; then
|
|
|
|
/bin/bash
|
2020-09-09 22:14:59 +00:00
|
|
|
else
|
|
|
|
python -m manage "$@"
|
|
|
|
fi
|