Merge pull request #1 from zamentur/24compat

[enh] Adapt for yunohost 2.4
This commit is contained in:
Jeff 2016-07-06 11:45:59 +02:00 committed by GitHub
commit 201b7152a9
6 changed files with 133 additions and 60 deletions

View file

@ -1,10 +1,11 @@
[options] [options]
; This is the password that allows database operations: ; This is the password that allows database operations:
without_demo = all
admin_passwd = ADMIN_PASSWORD admin_passwd = ADMIN_PASSWORD
db_host = False db_host = false
db_port = False db_port = false
db_user = odoo db_user = odoo
db_password = False db_password = DATABASE_PASSWORD
addons_path = /usr/lib/python2.7/dist-packages/openerp/addons addons_path = /usr/lib/python2.7/dist-packages/openerp/addons
proxy_mode = true proxy_mode = true
dbfilter = %h dbfilter = %h

View file

@ -1,6 +1,7 @@
{ {
"name": "Odoo", "name": "Odoo",
"id": "odoo", "id": "odoo",
"packaging_format": 1,
"description": { "description": {
"en": "Odoo is a suite of business apps (ERP: CRM, Accounting, Point of Sale, HR, Purchases...).", "en": "Odoo is a suite of business apps (ERP: CRM, Accounting, Point of Sale, HR, Purchases...).",
"fr": "Odoo est une collection d'apps de gestion d'entreprise (ERP : CRM, Comptabilité, Point de Vente, RH, Achats, ...)." "fr": "Odoo est une collection d'apps de gestion d'entreprise (ERP : CRM, Comptabilité, Point de Vente, RH, Achats, ...)."
@ -8,7 +9,13 @@
"developer": { "developer": {
"name": "scith" "name": "scith"
}, },
"requirements": {
"yunohost": ">> 2.4.0"
},
"multi_instance": "true", "multi_instance": "true",
"services": [
"nginx"
],
"arguments": { "arguments": {
"install" : [ "install" : [
{ {
@ -44,7 +51,7 @@
} }
}, },
{ {
"name": "database_lang", "name": "lang",
"ask": { "ask": {
"en": "Choose a language for Odoo", "en": "Choose a language for Odoo",
"fr": "Choisissez une langue pour Odoo" "fr": "Choisissez une langue pour Odoo"

View file

@ -1,3 +1,24 @@
#! /bin/bash #! /bin/bash
app=odoo
# TO BE DONE # Exit on command errors and treat unset variables as an error
set -eu
# See comments in install script
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
. /usr/share/yunohost/helpers
# Backup sources & data
ynh_backup "/usr/lib/python2.7/dist-packages/openerp/" "sources"
# Copy NGINX configuration
domain=$(ynh_app_setting_get "$app" domain)
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
ynh_backup "/etc/odoo/openerp-server.conf" "openerp-server.conf"
# Copy database
database=${domain//./-}
sudo su -c "pg_dump $database" postgres > ./dump.sql
pwd=`pwd`
ynh_backup "$pwd/dump.sql" "dump.sql"

View file

@ -1,15 +1,18 @@
#!/bin/bash #!/bin/bash
app=odoo
set -e set -eu
app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments # Retrieve arguments
domain=$1 domain=$YNH_APP_ARG_DOMAIN
odoo_version=$2 odoo_version=$YNH_APP_ARG_ODOO_VERSION
admin_password=$3 admin_password=$YNH_APP_ARG_ADMIN_PASSWORD
database_password=$4 database_password=$YNH_APP_ARG_DATABASE_PASSWORD
database_lang=$5 lang=$YNH_APP_ARG_LANG
# Source YunoHost helpers
. /usr/share/yunohost/helpers
# Check domain/path availability # Check domain/path availability
domain=${domain}"/" domain=${domain}"/"
@ -18,25 +21,26 @@ sudo yunohost app checkurl $domain -a $app \
# Remove trailing "/" for next commands # Remove trailing "/" for next commands
domain=${domain%/} domain=${domain%/}
sudo yunohost app setting $app domain -v $domain ynh_app_setting_set "$app" domain "$domain"
ynh_app_setting_set "$app" domain "$domain"
if [ -f /usr/bin/openerp-server ]; then if [ -f /usr/bin/openerp-server ]; then
echo "Odoo is already installed, switching to multi-instances" echo "Odoo is already installed, switching to multi-instances"
sudo yunohost app setting $app instance -v "slave" ynh_app_setting_set "$app" instance "slave"
else else
sudo yunohost app checkport 8069 sudo yunohost app checkport 8069
if [[ ! $? -eq 0 ]]; then if [[ ! $? -eq 0 ]]; then
exit 1 exit 1
fi fi
echo "Installing odoo" echo "Installing odoo"
sudo yunohost app setting $app version -v $odoo_version ynh_app_setting_set "$app" version "$odoo_version"
sudo yunohost app setting $app instance -v "master" ynh_app_setting_set "$app" instance "master"
# Install Odoo # Install Odoo
# Prepare installation # Prepare installation
sudo apt-get -y -qq install curl ynh_package_install curl
# Install Odoo # Install Odoo
sudo curl -sS https://nightly.odoo.com/odoo.key | sudo apt-key add - sudo curl -sS https://nightly.odoo.com/odoo.key | sudo apt-key add -
if [ "$odoo_version" = "8.0" ]; then if [ "$odoo_version" = "8.0" ]; then
@ -45,27 +49,28 @@ else
sudo sh -c 'echo "deb http://nightly.odoo.com/9.0/nightly/deb/ ./" > /etc/apt/sources.list.d/odoo.list' sudo sh -c 'echo "deb http://nightly.odoo.com/9.0/nightly/deb/ ./" > /etc/apt/sources.list.d/odoo.list'
fi fi
sudo apt-get update sudo apt-get update
# Initialize installation # Initialize installation
sudo apt-get -y -qq install postgresql ynh_package_install postgresql
sudo su - postgres -c "echo \"CREATE USER odoo WITH PASSWORD '$admin_password' CREATEDB;\" | psql" 2> /dev/null || true sudo su -c "psql" postgres <<< \
"CREATE USER $app WITH PASSWORD '$database_password' CREATEDB;"
sudo apt-get -y -qq install odoo ynh_package_install odoo
# Install wkhtmltopdf to print PDF reports # Install wkhtmltopdf to print PDF reports
sudo apt-get -yf -qq install wkhtmltopdf ynh_package_install wkhtmltopdf
# Set admin password # Set admin 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 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
# Autoinstall the LDAP auth module # 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 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 # Install oerplib to manage databases
#sudo pip install oerplib #sudo pip install oerplib
# Add services # Add services
sudo yunohost service add postgresql sudo yunohost service add postgresql
sudo yunohost service add odoo --log /var/log/odoo/odoo-server.log sudo yunohost service add odoo --log /var/log/odoo/odoo-server.log
@ -82,20 +87,45 @@ function exit_properly
exit 1 exit 1
} }
trap exit_properly ERR trap exit_properly ERR
ynh_psql_create_user() {
sudo su -c "psql" postgres <<< \
"CREATE USER ${1} WITH PASSWORD '${2}';"
}
ynh_psql_create_db() {
db=$1
# grant all privilegies to user
if [[ $# -gt 1 ]]; then
ynh_psql_create_user ${2} '${3}'
sudo su -c "createdb -O ${2} $db" postgres
else
sudo su -c "createdb $db" postgres
fi
}
# Configure Nginx and reload
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# Make Odoo public
sudo yunohost app setting $app skipped_uris -v "/"
sudo service nginx reload
# Fix peer authentification issue
sudo sed -i '/local\s*all\s*all\s*peer/i \
local all odoo password' /etc/postgresql/9.4/main/pg_hba.conf
sudo service postgresql reload
# Setup database: not working # Setup database: not working
database=${domain//./-}
sudo /usr/bin/openerp-server -c /etc/odoo/openerp-server.conf --stop-after-init -d $database
#ynh_psql_create_db $database
#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@$database_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@$database_password@g" ../conf/install_database.py
#sudo python ../conf/install_database.py #sudo python ../conf/install_database.py
# Setup LDAP: TO BE DONE # Setup LDAP: TO BE DONE
# Configure Nginx and reload
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# Make Odoo public
sudo yunohost app setting $app skipped_uris -v "/"
sudo service nginx reload
echo $? echo $?

View file

@ -1,24 +1,31 @@
#!/bin/bash #!/bin/bash
app=odoo set -eu
domain=$(sudo yunohost app setting $app domain)
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
. /usr/share/yunohost/helpers
# Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain)
database=${domain//./-} database=${domain//./-}
instance=$(sudo yunohost app setting $app instance) instance=$(ynh_app_setting_get "$app" instance)
# Remove database # Remove database
sudo -u postgres dropdb $database sudo su -c "dropdb $database" postgres
# If removing master instance, remove Odoo. # If removing master instance, remove Odoo.
if [ "$instance" = "master" ]; then if [ "$instance" = "master" ]; then
# Remove Odoo # Remove Odoo
sudo yunohost service stop odoo sudo yunohost service stop odoo
sudo apt-get remove odoo -y sudo apt-get remove odoo -y
sudo apt-get remove wkhtmltopdf -y sudo apt-get remove wkhtmltopdf -y
sudo yunohost service remove odoo sudo yunohost service remove odoo
fi fi
# Remove NGINX conf # Remove NGINX conf
sudo rm /etc/nginx/conf.d/$domain.d/$app.conf sudo rm /etc/nginx/conf.d/$domain.d/$app.conf
# Reload # Reload
sudo service nginx reload sudo service nginx reload
sudo yunohost app ssowatconf sudo yunohost app ssowatconf

View file

@ -1,7 +1,14 @@
#!/bin/bash #!/bin/bash
app=odoo set -eu
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
. /usr/share/yunohost/helpers
# Retrieve arguments
domain=$(ynh_app_setting_get "$app" domain)
# Upgrade official package # Upgrade official package
sudo apt-get install odoo -y -qq sudo apt-get install odoo -y -qq
# TBD # TBD