From b8ac53c7098a0de490271de296f9e0cb90e8d880 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 13 Feb 2022 19:55:00 +0100 Subject: [PATCH 1/5] Fix install --- check_process | 24 ++++-------------------- conf/12.src | 4 ++-- conf/14.src | 5 +++++ conf/app.service.j2 | 10 +++++----- conf/nginx.conf.j2 | 10 +++++----- conf/oca-12.src | 5 +++++ conf/oca-14.src | 5 +++++ conf/server.conf.j2 | 24 ++++++++++-------------- manifest.json | 4 ++-- scripts/_common.sh | 42 +++++++++++++++++++++++------------------- scripts/_future.sh | 19 +++++++++++++++++-- scripts/backup | 2 +- scripts/install | 9 +++++---- scripts/restore | 6 +++--- 14 files changed, 92 insertions(+), 77 deletions(-) create mode 100644 conf/14.src create mode 100644 conf/oca-12.src create mode 100644 conf/oca-14.src diff --git a/check_process b/check_process index 9de44be..ab58cea 100644 --- a/check_process +++ b/check_process @@ -1,8 +1,8 @@ ;; Test complet sans multisite auto_remove=1 ; Manifest - domain="domain.tld" (DOMAIN) - version="12" + domain="domain.tld" + version="14" oca=0 admin_password="testpassw0rD" lang="en_US" @@ -17,24 +17,8 @@ upgrade=1 backup_restore=1 multi_instance=1 - wrong_user=1 - wrong_path=0 - incorrect_path=0 - corrupt_source=1 - fail_download_source=1 - port_already_use=1 - final_path_already_use=1 -;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto - Level 4=1 - Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 + port_already_use=0 + change_url=0 ;;; Options Email=ljf+libreerp_ynh@reflexlibre.net Notification=down diff --git a/conf/12.src b/conf/12.src index da62001..295c3d4 100644 --- a/conf/12.src +++ b/conf/12.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/odoo/odoo/archive/206e0b71ac74147a989db60cddae801534b97bdc.tar.gz -SOURCE_SUM=a6d8d28bb7f20ac88fd149c652d7e4ce0f35241e46e7a3a347265dae0d7535fe +SOURCE_URL=https://github.com/odoo/odoo/archive/336c9aab3619abb5bfbeb07f87ae014facdefb0b.tar.gz +SOURCE_SUM=3d37bc31383bfad827c3fdbab4daa3914ad036fd70fe1f20925ed18d2b9e1f87 SOURCE_FILENAME=odoo-12.tar.gz SOURCE_FORMAT=tar.gz SOURCE_SUM_PRG=sha256sum diff --git a/conf/14.src b/conf/14.src new file mode 100644 index 0000000..8da0284 --- /dev/null +++ b/conf/14.src @@ -0,0 +1,5 @@ +SOURCE_URL=https://github.com/odoo/odoo/archive/d8322e64c6d999ffc72093b2ef2db91532138c89.tar.gz +SOURCE_SUM=40cbbc93ab594f614499ccdd04922590c420bfadeaf2f889853a5d58073e5fef +SOURCE_FILENAME=odoo-14.tar.gz +SOURCE_FORMAT=tar.gz +SOURCE_SUM_PRG=sha256sum diff --git a/conf/app.service.j2 b/conf/app.service.j2 index 600de12..b1304f1 100644 --- a/conf/app.service.j2 +++ b/conf/app.service.j2 @@ -1,16 +1,16 @@ [Unit] -Description={{ app }} +Description=__APP__ Requires=postgresql.service After=network.target postgresql.service [Service] Type=simple -SyslogIdentifier={{ app }} +SyslogIdentifier=__APP__ PermissionsStartOnly=true -User={{ app }} -Group={{ app }} +User=__APP__ +Group=__APP__ Environment=PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin -ExecStart={{ bin_file }} --config {{ conf_file }} --logfile /var/log/{{ app }}.log +ExecStart=__BIN_FILE__ --config __CONF_FILE__ --logfile /var/log/__APP__.log Restart=always RestartSec=3 StandardOutput=journal+console diff --git a/conf/nginx.conf.j2 b/conf/nginx.conf.j2 index 40ff7ea..9289867 100644 --- a/conf/nginx.conf.j2 +++ b/conf/nginx.conf.j2 @@ -2,10 +2,10 @@ location / { if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } - try_files $uri @{{ app }}; + try_files $uri @__APP__; } -location @{{ app }} { - proxy_pass http://127.0.0.1:{{ port }}; +location @__APP__ { + proxy_pass http://127.0.0.1:__PORT__; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_buffers 16 64k; proxy_buffer_size 128k; @@ -20,7 +20,7 @@ location @{{ app }} { proxy_send_timeout 720s; } location /longpolling { - proxy_pass http://127.0.0.1:{{ port_chat }}; + proxy_pass http://127.0.0.1:__PORT_CHAT__; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; @@ -34,7 +34,7 @@ location ~* /web/static/ { proxy_cache_valid 200 90m; proxy_buffering on; expires 864000; - proxy_pass http://127.0.0.1:{{ port }}; + proxy_pass http://127.0.0.1:__PORT__; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; diff --git a/conf/oca-12.src b/conf/oca-12.src new file mode 100644 index 0000000..5e7f51d --- /dev/null +++ b/conf/oca-12.src @@ -0,0 +1,5 @@ +SOURCE_URL=https://github.com/OCA/OCB/archive/4df6b0b164c6f384fdb7df40e51e80780572273a.tar.gz +SOURCE_SUM=e064dcd121ca207cbfa18c5f5f63c394ee6a1ca03f9ebbd6b88e6a62dda6bca0 +SOURCE_FILENAME=odoo-12.tar.gz +SOURCE_FORMAT=tar.gz +SOURCE_SUM_PRG=sha256sum diff --git a/conf/oca-14.src b/conf/oca-14.src new file mode 100644 index 0000000..4f5e8f4 --- /dev/null +++ b/conf/oca-14.src @@ -0,0 +1,5 @@ +SOURCE_URL=https://github.com/OCA/OCB/archive/b7dc86b530718c090ba26b8eea0154d1c50c05f2.tar.gz +SOURCE_SUM=d2ca8bbe913e90f1623c6f2375d4cd2c40d4ed4abb650e66f7691669cbab90fa +SOURCE_FILENAME=odoo-14.tar.gz +SOURCE_FORMAT=tar.gz +SOURCE_SUM_PRG=sha256sum diff --git a/conf/server.conf.j2 b/conf/server.conf.j2 index 432078a..4947406 100644 --- a/conf/server.conf.j2 +++ b/conf/server.conf.j2 @@ -1,22 +1,18 @@ [options] ; This is the password that allows database operations: without_demo = all -admin_passwd = {{ admin_password }} +admin_passwd = __ADMIN_PASSWORD__ db_host = localhost db_port = 5432 -db_user = {{ db_name }} -db_password = {{ db_pass }} -{% if preinstall == '1' %} -dbfilter = ^{{ db_name }}$ -{% else %} -db_name = {{ db_name }} -{% if app_version > 9 %}dbfilter = False{% endif %} -list_db = False -{% endif %} -addons_path = {{ final_path }}/{{ APPNAME }}/addons,{{ final_path }}/custom-addons +db_user = __DB_NAME__ +db_password = __DB_PASS__ +__CONTENT__ +__CONTENT2__ +__CONTENT3__ +addons_path = __FINAL_PATH__/__APPNAME__/addons,__FINAL_PATH__/custom-addons proxy_mode = true -logfile = /var/log/{{ app }}.log +logfile = /var/log/__APP__.log xmlrpc_interface = 127.0.0.1 netrpc_interface = 127.0.0.1 -xmlrpc_port = {{ port }} -longpolling_port = {{ port_chat }} +xmlrpc_port = __PORT__ +longpolling_port = __PORT_CHAT__ diff --git a/manifest.json b/manifest.json index aa74be2..3f2e54e 100644 --- a/manifest.json +++ b/manifest.json @@ -34,8 +34,8 @@ "example": "erp.domain.org" }, { "name": "version", - "choices": ["8", "9", "10", "11", "12"], - "default": "12", + "choices": ["11", "12", "14"], + "default": "14", "ask": { "en": "Choose the version you want", "fr": "Choisissez la version désirée" diff --git a/scripts/_common.sh b/scripts/_common.sh index acd31da..b6b83b4 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -2,31 +2,35 @@ # Common variables # -export APPNAME="libreerp" +export appname="libreerp" export FORKNAME="odoo" 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" function debranding() { # Remove Odoo references to avoid trademark issue - if [ -d $final_path/$APPNAME/$FORKNAME ]; then - python_app=$final_path/$APPNAME/$FORKNAME + if [ -d $final_path/$appname/$FORKNAME ]; then + python_app=$final_path/$appname/$FORKNAME else - python_app=$final_path/$APPNAME/openerp + python_app=$final_path/$appname/openerp fi - find $final_path/$APPNAME -type f \( -iname '*.xml' -o -iname '*.po' \) -exec sed -i 's/Powered by ]*>Odoo<\/a>//g' {} \; - find $final_path/$APPNAME -type f \( -iname '*.xml' -o -iname '*.po' \) -exec sed -i 's/]*>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 <[^>]*>]*Odoo[^>]*><\/a>//g' {} \; - sed -i 's/]*>My Odoo.com account<\/a>//g' $final_path/$APPNAME/addons/web/static/src/xml/base.xml - sed -i 's/]*>Documentation<\/a>//g' $final_path/$APPNAME/addons/web/static/src/xml/base.xml - sed -i 's/]*>Support<\/a>//g' $final_path/$APPNAME/addons/web/static/src/xml/base.xml + find $final_path/$appname -type f \( -iname '*.xml' -o -iname '*.po' \) -exec sed -i 's/Powered by ]*>Odoo<\/a>//g' {} \; + find $final_path/$appname -type f \( -iname '*.xml' -o -iname '*.po' \) -exec sed -i 's/]*>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 <[^>]*>]*Odoo[^>]*><\/a>//g' {} \; + sed -i 's/]*>My Odoo.com account<\/a>//g' $final_path/$appname/addons/web/static/src/xml/base.xml + sed -i 's/]*>Documentation<\/a>//g' $final_path/$appname/addons/web/static/src/xml/base.xml + sed -i 's/]*>Support<\/a>//g' $final_path/$appname/addons/web/static/src/xml/base.xml cp ../conf/logo_type.png $python_app/addons/base/static/img/logo_white.png - cp ../conf/favicon.ico $final_path/$APPNAME/addons/web/static/src/img/favicon.ico + cp ../conf/favicon.ico $final_path/$appname/addons/web/static/src/img/favicon.ico } function setup_files() { - ynh_setup_source $final_path/$APPNAME $app_version + if [[ $oca -eq 0 ]]; then + ynh_setup_source $final_path/$appname $app_version + else + ynh_setup_source $final_path/$appname "oca-$app_version" + fi debranding mkdir -p $final_path/custom-addons chown -R $app:$app $final_path @@ -38,10 +42,10 @@ function setup_files() { chown $app:$app $conf_file # Autoinstall the LDAP auth module - if ls $final_path/$APPNAME/$FORKNAME-bin > /dev/null ; then - ynh_replace_string "^{$" "{'auto_install': True," ${final_path}/$APPNAME/addons/auth_ldap/__manifest__.py + if ls $final_path/$appname/$FORKNAME-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 + ynh_replace_string "'auto_install': False" "'auto_install': True" ${final_path}/$appname/addons/auth_ldap/__openerp__.py fi fi @@ -63,14 +67,14 @@ function install_dependencies() { fi fi pushd $final_path - if grep "python3" $final_path/$APPNAME/$FORKNAME-bin ; then + if grep "python3" $final_path/$appname/$FORKNAME-bin ; then python3 -m venv venv venv/bin/pip3 install wheel - venv/bin/pip3 install -r $APPNAME/requirements.txt + venv/bin/pip3 install -r $appname/requirements.txt else virtualenv venv venv/bin/pip install wheel - venv/bin/pip install -r $APPNAME/requirements.txt + venv/bin/pip install -r $appname/requirements.txt fi popd } diff --git a/scripts/_future.sh b/scripts/_future.sh index 30e25be..7695cee 100644 --- a/scripts/_future.sh +++ b/scripts/_future.sh @@ -32,11 +32,26 @@ ynh_sso_access () { ynh_configure () { local TEMPLATE=$1 local DEST=$2 + content="" + content2="" + content3="" + if [[ $preinstall == '1' ]] + then + content="dbfilter = $db_name" + else + content="db_name = $db_name" + if [[ $app_version > 9 ]] + then + content2="dbfilter = False" + fi + content3="list_db = False" + fi + mkdir -p "$(dirname $DEST)" if [ -f '../manifest.json' ] ; then - ynh_render_template "${YNH_CWD}/../conf/$TEMPLATE.j2" "$DEST" + ynh_add_config "${YNH_CWD}/../conf/$TEMPLATE.j2" "$DEST" else - ynh_render_template "${YNH_CWD}/../settings/conf/$TEMPLATE.j2" "$DEST" + ynh_add_config "${YNH_CWD}/../settings/conf/$TEMPLATE.j2" "$DEST" fi } diff --git a/scripts/backup b/scripts/backup index 3413100..6ddf741 100644 --- a/scripts/backup +++ b/scripts/backup @@ -14,7 +14,7 @@ final_path=$(ynh_app_setting_get "$app" final_path) conf_file=$(ynh_app_setting_get "$app" conf_file) # Backup sources & data -ynh_backup "${final_path}/$APPNAME" +ynh_backup "${final_path}/$appname" ynh_backup "${final_path}/custom-addons" ynh_backup "${final_path}/.local" diff --git a/scripts/install b/scripts/install index 82e8434..eb13e98 100644 --- a/scripts/install +++ b/scripts/install @@ -15,12 +15,12 @@ export app_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/$FORKNAME-bin" +export bin_file="$final_path/venv/bin/python3 $final_path/$appname/$FORKNAME-bin" if [ "$app_version" = "9" ]; then - bin_file="$final_path/venv/bin/python $final_path/$APPNAME/$FORKNAME.py" + bin_file="$final_path/venv/bin/python3 $final_path/$appname/$FORKNAME.py" fi if [ "$app_version" = "8" ]; then - bin_file="$final_path/venv/bin/python $final_path/$APPNAME/$FORKNAME.py" + bin_file="$final_path/venv/bin/python3 $final_path/$appname/$FORKNAME.py" fi export db_name=$(ynh_sanitize_dbid $app) export port=$(ynh_find_port 8069) @@ -43,8 +43,9 @@ function setup_database() { ynh_configure server.conf $conf_file chown $app:$app $conf_file # Load translation - #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=" --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 " + sudo -u $app $bin_file -c $conf_file --stop-after-init -i base -d $app 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 --load-language $lang -d $app # Configure language, timezone and ldap diff --git a/scripts/restore b/scripts/restore index ac1e39f..5c9eaa1 100644 --- a/scripts/restore +++ b/scripts/restore @@ -19,12 +19,12 @@ export db_pass=$(ynh_app_setting_get $app psqlpwd) export final_path=$(ynh_app_setting_get $app final_path) export conf_file=$(ynh_app_setting_get $app conf_file) export is_public=0 -export bin_file="$final_path/venv/bin/python $final_path/$APPNAME/$FORKNAME-bin" +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" + bin_file="$final_path/venv/bin/python $final_path/$appname/$FORKNAME.py" fi if [ "$app_version" = "8" ]; then - bin_file="$final_path/venv/bin/python $final_path/$APPNAME/$FORKNAME.py" + bin_file="$final_path/venv/bin/python $final_path/$appname/$FORKNAME.py" fi #================================================= From 8a5942f5fdee899d1e93c9bc0d9b32f831577dc1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 15 Feb 2022 21:22:47 +0100 Subject: [PATCH 2/5] Fix ffi.h: No such file or directory --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index b6b83b4..2f1b319 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,7 +4,7 @@ export appname="libreerp" export FORKNAME="odoo" -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" +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 libffi-dev" function debranding() { # Remove Odoo references to avoid trademark issue From e7b3b20cfaad12f458fff892cec6e10750acf005 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 16 Feb 2022 01:26:09 +0100 Subject: [PATCH 3/5] Fix restore --- scripts/restore | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/restore b/scripts/restore index 5c9eaa1..62df297 100644 --- a/scripts/restore +++ b/scripts/restore @@ -26,6 +26,7 @@ fi if [ "$app_version" = "8" ]; then bin_file="$final_path/venv/bin/python $final_path/$appname/$FORKNAME.py" fi +export preinstall=0 #================================================= # CHECK IF THE APP CAN BE RESTORED From a04bcba013180c60c4b83a45b8dd690133055d34 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 16 Feb 2022 08:27:43 +0100 Subject: [PATCH 4/5] Bullseye dependencies --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 2f1b319..29d5621 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,7 +4,7 @@ export appname="libreerp" export FORKNAME="odoo" -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 libffi-dev" +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 libjpeg-dev zlib1g-dev libfreetype6-dev libffi-dev" function debranding() { # Remove Odoo references to avoid trademark issue From 4572473dae73d0d0f352e6e1bf7b16fa0a1f91eb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 16 Feb 2022 20:03:36 +0100 Subject: [PATCH 5/5] Fix fatal error: libpq-fe.h: No such file or directory on bullseye --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 29d5621..463f944 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,7 +4,7 @@ export appname="libreerp" export FORKNAME="odoo" -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 libjpeg-dev zlib1g-dev libfreetype6-dev libffi-dev" +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 libjpeg-dev zlib1g-dev libfreetype6-dev libffi-dev libpq-dev" function debranding() { # Remove Odoo references to avoid trademark issue