mirror of
https://github.com/YunoHost-Apps/libreerp_ynh.git
synced 2024-09-03 19:36:13 +02:00
104 lines
3.1 KiB
Bash
104 lines
3.1 KiB
Bash
#!/bin/bash
|
|
|
|
set -eu
|
|
|
|
source /usr/share/yunohost/helpers
|
|
source _future.sh
|
|
source _common.sh
|
|
|
|
ynh_abort_if_errors
|
|
|
|
# Arguments from manifest
|
|
export app=$YNH_APP_INSTANCE_NAME
|
|
ynh_export domain oca admin_password lang tz
|
|
export odoo_version=$YNH_APP_ARG_VERSION
|
|
export is_public=0
|
|
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)
|
|
|
|
#=================================================
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
|
#=================================================
|
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
|
ynh_webpath_available $domain "/"
|
|
ynh_webpath_register $app $domain "/"
|
|
|
|
|
|
#=================================================
|
|
# SETUP THE APP BY MODIFYING THE SYSTEM
|
|
#=================================================
|
|
function setup_files() {
|
|
|
|
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
|
|
|
|
# Autoinstall the LDAP auth module
|
|
if ls $final_path/$APPNAME/$APPNAME-bin > /dev/null ; then
|
|
ynh_replace_string "^{$" "{'auto_install': True," ${final_path}/$APPNAME/addons/auth_ldap/__manifest__.py
|
|
else
|
|
ynh_replace_string "'auto_install': False" "'auto_install': True" ${final_path}/$APPNAME/addons/auth_ldap/__openerp__.py
|
|
fi
|
|
|
|
touch /var/log/$app.log
|
|
chown $app:$app /var/log/$app.log
|
|
|
|
ynh_configure_nginx
|
|
}
|
|
|
|
function setup_database() {
|
|
|
|
# Load translation
|
|
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
|
|
# Configure language, timezone and ldap
|
|
sudo -u $app $bin_file shell -c $conf_file -d $app <<< \
|
|
"
|
|
self.env['res.users'].search([['login', '=', 'admin']])[0].write({'password': '$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_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
|
|
setup_files
|
|
install_dependencies
|
|
add_services
|
|
setup_database
|
|
ssowat_and_restart
|
|
|