diff --git a/conf/odoo.service.j2 b/conf/odoo.service.j2 new file mode 100644 index 0000000..c6ba300 --- /dev/null +++ b/conf/odoo.service.j2 @@ -0,0 +1,14 @@ +[Unit] +Description=Odoo +After=network.target + +[Service] +Type=simple +User=odoo +Environment=PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin +ExecStart={{ bin_file }} --config {{ conf_file }} > /var/log/odoo/odoo-server.log 2>&1 +Restart=always +RestartSec=3 + +[Install] +WantedBy=multi-user.target diff --git a/conf/openupgrade.src b/conf/openupgrade.src new file mode 100644 index 0000000..7bba77f --- /dev/null +++ b/conf/openupgrade.src @@ -0,0 +1,5 @@ +SOURCE_URL=https://raw.githubusercontent.com/OCA/OpenUpgrade/11.0/scripts/migrate.py +SOURCE_SUM=362c8cf9b43a3aaddb440e642205e9596da78e28d1e47b582612ced671d95e0b +SOURCE_FILE=odoo-migrate-11.py +SOURCE_SUM_PRG=sha256sum +SOURCE_EXTRACT=False diff --git a/manifest.json b/manifest.json index e1e4fb1..11cfe60 100644 --- a/manifest.json +++ b/manifest.json @@ -10,7 +10,7 @@ "name": "scith, ljf", "email": "ljf+yunohost@grimaud.me" }, - "version": "10.0-1", + "version": "11.0-1", "url": "https://www.odoo.com", "license": "LGPL-3.0", "requirements": { @@ -35,8 +35,8 @@ "en": "Which version of Odoo do you want to install?", "fr": "Quelle version d'Odoo souhaitez-vous installer ?" }, - "choices": ["8.0", "9.0", "10.0"], - "default": "9.0" + "choices": ["8.0", "9.0", "10.0", "11.0"], + "default": "11.0" }, { "name": "oca", "type": "boolean", diff --git a/scripts/_common.sh b/scripts/_common.sh index 2228359..f24ac78 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,13 +7,17 @@ APPNAME="odoo" function define_paths() { # In odoo 10 some file change if [ $(echo "$odoo_version >= 10" | bc) -ne 0 ]; then - export source_path=/usr/lib/python2.7/dist-packages/odoo/ - conf_file=/etc/odoo/odoo.conf - bin_file=/usr/bin/odoo + if [ $(echo "$odoo_version >= 11" | bc) -ne 0 ]; then + export source_path=/usr/lib/python3/dist-packages/odoo/ + else + export source_path=/usr/lib/python2.7/dist-packages/odoo/ + fi + export conf_file=/etc/odoo/odoo.conf + export bin_file=/usr/bin/odoo else export source_path=/usr/lib/python2.7/dist-packages/openerp/ - conf_file=/etc/odoo/openerp-server.conf - bin_file=/usr/bin/openerp-server + export conf_file=/etc/odoo/openerp-server.conf + export bin_file=/usr/bin/openerp-server fi } @@ -70,7 +74,7 @@ function install_dependencies() { if [ ! -f /etc/apt/sources.list.d/odoo.list ]; then # Install Odoo # Prepare installation - ynh_package_install curl + ynh_package_install curl bc # Install Odoo curl -sS https://nightly.odoo.com/odoo.key | sudo apt-key add - @@ -78,9 +82,13 @@ function install_dependencies() { # TODO if 8.0 install https://www.odoo.com/apps/modules/8.0/shell/ fi + if is_jessie ; then + sudo echo "deb http://http.debian.net/debian jessie-backports main" | sudo tee /etc/apt/sources.list.d/jessie-backport.list + fi apt-get update - ynh_install_app_dependencies curl postgresql odoo xfonts-75dpi xfonts-base wkhtmltopdf node-less python-xlrd + ynh_install_app_dependencies curl postgresql odoo xfonts-75dpi xfonts-base wkhtmltopdf node-less python-xlrd python3-dev gcc libldap2-dev libssl-dev libsasl2-dev python3-pip + pip3 install pyldap 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 @@ -106,9 +114,13 @@ function add_services() { yunohost service add postgresql fi if ! grep "^odoo:$" /etc/yunohost/services.yml; then + ynh_configure odoo.service /etc/systemd/system/odoo.service + rm /etc/init.d/odoo + yunohost service add odoo --log /var/log/odoo/odoo-server.log yunohost service stop odoo yunohost service start odoo + yunohost service enable odoo fi } diff --git a/scripts/_future.sh b/scripts/_future.sh index d68da67..ff18dad 100644 --- a/scripts/_future.sh +++ b/scripts/_future.sh @@ -203,3 +203,26 @@ exec_as() { sudo sudo -u "$USER" "$@" fi } + +ynh_debian_release () { + lsb_release --codename --short +} + +is_stretch () { + if [ "$(ynh_debian_release)" == "stretch" ] + then + return 0 + else + return 1 + fi +} + +is_jessie () { + if [ "$(ynh_debian_release)" == "jessie" ] + then + return 0 + else + return 1 + fi +} + diff --git a/scripts/upgrade b/scripts/upgrade index 51aed46..b0948a1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,13 +1,19 @@ #!/bin/bash -set -eu +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= # Source YunoHost helpers source /usr/share/yunohost/helpers source _future.sh source _common.sh -ynh_trap_on +#================================================= +# LOAD SETTINGS +#================================================= # Retrieve arguments export app=$YNH_APP_INSTANCE_NAME @@ -17,18 +23,40 @@ export is_master=$(ynh_app_setting_get "$app" is_master) export oca=$(ynh_app_setting_get "$app" oca) export port=$(ynh_app_setting_get $app port) export is_public=0 +export major_upgrade=$(ynh_app_setting_get $app major_upgrade) -version=$(ynh_read_json "/etc/yunohost/apps/$app/manifest.json" 'version' 2> /dev/null || echo '9.0-0') -last_version=$(ynh_read_manifest 'version') +#================================================= +# CHECK VERSION +#================================================= -#ynh_exit_if_up_to_date -ynh_check_var "$app" "app name not set" +ynh_abort_if_up_to_date -# Upgrade official package -apt-get install odoo -y -qq +#================================================= +# STANDARD UPGRADE STEPS +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# CHECK THE PATH +#================================================= + +path_url=$(ynh_normalize_url_path $path_url) # VĂ©rifie et corrige la syntaxe du path. + +#================================================= +# STEP Migrations +#================================================= # Zamentur version https://github.com/zamentur/odoo_ynh/commit/cdeb9afbf218431781f752dedfbf4247afbd5b44 -if [ "${version}" = "9.0-0" ]; then +if ynh_version_le "9.0-0" ; then # set new args odoo_version=${odoo_version:-$(ynh_app_setting_get "$app" version)} if [ "$is_master" = "" ]; then @@ -46,9 +74,14 @@ if [ "${version}" = "9.0-0" ]; then install_dependencies fi -if [ "${version}" = "10.0-1" ]; then - # Put here your migrations - echo "" +if ynh_version_le "11.0-1" ; then + # By default we don't upgrade to major version + major_upgrade=${major_upgrade:-0} + ynh_save_args major_upgrade fi +# Upgrade official package +apt-get install odoo -y -qq + +