From b97d95b2eba7de4ecf13846de8dd9d510709fef1 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 4 Nov 2016 14:24:28 +0000 Subject: [PATCH] Create etherpad database --- src/freedombone-app-etherpad | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/freedombone-app-etherpad b/src/freedombone-app-etherpad index 3cf43800..614c7454 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