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/_common.sh

107 lines
3.9 KiB
Bash
Raw Normal View History

#
# Common variables
#
2022-02-13 19:55:00 +01:00
export appname="libreerp"
export FORKNAME="odoo"
2020-01-20 04:01:02 +01:00
DEPENDENCIES="curl postgresql xfonts-75dpi xfonts-base wkhtmltopdf node-less python3-dev gcc libldap2-dev libssl-dev libsasl2-dev python3-pip python3-dev python3-venv python3-wheel libxslt-dev libzip-dev python3-setuptools python-virtualenv python-wheel python-setuptools libjpeg-dev zlib1g-dev virtualenv libfreetype6-dev"
2017-05-18 23:28:18 +02:00
2018-12-16 19:41:40 +01:00
function debranding() {
2018-12-14 19:49:43 +01:00
# Remove Odoo references to avoid trademark issue
2022-02-13 19:55:00 +01:00
if [ -d $final_path/$appname/$FORKNAME ]; then
python_app=$final_path/$appname/$FORKNAME
2018-12-14 19:49:43 +01:00
else
2022-02-13 19:55:00 +01:00
python_app=$final_path/$appname/openerp
2018-12-14 19:49:43 +01:00
fi
2022-02-13 19:55:00 +01:00
find $final_path/$appname -type f \( -iname '*.xml' -o -iname '*.po' \) -exec sed -i 's/Powered by <a[^>]*>Odoo<\/a>//g' {} \;
find $final_path/$appname -type f \( -iname '*.xml' -o -iname '*.po' \) -exec sed -i 's/<a[^>]*>Powered by <[^>]*>Odoo<\/[^>]*><\/a>//g' {} \;
find $final_path/$appname -type f \( -iname '*.xml' -o -iname '*.po' \) -exec sed -i 's/Powered by <[^>]*>Odoo<\/[^>]*>//g' {} \;
find $final_path/$appname -type f \( -iname '*.xml' -o -iname '*.po' \) -exec sed -i 's/Powered by <[^>]*><img[^>]*Odoo[^>]*><\/a>//g' {} \;
sed -i 's/<a[^>]*>My Odoo.com account<\/a>//g' $final_path/$appname/addons/web/static/src/xml/base.xml
sed -i 's/<a[^>]*>Documentation<\/a>//g' $final_path/$appname/addons/web/static/src/xml/base.xml
sed -i 's/<a[^>]*>Support<\/a>//g' $final_path/$appname/addons/web/static/src/xml/base.xml
2018-12-14 19:49:43 +01:00
cp ../conf/logo_type.png $python_app/addons/base/static/img/logo_white.png
2022-02-13 19:55:00 +01:00
cp ../conf/favicon.ico $final_path/$appname/addons/web/static/src/img/favicon.ico
2018-12-16 19:41:40 +01:00
}
function setup_files() {
2022-02-13 19:55:00 +01:00
if [[ $oca -eq 0 ]]; then
ynh_setup_source $final_path/$appname $app_version
else
ynh_setup_source $final_path/$appname "oca-$app_version"
fi
2018-12-16 19:41:40 +01:00
debranding
2018-12-14 19:49:43 +01:00
mkdir -p $final_path/custom-addons
chown -R $app:$app $final_path
touch /var/log/$app.log
chown $app:$app /var/log/$app.log
2018-12-16 19:41:40 +01:00
if [ ! -f $conf_file ]; then
ynh_configure server.conf $conf_file
chown $app:$app $conf_file
# Autoinstall the LDAP auth module
2022-02-13 19:55:00 +01:00
if ls $final_path/$appname/$FORKNAME-bin > /dev/null ; then
ynh_replace_string "^{$" "{'auto_install': True," ${final_path}/$appname/addons/auth_ldap/__manifest__.py
2018-12-16 19:41:40 +01:00
else
2022-02-13 19:55:00 +01:00
ynh_replace_string "'auto_install': False" "'auto_install': True" ${final_path}/$appname/addons/auth_ldap/__openerp__.py
2018-12-16 19:41:40 +01:00
fi
fi
2018-12-14 19:49:43 +01:00
}
2017-05-18 23:28:18 +02:00
# Install dependencies
function install_dependencies() {
2018-09-27 00:31:17 +02:00
ynh_add_swap 1024
2018-12-14 03:36:58 +01:00
ynh_install_app_dependencies $DEPENDENCIES
2017-05-18 23:28:18 +02:00
if ! wkhtmltopdf --version | grep "wkhtmltopdf 0.12.4 (with patched qt)"; then
# The debian package has a bug so we deploy a more recent version
2018-12-16 19:41:40 +01:00
if [ -f '../manifest.json' ] ; then
ynh_setup_source /usr/
else
OLD_YNH_CWD=$YNH_CWD
YNH_CWD=$YNH_CWD/../settings/conf
ynh_setup_source /usr/
YNH_CWD=$OLD_YNH_CWD
fi
2017-05-18 23:28:18 +02:00
fi
2018-12-14 03:36:58 +01:00
pushd $final_path
2022-02-13 19:55:00 +01:00
if grep "python3" $final_path/$appname/$FORKNAME-bin ; then
2018-12-14 03:36:58 +01:00
python3 -m venv venv
venv/bin/pip3 install wheel
2022-02-13 19:55:00 +01:00
venv/bin/pip3 install -r $appname/requirements.txt
2018-12-14 03:36:58 +01:00
else
virtualenv venv
venv/bin/pip install wheel
2022-02-13 19:55:00 +01:00
venv/bin/pip install -r $appname/requirements.txt
2017-05-18 23:28:18 +02:00
fi
2018-12-14 03:36:58 +01:00
popd
}
2018-12-14 03:36:58 +01:00
2017-05-18 23:28:18 +02:00
# Add services
function add_services() {
if ! grep "^postgresql:$" /etc/yunohost/services.yml; then
yunohost service add postgresql
fi
2018-12-14 03:36:58 +01:00
ynh_configure app.service /etc/systemd/system/$app.service
systemctl daemon-reload
2018-05-21 10:51:03 +02:00
2018-12-14 03:36:58 +01:00
yunohost service add $app --log /var/log/$app.log
yunohost service stop $app
yunohost service start $app
yunohost service enable $app
}
2017-05-18 23:28:18 +02:00
function ssowat_and_restart() {
# Restart odoo service
2018-12-14 03:36:58 +01:00
service $app restart
2017-05-18 23:28:18 +02:00
# Configure SSOWat
ynh_sso_access "/web/database/manager"
2017-05-18 23:28:18 +02:00
# Reload services
service nginx reload
}