From 82a8ee368a18560d26e054008c83f0a0f3eb0852 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 25 Jul 2016 19:55:51 +0100 Subject: [PATCH] Create gnusocial database before restore --- src/freedombone-app-gnusocial | 49 +++++++++++++++++++++++++--------- src/freedombone-utils-database | 11 -------- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/freedombone-app-gnusocial b/src/freedombone-app-gnusocial index d09c02da..e63c0b26 100755 --- a/src/freedombone-app-gnusocial +++ b/src/freedombone-app-gnusocial @@ -53,6 +53,35 @@ SHARINGS_THEME_COMMIT='7106c7ef03' GNUSOCIAL_NSFW_REPO="https://gitgud.io/ShitposterClub/SensitiveContent" GNUSOCIAL_NSFW_COMMIT='a096bbe0cfae9a9b177682920ffb58d32a48e136' +function get_mariadb_gnusocial_admin_password { + if [ -f /home/$MY_USERNAME/README ]; then + if grep -q "MariaDB gnusocial admin password" /home/$MY_USERNAME/README; then + MICROBLOG_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "MariaDB gnusocial admin password" | awk -F ':' '{print $2}' | sed 's/^ *//') + fi + if grep -q "Microblog administrator password" /home/$MY_USERNAME/README; then + MICROBLOG_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "Microblog administrator password" | awk -F ':' '{print $2}' | sed 's/^ *//') + fi + fi +} + +function gnusocial_create_database { + function_check get_mariadb_gnusocial_admin_password + get_mariadb_gnusocial_admin_password + if [ ! $MICROBLOG_ADMIN_PASSWORD ]; then + if [ -f $IMAGE_PASSWORD_FILE ]; then + MICROBLOG_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" + else + MICROBLOG_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})" + fi + fi + if [ ! $MICROBLOG_ADMIN_PASSWORD ]; then + return + fi + + function_check create_database + create_database gnusocial "$MICROBLOG_ADMIN_PASSWORD" $MY_USERNAME +} + function gnusocial_running_script { if ! grep -Fxq "install_gnusocial" $COMPLETION_FILE; then return @@ -130,6 +159,9 @@ function restore_local_gnusocial { cd $gnusocial_dir scripts/stopdaemons.sh + function_check gnusocial_create_database + gnusocial_create_database + restore_database gnusocial ${MICROBLOG_DOMAIN_NAME} if [ -d $temp_restore_dir ]; then rm -rf $temp_restore_dir @@ -175,6 +207,9 @@ function restore_remote_gnusocial { cd /var/www/${MICROBLOG_DOMAIN_NAME}/htdocs scripts/stopdaemons.sh + function_check gnusocial_create_database + gnusocial_create_database + function_check restore_database_from_friend restore_database_from_friend gnusocial ${MICROBLOG_DOMAIN_NAME} if [ -d /root/tempgnusocial ]; then @@ -256,18 +291,8 @@ function install_gnusocial_main { chown www-data:www-data /var/www/$MICROBLOG_DOMAIN_NAME/htdocs chmod +x /var/www/$MICROBLOG_DOMAIN_NAME/htdocs/scripts/maildaemon.php - function_check get_mariadb_gnusocial_admin_password - get_mariadb_gnusocial_admin_password - if [ ! $MICROBLOG_ADMIN_PASSWORD ]; then - if [ -f $IMAGE_PASSWORD_FILE ]; then - MICROBLOG_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" - else - MICROBLOG_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})" - fi - fi - - function_check create_database - create_database gnusocial "$MICROBLOG_ADMIN_PASSWORD" $MY_USERNAME + function_check gnusocial_create_database + gnusocial_create_database if [ ! -f "/etc/aliases" ]; then touch /etc/aliases diff --git a/src/freedombone-utils-database b/src/freedombone-utils-database index 55153f08..011c42ec 100755 --- a/src/freedombone-utils-database +++ b/src/freedombone-utils-database @@ -124,17 +124,6 @@ function get_mariadb_media_server_admin_password { fi } -function get_mariadb_gnusocial_admin_password { - if [ -f /home/$MY_USERNAME/README ]; then - if grep -q "MariaDB gnusocial admin password" /home/$MY_USERNAME/README; then - MICROBLOG_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "MariaDB gnusocial admin password" | awk -F ':' '{print $2}' | sed 's/^ *//') - fi - if grep -q "Microblog administrator password" /home/$MY_USERNAME/README; then - MICROBLOG_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "Microblog administrator password" | awk -F ':' '{print $2}' | sed 's/^ *//') - fi - fi -} - function get_mariadb_webmail_admin_password { if [ -f /home/$MY_USERNAME/README ]; then if grep -q "MariaDB webmail admin password" /home/$MY_USERNAME/README; then