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

101 lines
2.6 KiB
Bash

#!/bin/bash
set -eu
source /usr/share/yunohost/helpers
source _future.sh
source _common.sh
ynh_trap_on
# Arguments from manifest
export app=$YNH_APP_INSTANCE_NAME
export domain=$YNH_APP_ARG_DOMAIN
export odoo_version=$YNH_APP_ARG_VERSION
export oca=$YNH_APP_ARG_OCA
export admin_password=$YNH_APP_ARG_ADMIN_PASSWORD
export lang=$YNH_APP_ARG_LANG
export tz=$YNH_APP_ARG_TZ
export is_public=0
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
#=================================================
ynh_check_var "$app" "app name not set"
ynh_webpath_available "$domain" "/"
check_odoo_version
define_paths
define_is_master
define_port
define_dbpass
#=================================================
# SETUP THE APP BY MODIFYING THE SYSTEM
#=================================================
function setup_files() {
# Set admin password
export database=${domain//./-}
ynh_configure openerp-server.conf $conf_file
chown odoo:odoo $conf_file
# Autoinstall the LDAP auth module
if [ $(echo "$odoo_version >= 10" | bc) -ne 0 ]; then
ynh_replace_string "^{$" "{'auto_install': True," ${source_path}addons/auth_ldap/__manifest__.py
else
ynh_replace_string "'auto_install': False" "'auto_install': True" ${source_path}addons/auth_ldap/__openerp__.py
fi
# Fix peer authentification issue
sed -i '/local\s*all\s*all\s*peer/i \
local all odoo password' /etc/postgresql/9.*/main/pg_hba.conf
ynh_configure_nginx
}
function setup_database() {
# Setup database: not working
database=${domain//./-}
# Load translation
$bin_file -c $conf_file --stop-after-init -i auth_ldap -d $database
$bin_file -c $conf_file --stop-after-init -d $database --load-language $lang
# Configure language, timezone and ldap
$bin_file shell -c $conf_file -d $database <<< \
"
self.change_password('admin','$admin_password')
self.env.cr.commit()
self.write({'tz':'$tz','lang':'$lang'})
self.env.cr.commit()
template=env['res.users'].create({
'login':'template',
'password':'',
'name':'template',
'email':'template',
'sel_groups_9_10':9,
'tz':'$tz',
'lang':'$lang'
})
self.env.cr.commit()
self.company_id.ldaps.create({
'ldap_server':'localhost',
'ldap_server_port':389,
'ldap_base':'ou=users, dc=yunohost,dc=org',
'ldap_filter':'uid=%s',
'user':template.id,
'company':self.company_id.id
})
self.env.cr.commit()
"
}
ynh_webpath_register "$app" "$domain" "/"
ynh_save_args domain odoo_version oca lang tz is_master port
install_dependencies
setup_files
create_general_db
add_services
setup_database
ssowat_and_restart