#!/bin/bash set -xeo pipefail if [ ! -f /fdroid/host_ssh/ssh_host_rsa_key ]; then echo "Generating host SSH key..." mkdir -p /fdroid/host_ssh ssh-keygen -f /fdroid/host_ssh/ssh_host_rsa_key -N '' -t rsa chown fdroid: /fdroid/host_ssh/ssh_host_rsa_key fi mkdir -p /fdroid/.ssh if [ ! -z "${SSH_PUBLIC_KEY}" ]; then echo "${SSH_PUBLIC_KEY}" > /fdroid/.ssh/authorized_keys fi chmod 0600 /fdroid/.ssh/authorized_keys if [ ! -f /fdroid/keystore/keystore.jks ]; then keytool -genkey -noprompt \ -keyalg RSA \ -alias "${FDROID_KEYSTORE_KEY_ALIAS}" \ -dname "${FDROID_KEYSTORE_DNAME}" \ -keystore /fdroid/keystore/keystore.jks \ -storepass "${FDROID_KEYSTORE_PASS}" \ -keypass "${FDROID_KEYSTORE_KEYPASS}" fi echo "Updating configuration from environment..." envsubst < config.yml.tmpl > /fdroid/config.yml chmod 0600 /fdroid/config.yml find /fdroid -not -user fdroid | xargs chown fdroid: su fdroid /fdroid/fdroid-update.sh /usr/bin/supervisord -c /etc/supervisor.d/supervisor.ini