From cff0afa56a1356fa0e2c47427eb859d3e245ec9c Mon Sep 17 00:00:00 2001 From: polytan02 Date: Sat, 7 Mar 2015 13:27:36 +0000 Subject: [PATCH] MySQL database creation --- manifest.json | 11 +---------- scripts/install | 8 ++++---- scripts/remove | 9 +++++---- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/manifest.json b/manifest.json index bad1e4c..3ead178 100644 --- a/manifest.json +++ b/manifest.json @@ -40,16 +40,7 @@ }, "choices": ["Yes", "No"], "default": "Yes" - }, - { - "name": "db_pwd", - "type": "password", - "ask": { - "en": "Indicate a password fot phpBB's MySQL database", - "fr": "Choisissez un mot de passe pour la base MySQL de phpBB" - }, - "example": "strong_password" - } + } ] } } diff --git a/scripts/install b/scripts/install index 70cc332..f363eae 100644 --- a/scripts/install +++ b/scripts/install @@ -15,13 +15,13 @@ if [[ ! $? -eq 0 ]]; then exit 1 fi -#db_user=$app +db_user=$app +db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p') # Initialize database and store mysql password for upgrade #sudo yunohost app initdb $db_user -p $db_pwd -s $(readlink -e ../sources/SQL/mysql.initial.sql) -#sudo yunohost app setting rainloop mysqlpwd -v $db_pwd - -#mysql -u $db_user -p$db_pwd $db_user < ../sources/plugins/automatic_addressbook/SQL/mysql.initial.sql +sudo yunohost app initdb $db_user -p $db_pwd +sudo yunohost app setting $app mysqlpwd -v $db_pwd # Copy files to the right place final_path=/var/www/$app diff --git a/scripts/remove b/scripts/remove index 1fff30a..f94d6db 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,12 +1,13 @@ #!/bin/bash -#db_user=rainloop -#db_name=rainloop -#root_pwd=$(sudo cat /etc/yunohost/mysql) app=phpBB + +db_user=$app +db_name=$app +root_pwd=$(sudo cat /etc/yunohost/mysql) domain=$(sudo yunohost app setting $app domain) -#mysql -u root -p $root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;" +sudo mysql -u root -p $root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;" sudo rm -rf /var/www/$app sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf sudo rm -f /etc/php5/fpm/pool.d/$app.conf