[enh] Generate database password

This commit is contained in:
ljf 2016-12-14 11:23:57 +01:00
parent fde40cfdc5
commit 1dafd42023
2 changed files with 17 additions and 15 deletions

View file

@ -45,13 +45,6 @@
"en": "Choose a strong master admin password", "en": "Choose a strong master admin password",
"fr": "Choisissez un mot de passe maître fort pour l'administration" "fr": "Choisissez un mot de passe maître fort pour l'administration"
} }
},
{
"name": "database_password",
"ask": {
"en": "Choose a password for the 'admin' account on Odoo",
"fr": "Choisissez un mot de passe pour le compte 'admin' d'Odoo"
}
}, },
{ {
"name": "lang", "name": "lang",

View file

@ -8,7 +8,6 @@ app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
odoo_version=$YNH_APP_ARG_ODOO_VERSION odoo_version=$YNH_APP_ARG_ODOO_VERSION
admin_password=$YNH_APP_ARG_ADMIN_PASSWORD admin_password=$YNH_APP_ARG_ADMIN_PASSWORD
database_password=$YNH_APP_ARG_DATABASE_PASSWORD
lang=$YNH_APP_ARG_LANG lang=$YNH_APP_ARG_LANG
# Load common variables # Load common variables
@ -24,7 +23,10 @@ sudo yunohost app checkurl $domain -a $app \
# Remove trailing "/" for next commands # Remove trailing "/" for next commands
domain=${domain%/} domain=${domain%/}
ynh_app_setting_set "$app" domain "$domain" ynh_app_setting_set "$app" domain "$domain"
ynh_app_setting_set "$app" lang "$lang"
if [ -f /usr/bin/openerp-server ]; then if [ -f /usr/bin/openerp-server ]; then
@ -38,8 +40,17 @@ else
fi fi
echo "Installing odoo" echo "Installing odoo"
dbname=$app
dbuser=$app
# Generate random password
# Fix a bug on ynh_string_random https://github.com/YunoHost/yunohost/pull/205/commits/0d6cf499a0b858e7009245fd11a9210188047c13
dbpass=$(ynh_string_random | sed "s/\[/e/g" | sed "s/\]/e/g")
ynh_app_setting_set "$app" version "$odoo_version" ynh_app_setting_set "$app" version "$odoo_version"
ynh_app_setting_set "$app" instance "master" ynh_app_setting_set "$app" instance "master"
ynh_app_setting_set "$app" psqlpwd "$dbpass"
# Install Odoo # Install Odoo
# Prepare installation # Prepare installation
ynh_package_install curl ynh_package_install curl
@ -56,9 +67,7 @@ else
# Initialize installation # Initialize installation
ynh_package_install postgresql ynh_package_install postgresql
# This db may be unused # This db may be unused
dbuser=$app ynh_psql_create_db "$dbname" "$dbuser" "$dbpass"
dbname=$app
ynh_psql_create_db "$dbname" "$dbuser" "$database_password"
ynh_package_install odoo ynh_package_install odoo
# Install wkhtmltopdf to print PDF reports # Install wkhtmltopdf to print PDF reports
@ -72,7 +81,7 @@ else
# Set admin password # Set admin password
# TODO Support @ in password # TODO Support @ in password
sudo sed -i "s@ADMIN_PASSWORD@$admin_password@g" ../conf/openerp-server.conf sudo sed -i "s@ADMIN_PASSWORD@$admin_password@g" ../conf/openerp-server.conf
sudo sed -i "s@DATABASE_PASSWORD@$database_password@g" ../conf/openerp-server.conf sudo sed -i "s@DATABASE_PASSWORD@$dbpass@g" ../conf/openerp-server.conf
sudo cp ../conf/openerp-server.conf /etc/odoo/openerp-server.conf sudo cp ../conf/openerp-server.conf /etc/odoo/openerp-server.conf
sudo chown odoo:odoo /etc/odoo/openerp-server.conf sudo chown odoo:odoo /etc/odoo/openerp-server.conf
@ -110,7 +119,7 @@ sudo /usr/bin/openerp-server -c /etc/odoo/openerp-server.conf --stop-after-init
#sudo sed -i "s@ADMIN_PASSWORD@$admin_password@g" ../conf/install_database.py #sudo sed -i "s@ADMIN_PASSWORD@$admin_password@g" ../conf/install_database.py
#sudo sed -i "s@DOMAIN_DATABASE@${domain//./-}@g" ../conf/install_database.py #sudo sed -i "s@DOMAIN_DATABASE@${domain//./-}@g" ../conf/install_database.py
#sudo sed -i "s@DATABASE_LANG@$lang@g" ../conf/install_database.py #sudo sed -i "s@DATABASE_LANG@$lang@g" ../conf/install_database.py
#sudo sed -i "s@DATABASE_PASSWORD@$database_password@g" ../conf/install_database.py #sudo sed -i "s@DATABASE_PASSWORD@$dbpass@g" ../conf/install_database.py
#sudo python ../conf/install_database.py #sudo python ../conf/install_database.py
sudo service odoo restart sudo service odoo restart
# Setup LDAP: TO BE DONE # Setup LDAP: TO BE DONE