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
|
|
|
|
|
2018-12-14 03:36:58 +01:00
|
|
|
ynh_abort_if_errors
|
2017-05-18 23:28:18 +02:00
|
|
|
|
|
|
|
# Arguments from manifest
|
|
|
|
export app=$YNH_APP_INSTANCE_NAME
|
2018-12-14 03:36:58 +01:00
|
|
|
ynh_export domain oca admin_password lang tz
|
2017-05-18 23:28:18 +02:00
|
|
|
export odoo_version=$YNH_APP_ARG_VERSION
|
|
|
|
export is_public=0
|
2018-12-14 03:36:58 +01:00
|
|
|
export final_path="/var/www/$app"
|
|
|
|
export conf_file=/etc/$app/main.conf
|
|
|
|
export bin_file="$final_path/venv/bin/python $final_path/$APPNAME/$APPNAME-bin"
|
|
|
|
if [ "$odoo_version" = "9" ]; then
|
|
|
|
bin_file="$final_path/venv/bin/python $final_path/$APPNAME/$APPNAME.py"
|
|
|
|
fi
|
|
|
|
if [ "$odoo_version" = "8" ]; then
|
|
|
|
bin_file="$final_path/venv/bin/python $final_path/$APPNAME/$APPNAME.py"
|
|
|
|
fi
|
|
|
|
export db_name=$(ynh_sanitize_dbid $app)
|
|
|
|
export port=$(ynh_find_port 8069)
|
|
|
|
export port_chat=$(ynh_find_port 8072)
|
2017-05-18 23:28:18 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
|
|
|
#=================================================
|
2018-12-14 03:36:58 +01:00
|
|
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
|
|
|
ynh_webpath_available $domain "/"
|
|
|
|
ynh_webpath_register $app $domain "/"
|
2017-05-18 23:28:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP THE APP BY MODIFYING THE SYSTEM
|
|
|
|
#=================================================
|
|
|
|
function setup_files() {
|
2018-12-14 03:36:58 +01:00
|
|
|
|
|
|
|
ynh_setup_source $final_path/$APPNAME $odoo_version
|
|
|
|
mkdir -p $final_path/custom-addons
|
|
|
|
chown -R $app:$app $final_path
|
|
|
|
ynh_configure server.conf $conf_file
|
|
|
|
chown $app:$app $conf_file
|
2016-07-05 15:22:12 +02:00
|
|
|
|
2016-11-29 00:20:02 +01:00
|
|
|
# Autoinstall the LDAP auth module
|
2018-12-14 03:36:58 +01:00
|
|
|
if ls $final_path/$APPNAME/$APPNAME-bin > /dev/null ; then
|
|
|
|
ynh_replace_string "^{$" "{'auto_install': True," ${final_path}/$APPNAME/addons/auth_ldap/__manifest__.py
|
2017-05-18 23:28:18 +02:00
|
|
|
else
|
2018-12-14 03:36:58 +01:00
|
|
|
ynh_replace_string "'auto_install': False" "'auto_install': True" ${final_path}/$APPNAME/addons/auth_ldap/__openerp__.py
|
2017-05-18 23:28:18 +02:00
|
|
|
fi
|
2018-12-14 03:36:58 +01:00
|
|
|
|
|
|
|
touch /var/log/$app.log
|
|
|
|
chown $app:$app /var/log/$app.log
|
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
|
|
|
# Load translation
|
2018-12-14 03:36:58 +01:00
|
|
|
sudo -u $app $bin_file -c $conf_file --stop-after-init -i auth_ldap -d $app
|
|
|
|
sudo -u $app $bin_file -c $conf_file --stop-after-init -d $app --load-language $lang
|
2017-05-18 23:28:18 +02:00
|
|
|
# Configure language, timezone and ldap
|
2018-12-14 03:36:58 +01:00
|
|
|
sudo -u $app $bin_file shell -c $conf_file -d $app <<< \
|
2016-12-14 21:45:41 +01:00
|
|
|
"
|
2018-12-13 13:07:01 +01:00
|
|
|
self.env['res.users'].search([['login', '=', 'admin']])[0].write({'password': '$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
|
|
|
}
|
2018-12-14 03:36:58 +01:00
|
|
|
ynh_save_args domain odoo_version oca lang tz final_path conf_file db_name port port_chat
|
|
|
|
ynh_psql_test_if_first_run
|
|
|
|
ynh_psql_setup_db $db_name $db_name
|
|
|
|
export db_pass=$(ynh_app_setting_get $app psqlpwd)
|
|
|
|
ynh_system_user_create $app $final_path
|
2017-05-18 23:28:18 +02:00
|
|
|
setup_files
|
2018-12-14 03:36:58 +01:00
|
|
|
install_dependencies
|
2017-05-18 23:28:18 +02:00
|
|
|
add_services
|
|
|
|
setup_database
|
|
|
|
ssowat_and_restart
|
2016-12-14 21:45:41 +01:00
|
|
|
|