From 07186f71ff347c808520c272d40cddad47a75aa2 Mon Sep 17 00:00:00 2001 From: scith Date: Wed, 16 Sep 2015 12:13:00 +0200 Subject: [PATCH] Autoinstall database --- README.md | 3 --- conf/install_database.py | 4 ++++ manifest.json | 16 ++++++++++++++++ scripts/install | 16 +++++++++++++--- 4 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 conf/install_database.py diff --git a/README.md b/README.md index 351934c..aa055fa 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,6 @@ What does not work Configuration ------------- -**Database** -- Create a database named "**subdomain-domain-ltd**" (for example "erp-test-com" if you access via erp.test.com) - **Setup LDAP** - Create a user named "template" with email "template". This user will give its permissions by default to YunoHost users so you can also give it appropriate permissions. - In "Edit Company Data" (on the logo), go to "Configuration" and add a LDAP setting diff --git a/conf/install_database.py b/conf/install_database.py new file mode 100644 index 0000000..89e85b2 --- /dev/null +++ b/conf/install_database.py @@ -0,0 +1,4 @@ +#!/usr/bin/python +import oerplib +oerp = oerplib.OERP(server='localhost') +oer.db.create_database('ADMIN_PASSWORD', 'DOMAIN_DATABASE', False, 'DATABASE_LANG', 'DATABASE_PASSWORD') \ No newline at end of file diff --git a/manifest.json b/manifest.json index 28aee2f..b0bcfed 100644 --- a/manifest.json +++ b/manifest.json @@ -35,6 +35,22 @@ "en": "Choose a strong master admin password", "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": "database_lang", + "ask": { + "en": "Choose a language for Odoo", + "fr": "Choisissez une langue pour Odoo" + }, + "choices": ["en_US", "fr_FR", "de_DE"], + "default": "en_US" } ] } diff --git a/scripts/install b/scripts/install index 2b331fc..073bd73 100644 --- a/scripts/install +++ b/scripts/install @@ -6,7 +6,8 @@ set -e domain=$1 odoo_version=$2 admin_password=$3 - +database_password=$4 +database_lang=$5 # Check domain/path availability domain=${domain}"/" @@ -57,9 +58,12 @@ else sudo cp ../conf/openerp-server.conf /etc/odoo/openerp-server.conf sudo chown odoo:odoo /etc/odoo/openerp-server.conf - # Setup LDAP + # Autoinstall the LDAP auth module sudo sed -i "s@'auto_install': False@'auto_install': True@g" /usr/lib/python2.7/dist-packages/openerp/addons/auth_ldap/__openerp__.py + # Install oerplib to manage databases + pip install oerplib + # Add services sudo yunohost service add postgresql sudo yunohost service add odoo @@ -67,7 +71,13 @@ else sudo yunohost service start odoo fi -# Setup database: TO BE DONE +# Setup database + 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@DATABASE_LANG@$database_lang@g" ../conf/install_database.py + sudo sed -i "s@DATABASE_PASSWORD@$database_password@g" ../conf/install_database.py + python ../conf/install_database.py + # Setup LDAP: TO BE DONE # Configure Nginx and reload