1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/libreerp_ynh.git synced 2024-09-03 19:36:13 +02:00

[enh] Adapt for yunohost 2.4

This commit is contained in:
zamentur 2016-07-05 15:22:12 +02:00
parent 6d7e896715
commit fa877df587
6 changed files with 133 additions and 60 deletions

View file

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

View file

@ -1,6 +1,7 @@
{
"name": "Odoo",
"id": "odoo",
"packaging_format": 1,
"description": {
"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, ...)."
@ -8,7 +9,13 @@
"developer": {
"name": "scith"
},
"requirements": {
"yunohost": ">> 2.4.0"
},
"multi_instance": "true",
"services": [
"nginx"
],
"arguments": {
"install" : [
{
@ -44,7 +51,7 @@
}
},
{
"name": "database_lang",
"name": "lang",
"ask": {
"en": "Choose a language for Odoo",
"fr": "Choisissez une langue pour Odoo"

View file

@ -1,3 +1,24 @@
#! /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
app=odoo
set -e
set -eu
app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments
domain=$1
odoo_version=$2
admin_password=$3
database_password=$4
database_lang=$5
domain=$YNH_APP_ARG_DOMAIN
odoo_version=$YNH_APP_ARG_ODOO_VERSION
admin_password=$YNH_APP_ARG_ADMIN_PASSWORD
database_password=$YNH_APP_ARG_DATABASE_PASSWORD
lang=$YNH_APP_ARG_LANG
# Source YunoHost helpers
. /usr/share/yunohost/helpers
# Check domain/path availability
domain=${domain}"/"
@ -18,25 +21,26 @@ sudo yunohost app checkurl $domain -a $app \
# Remove trailing "/" for next commands
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
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
sudo yunohost app checkport 8069
if [[ ! $? -eq 0 ]]; then
exit 1
fi
echo "Installing odoo"
sudo yunohost app setting $app version -v $odoo_version
sudo yunohost app setting $app instance -v "master"
ynh_app_setting_set "$app" version "$odoo_version"
ynh_app_setting_set "$app" instance "master"
# Install Odoo
# Prepare installation
sudo apt-get -y -qq install curl
ynh_package_install curl
# Install Odoo
sudo curl -sS https://nightly.odoo.com/odoo.key | sudo apt-key add -
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'
fi
sudo apt-get update
# Initialize installation
sudo apt-get -y -qq install postgresql
sudo su - postgres -c "echo \"CREATE USER odoo WITH PASSWORD '$admin_password' CREATEDB;\" | psql" 2> /dev/null || true
sudo apt-get -y -qq install odoo
ynh_package_install postgresql
sudo su -c "psql" postgres <<< \
"CREATE USER $app WITH PASSWORD '$database_password' CREATEDB;"
ynh_package_install odoo
# Install wkhtmltopdf to print PDF reports
sudo apt-get -yf -qq install wkhtmltopdf
ynh_package_install wkhtmltopdf
# Set admin password
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 chown odoo:odoo /etc/odoo/openerp-server.conf
# 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
#sudo pip install oerplib
# Add services
sudo yunohost service add postgresql
sudo yunohost service add odoo --log /var/log/odoo/odoo-server.log
@ -82,20 +87,45 @@ function exit_properly
exit 1
}
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
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@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 python ../conf/install_database.py
# 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 $?

View file

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

View file

@ -1,7 +1,14 @@
#!/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
sudo apt-get install odoo -y -qq
# TBD