start.sh 1.31 KB
Newer Older
Felix Bartels's avatar
Felix Bartels committed
1 2 3 4
#!/bin/bash

set -eu

Ian Fijolek's avatar
Ian Fijolek committed
5
echo "=> Exporting env vars expected by Bitwarden"
Johannes Zellner's avatar
Johannes Zellner committed
6 7 8
export DOMAIN=$CLOUDRON_APP_ORIGIN
export SMTP_HOST=$CLOUDRON_MAIL_SMTP_SERVER
export SMTP_FROM=$CLOUDRON_MAIL_FROM
Felix Bartels's avatar
Felix Bartels committed
9
export SMTP_FROM_NAME=Bitwarden
Ian Fijolek's avatar
Ian Fijolek committed
10
export SMTP_PORT=$CLOUDRON_MAIL_SMTP_PORT
11 12
export SMTP_SSL=false
export SMTP_EXPLICIT_TLS=false
Johannes Zellner's avatar
Johannes Zellner committed
13 14
export SMTP_USERNAME=$CLOUDRON_MAIL_SMTP_USERNAME
export SMTP_PASSWORD=$CLOUDRON_MAIL_SMTP_PASSWORD
15 16
export SMTP_AUTH_MECHANISM="Plain"
export LOG_LEVEL=debug
17

18 19 20 21 22
# Generate admin token if it doesn't exist
if [[ ! -f /app/data/admin_token ]]; then
    pwgen -1 48 -s > /app/data/admin_token
fi
export ADMIN_TOKEN=$(cat /app/data/admin_token)
23
echo "=> Admin token: ${ADMIN_TOKEN}"
24

Ian Fijolek's avatar
Ian Fijolek committed
25 26
echo "=> Generate LDAP config"
# Generate ldap sync config from template
Ian Fijolek's avatar
Ian Fijolek committed
27 28 29 30 31
sed -e "s/##LDAP_SERVER/${CLOUDRON_LDAP_SERVER}/"\
    -e "s/##LDAP_PORT/${CLOUDRON_LDAP_PORT}/"\
    -e "s/##LDAP_USERS_BASE_DN/${CLOUDRON_LDAP_USERS_BASE_DN}/"\
    -e "s/##LDAP_BIND_DN/${CLOUDRON_LDAP_BIND_DN}/"\
    -e "s/##LDAP_BIND_PASSWORD/${CLOUDRON_LDAP_BIND_PASSWORD}/"\
Ian Fijolek's avatar
Ian Fijolek committed
32 33 34
    -e "s/##BITWARDEN_HOSTNAME/${CLOUDRON_APP_HOSTNAME}/"\
    -e "s/##ADMIN_TOKEN/${ADMIN_TOKEN}/"\
    /app/code/ldap_config.template.toml > /run/ldap_config.toml
35

36 37
echo "=> Starting supervisord"
exec /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i Bitwarden