Create webmail database before restoring from backup

This commit is contained in:
Bob Mottram 2016-07-25 20:35:13 +01:00
parent 2acf8f67ce
commit cb7374a8c5
2 changed files with 181 additions and 178 deletions

View File

@ -38,6 +38,31 @@ WEBMAIL_ADMIN_PASSWORD=
WEB_PATH=/var/www
WEBMAIL_PATH=$WEB_PATH/webmail
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
WEBMAIL_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "MariaDB webmail admin password" | awk -F ':' '{print $2}' | sed 's/^ *//')
fi
fi
}
function webmail_create_database {
function_check get_mariadb_webmail_admin_password
get_mariadb_webmail_admin_password
if [ ! $WEBMAIL_ADMIN_PASSWORD ]; then
if [ -f $IMAGE_PASSWORD_FILE ]; then
WEBMAIL_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
WEBMAIL_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
fi
fi
if [ ! $WEBMAIL_ADMIN_PASSWORD ]; then
return
fi
function_check create_database
create_database webmail "$WEBMAIL_ADMIN_PASSWORD"
}
function reconfigure_webmail {
echo -n ''
}
@ -68,6 +93,9 @@ function restore_local_webmail {
fi
echo $"Restoring webmail"
function_check webmail_create_database
webmail_create_database
function_check restore_database
restore_database webmail
@ -143,17 +171,8 @@ function install_webmail {
WEBMAIL_ONION_HOSTNAME=$(add_onion_service webmail 80 ${WEBMAIL_ONION_PORT})
echo "Webmail onion domain:${WEBMAIL_ONION_HOSTNAME}" >> $COMPLETION_FILE
function_check get_mariadb_webmail_admin_password
get_mariadb_webmail_admin_password
if [ ! $WEBMAIL_ADMIN_PASSWORD ]; then
if [ -f $IMAGE_PASSWORD_FILE ]; then
WEBMAIL_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
WEBMAIL_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
fi
fi
function_check create_database
create_database webmail "$WEBMAIL_ADMIN_PASSWORD"
webmail_create_database
mysql -u root --password="$MARIADB_PASSWORD" -D webmail < $WEBMAIL_PATH/SQL/mysql.initial.sql
if [ ! -d /var/www/$DEFAULT_DOMAIN_NAME/htdocs ]; then

View File

@ -116,22 +116,6 @@ function get_mariadb_password {
fi
}
function get_mariadb_media_server_admin_password {
if [ -f /home/$MY_USERNAME/README ]; then
if grep -q "Media server administrator password" /home/$MY_USERNAME/README; then
MEDIA_SERVER_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "Media server 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
WEBMAIL_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "MariaDB webmail admin password" | awk -F ':' '{print $2}' | sed 's/^ *//')
fi
fi
}
function install_mariadb {
if grep -Fxq "install_mariadb" $COMPLETION_FILE; then
return