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

105 lines
2.8 KiB
Text
Raw Normal View History

2015-09-14 17:12:17 +02:00
#!/bin/bash
2016-07-05 15:22:12 +02:00
set -eu
2017-05-18 23:28:18 +02:00
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() {
2016-11-29 00:20:02 +01:00
# Set admin password
2018-09-19 18:20:58 +02:00
export database=${domain//./-}
2017-05-18 23:28:18 +02:00
ynh_configure openerp-server.conf $conf_file
chown odoo:odoo $conf_file
2016-07-05 15:22:12 +02:00
2016-11-29 00:20:02 +01:00
# Autoinstall the LDAP auth module
2017-05-18 23:28:18 +02:00
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
2016-07-05 15:22:12 +02:00
2017-05-18 23:28:18 +02:00
# Fix peer authentification issue
sed -i '/local\s*all\s*all\s*peer/i \
2018-09-19 15:53:06 +02:00
local all odoo password' /etc/postgresql/9.*/main/pg_hba.conf
2015-09-16 10:17:50 +02:00
2017-05-18 23:28:18 +02:00
ynh_configure_nginx
}
2015-09-14 17:12:17 +02:00
2017-05-18 23:28:18 +02:00
function setup_database() {
2015-09-14 17:12:17 +02:00
2017-05-18 23:28:18 +02:00
# Setup database: not working
database=${domain//./-}
2016-07-05 15:22:12 +02:00
2018-09-26 20:40:40 +02:00
if [ $(echo "$odoo_version <= 8" | bc) -ne 0 ]; then
su -c "createdb -O $APPNAME $database" - postgres
fi
2017-05-18 23:28:18 +02:00
# Load translation
2018-09-26 20:40:40 +02:00
sudo -u odoo $bin_file -c $conf_file --stop-after-init -i auth_ldap -d $database
sudo -u odoo $bin_file -c $conf_file --stop-after-init -d $database --load-language $lang
2017-05-18 23:28:18 +02:00
# Configure language, timezone and ldap
2018-09-26 20:40:40 +02:00
sudo -u odoo $bin_file shell -c $conf_file -d $database <<< \
2016-12-14 21:45:41 +01:00
"
self.change_password('admin','$admin_password')
2016-12-14 22:12:22 +01:00
self.env.cr.commit()
2016-12-14 21:45:41 +01:00
self.write({'tz':'$tz','lang':'$lang'})
2016-12-14 22:12:22 +01:00
self.env.cr.commit()
2016-12-14 21:45:41 +01:00
template=env['res.users'].create({
'login':'template',
'password':'',
'name':'template',
'email':'template',
'sel_groups_9_10':9,
'tz':'$tz',
'lang':'$lang'
})
2016-12-14 22:12:22 +01:00
self.env.cr.commit()
2016-12-14 21:45:41 +01:00
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()
"
2017-05-18 23:28:18 +02:00
}
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
2016-12-14 21:45:41 +01:00