start.sh 1.38 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
export SMTP_AUTH_MECHANISM="Plain"
Ian Fijolek's avatar
Ian Fijolek committed
16 17
export DATABASE_URL=$CLOUDRON_MYSQL_URL
export ENABLE_DB_WAL=false
18
export LOG_LEVEL=debug
19

20 21 22 23 24
# 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)
25
echo "=> Admin token: ${ADMIN_TOKEN}"
26

Ian Fijolek's avatar
Ian Fijolek committed
27 28
echo "=> Generate LDAP config"
# Generate ldap sync config from template
Ian Fijolek's avatar
Ian Fijolek committed
29 30 31 32 33
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
34 35 36
    -e "s/##BITWARDEN_HOSTNAME/${CLOUDRON_APP_HOSTNAME}/"\
    -e "s/##ADMIN_TOKEN/${ADMIN_TOKEN}/"\
    /app/code/ldap_config.template.toml > /run/ldap_config.toml
37

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