#!/bin/sh set -eu # Create configuration file from collected templates. envsubst < /etc/gotosocial/config.yaml.template > /etc/gotosocial/config.yaml # Create data directories and correct permissions for data files. chown -R gotosocial:gotosocial /var/lib/gotosocial # Initialize default condiguration if needed. if ! test -f /var/lib/gotosocial/gotosocial.db; then ( password="$(dd if=/dev/urandom | tr -dc '[:alnum:]' | head -c 50)" gosu gotosocial /usr/bin/gotosocial --config-path /etc/gotosocial/config.yaml admin account create \ --username "$GOTOSOCIAL_DEFAULT_USERNAME" --password "$password" \ --email "${GOTOSOCIAL_DEFAULT_USERNAME}@${GOTOSOCIAL_ACCOUNT_DOMAIN}" gosu gotosocial /usr/bin/gotosocial --config-path /etc/gotosocial/config.yaml admin account promote \ --username "$GOTOSOCIAL_DEFAULT_USERNAME" echo "Created an administrator user with username '$GOTOSOCIAL_DEFAULT_USERNAME' and password '$password'." echo "Make sure to change this immediately after logging in for the first time!" ) fi # Run entrypoint under specific user. exec gosu gotosocial /usr/bin/gotosocial --config-path /etc/gotosocial/config.yaml server start "$@"