diff --git a/src/freedombone-app-etherpad b/src/freedombone-app-etherpad index 3cf438000ec8a5006fb00fdb947190976637fd43..614c74547abedfd82e05ea91d0653bee8a920761 100755 --- a/src/freedombone-app-etherpad +++ b/src/freedombone-app-etherpad @@ -52,6 +52,35 @@ etherpad_variables=(ETHERPAD_COMMIT DDNS_PROVIDER MY_USERNAME) +function get_mariadb_etherpad_admin_password { + if [ -f /home/$MY_USERNAME/README ]; then + if grep -q "MariaDB etherpad admin password" /home/$MY_USERNAME/README; then + ETHERPAD_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "MariaDB etherpad admin password" | awk -F ':' '{print $2}' | sed 's/^ *//') + fi + if grep -q "etherpad administrator password" /home/$MY_USERNAME/README; then + ETHERPAD_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "etherpad administrator password" | awk -F ':' '{print $2}' | sed 's/^ *//') + fi + fi +} + +function etherpad_create_database { + function_check get_mariadb_etherpad_admin_password + get_mariadb_etherpad_admin_password + if [ ! $ETHERPAD_ADMIN_PASSWORD ]; then + if [ -f $IMAGE_PASSWORD_FILE ]; then + ETHERPAD_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" + else + ETHERPAD_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})" + fi + fi + if [ ! $ETHERPAD_ADMIN_PASSWORD ]; then + return + fi + + function_check create_database + create_database etherpad "$ETHERPAD_ADMIN_PASSWORD" $MY_USERNAME +} + function create_etherpad_settings { echo '{' > /var/www/$ETHERPAD_DOMAIN_NAME/htdocs/settings.json echo " \"title\": \"${ETHERPAD_TITLE}\"," >> /var/www/$ETHERPAD_DOMAIN_NAME/htdocs/settings.json