Merge pull request #6 from zamentur/master

Upgrade Odoo
This commit is contained in:
Jeff 2018-05-22 08:00:22 +02:00 committed by GitHub
commit db43e6ddc1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 109 additions and 22 deletions

14
conf/odoo.service.j2 Normal file
View file

@ -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

5
conf/openupgrade.src Normal file
View file

@ -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

View file

@ -10,7 +10,7 @@
"name": "scith, ljf", "name": "scith, ljf",
"email": "ljf+yunohost@grimaud.me" "email": "ljf+yunohost@grimaud.me"
}, },
"version": "10.0-1", "version": "11.0-1",
"url": "https://www.odoo.com", "url": "https://www.odoo.com",
"license": "LGPL-3.0", "license": "LGPL-3.0",
"requirements": { "requirements": {
@ -35,8 +35,8 @@
"en": "Which version of Odoo do you want to install?", "en": "Which version of Odoo do you want to install?",
"fr": "Quelle version d'Odoo souhaitez-vous installer ?" "fr": "Quelle version d'Odoo souhaitez-vous installer ?"
}, },
"choices": ["8.0", "9.0", "10.0"], "choices": ["8.0", "9.0", "10.0", "11.0"],
"default": "9.0" "default": "11.0"
}, { }, {
"name": "oca", "name": "oca",
"type": "boolean", "type": "boolean",

View file

@ -7,13 +7,17 @@ APPNAME="odoo"
function define_paths() { function define_paths() {
# In odoo 10 some file change # In odoo 10 some file change
if [ $(echo "$odoo_version >= 10" | bc) -ne 0 ]; then if [ $(echo "$odoo_version >= 10" | bc) -ne 0 ]; then
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/ export source_path=/usr/lib/python2.7/dist-packages/odoo/
conf_file=/etc/odoo/odoo.conf fi
bin_file=/usr/bin/odoo export conf_file=/etc/odoo/odoo.conf
export bin_file=/usr/bin/odoo
else else
export source_path=/usr/lib/python2.7/dist-packages/openerp/ export source_path=/usr/lib/python2.7/dist-packages/openerp/
conf_file=/etc/odoo/openerp-server.conf export conf_file=/etc/odoo/openerp-server.conf
bin_file=/usr/bin/openerp-server export bin_file=/usr/bin/openerp-server
fi fi
} }
@ -70,7 +74,7 @@ function install_dependencies() {
if [ ! -f /etc/apt/sources.list.d/odoo.list ]; then if [ ! -f /etc/apt/sources.list.d/odoo.list ]; then
# Install Odoo # Install Odoo
# Prepare installation # Prepare installation
ynh_package_install curl ynh_package_install curl bc
# Install Odoo # Install Odoo
curl -sS https://nightly.odoo.com/odoo.key | sudo apt-key add - 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/ # TODO if 8.0 install https://www.odoo.com/apps/modules/8.0/shell/
fi 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 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 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 # The debian package has a bug so we deploy a more recent version
@ -106,9 +114,13 @@ function add_services() {
yunohost service add postgresql yunohost service add postgresql
fi fi
if ! grep "^odoo:$" /etc/yunohost/services.yml; then 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 add odoo --log /var/log/odoo/odoo-server.log
yunohost service stop odoo yunohost service stop odoo
yunohost service start odoo yunohost service start odoo
yunohost service enable odoo
fi fi
} }

View file

@ -203,3 +203,26 @@ exec_as() {
sudo sudo -u "$USER" "$@" sudo sudo -u "$USER" "$@"
fi 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
}

View file

@ -1,13 +1,19 @@
#!/bin/bash #!/bin/bash
set -eu #=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Source YunoHost helpers # Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
source _future.sh source _future.sh
source _common.sh source _common.sh
ynh_trap_on #=================================================
# LOAD SETTINGS
#=================================================
# Retrieve arguments # Retrieve arguments
export app=$YNH_APP_INSTANCE_NAME 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 oca=$(ynh_app_setting_get "$app" oca)
export port=$(ynh_app_setting_get $app port) export port=$(ynh_app_setting_get $app port)
export is_public=0 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_abort_if_up_to_date
ynh_check_var "$app" "app name not set"
# 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 # 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 # set new args
odoo_version=${odoo_version:-$(ynh_app_setting_get "$app" version)} odoo_version=${odoo_version:-$(ynh_app_setting_get "$app" version)}
if [ "$is_master" = "" ]; then if [ "$is_master" = "" ]; then
@ -46,9 +74,14 @@ if [ "${version}" = "9.0-0" ]; then
install_dependencies install_dependencies
fi fi
if [ "${version}" = "10.0-1" ]; then if ynh_version_le "11.0-1" ; then
# Put here your migrations # By default we don't upgrade to major version
echo "" major_upgrade=${major_upgrade:-0}
ynh_save_args major_upgrade
fi fi
# Upgrade official package
apt-get install odoo -y -qq