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

100 lines
3 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
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
export app_version=$YNH_APP_ARG_VERSION
2017-05-18 23:28:18 +02:00
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/$FORKNAME-bin"
if [ "$app_version" = "9" ]; then
bin_file="$final_path/venv/bin/python $final_path/$APPNAME/$FORKNAME.py"
2018-12-14 03:36:58 +01:00
fi
if [ "$app_version" = "8" ]; then
bin_file="$final_path/venv/bin/python $final_path/$APPNAME/$FORKNAME.py"
2018-12-14 03:36:58 +01:00
fi
export db_name=$(ynh_sanitize_dbid $app)
export port=$(ynh_find_port 8069)
export port_chat=$(ynh_find_port 8072)
2019-04-17 22:45:59 +02:00
export preinstall=0
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_register $app $domain "/"
2017-05-18 23:28:18 +02:00
#=================================================
# SETUP THE APP BY MODIFYING THE SYSTEM
#=================================================
2015-09-14 17:12:17 +02:00
2017-05-18 23:28:18 +02:00
function setup_database() {
2019-04-17 22:45:59 +02:00
export preinstall=1
ynh_configure server.conf $conf_file
chown $app:$app $conf_file
2017-05-18 23:28:18 +02:00
# Load translation
2019-04-17 22:45:59 +02:00
#param=" --without-demo True --addons-path $final_path/$APPNAME/addons --db_user $app --db_password $db_pass --db_host 127.0.0.1 --db_port 5432 --db-filter '^$app\$' -d $app "
param=" -c $conf_file -d $app "
2018-12-14 03:36:58 +01:00
sudo -u $app $bin_file -c $conf_file --stop-after-init -i auth_ldap -d $app
2019-04-17 22:45:59 +02:00
sudo -u $app $bin_file -c $conf_file --stop-after-init --load-language $lang -d $app
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()
2019-04-17 22:45:59 +02:00
"
sudo -u $app $bin_file shell -c $conf_file -d $app <<< \
"
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()
2019-04-17 22:45:59 +02:00
"
sudo -u $app $bin_file shell -c $conf_file -d $app <<< \
"
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()
"
2019-04-17 22:45:59 +02:00
export preinstall=0
ynh_configure server.conf $conf_file
chown $app:$app $conf_file
2017-05-18 23:28:18 +02:00
}
ynh_save_args domain app_version oca lang tz final_path conf_file db_name port port_chat
ynh_system_user_create -u $app -h $final_path
export db_pass=$(ynh_string_random)
2017-05-18 23:28:18 +02:00
setup_files
2018-12-14 03:36:58 +01:00
install_dependencies
ynh_psql_test_if_first_run
ynh_psql_setup_db $db_name $db_name $db_pass
export db_pass=$(ynh_app_setting_get $app psqlpwd)
ynh_configure_nginx
2017-05-18 23:28:18 +02:00
add_services
setup_database
ssowat_and_restart
2016-12-14 21:45:41 +01:00