mirror of
https://github.com/YunoHost-Apps/libreerp_ynh.git
synced 2024-09-03 19:36:13 +02:00
[fix] Upgrade and restore
This commit is contained in:
parent
1aeb936572
commit
b557245b5e
7 changed files with 91 additions and 39 deletions
|
@ -13,7 +13,7 @@
|
||||||
"previous_maintainers": {
|
"previous_maintainers": {
|
||||||
"name": "scith"
|
"name": "scith"
|
||||||
},
|
},
|
||||||
"version": "12.0-1",
|
"version": "12.0-5",
|
||||||
"url": "https://github.com/YunoHost-Apps/libreerp_ynh",
|
"url": "https://github.com/YunoHost-Apps/libreerp_ynh",
|
||||||
"license": "LGPL-3.0,AGPL-3.0",
|
"license": "LGPL-3.0,AGPL-3.0",
|
||||||
"requirements": {
|
"requirements": {
|
||||||
|
|
|
@ -6,10 +6,7 @@ export APPNAME="libreerp"
|
||||||
export FORKNAME="odoo"
|
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"
|
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"
|
||||||
|
|
||||||
function setup_files() {
|
function debranding() {
|
||||||
|
|
||||||
ynh_setup_source $final_path/$APPNAME $app_version
|
|
||||||
|
|
||||||
# Remove Odoo references to avoid trademark issue
|
# Remove Odoo references to avoid trademark issue
|
||||||
if [ -d $final_path/$APPNAME/$FORKNAME ]; then
|
if [ -d $final_path/$APPNAME/$FORKNAME ]; then
|
||||||
python_app=$final_path/$APPNAME/$FORKNAME
|
python_app=$final_path/$APPNAME/$FORKNAME
|
||||||
|
@ -24,21 +21,29 @@ function setup_files() {
|
||||||
sed -i 's/<a[^>]*>Documentation<\/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
|
sed -i 's/<a[^>]*>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/logo_type.png $python_app/addons/base/static/img/logo_white.png
|
||||||
|
|
||||||
|
}
|
||||||
|
function setup_files() {
|
||||||
|
|
||||||
|
ynh_setup_source $final_path/$APPNAME $app_version
|
||||||
|
debranding
|
||||||
mkdir -p $final_path/custom-addons
|
mkdir -p $final_path/custom-addons
|
||||||
chown -R $app:$app $final_path
|
chown -R $app:$app $final_path
|
||||||
ynh_configure server.conf $conf_file
|
|
||||||
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
|
|
||||||
else
|
|
||||||
ynh_replace_string "'auto_install': False" "'auto_install': True" ${final_path}/$APPNAME/addons/auth_ldap/__openerp__.py
|
|
||||||
fi
|
|
||||||
|
|
||||||
touch /var/log/$app.log
|
touch /var/log/$app.log
|
||||||
chown $app:$app /var/log/$app.log
|
chown $app:$app /var/log/$app.log
|
||||||
|
|
||||||
|
if [ ! -f $conf_file ]; then
|
||||||
|
ynh_configure server.conf $conf_file
|
||||||
|
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
|
||||||
|
else
|
||||||
|
ynh_replace_string "'auto_install': False" "'auto_install': True" ${final_path}/$APPNAME/addons/auth_ldap/__openerp__.py
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
function install_dependencies() {
|
function install_dependencies() {
|
||||||
|
@ -47,7 +52,14 @@ function install_dependencies() {
|
||||||
|
|
||||||
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
|
||||||
ynh_setup_source /usr/
|
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
|
||||||
fi
|
fi
|
||||||
pushd $final_path
|
pushd $final_path
|
||||||
if grep "python3" $final_path/$APPNAME/$FORKNAME-bin ; then
|
if grep "python3" $final_path/$APPNAME/$FORKNAME-bin ; then
|
||||||
|
|
|
@ -33,7 +33,11 @@ ynh_configure () {
|
||||||
local TEMPLATE=$1
|
local TEMPLATE=$1
|
||||||
local DEST=$2
|
local DEST=$2
|
||||||
mkdir -p "$(dirname $DEST)"
|
mkdir -p "$(dirname $DEST)"
|
||||||
ynh_render_template "${YNH_CWD}/../conf/$TEMPLATE.j2" "$DEST"
|
if [ -f '../manifest.json' ] ; then
|
||||||
|
ynh_render_template "${YNH_CWD}/../conf/$TEMPLATE.j2" "$DEST"
|
||||||
|
else
|
||||||
|
ynh_render_template "${YNH_CWD}/../settings/conf/$TEMPLATE.j2" "$DEST"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
ynh_configure_nginx () {
|
ynh_configure_nginx () {
|
||||||
|
@ -323,3 +327,48 @@ ynh_del_swap () {
|
||||||
rm /swap
|
rm /swap
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Checks the app version to upgrade with the existing app version and returns:
|
||||||
|
# - UPGRADE_APP if the upstream app version has changed
|
||||||
|
# - UPGRADE_PACKAGE if only the YunoHost package has changed
|
||||||
|
#
|
||||||
|
## It stops the current script without error if the package is up-to-date
|
||||||
|
#
|
||||||
|
# This helper should be used to avoid an upgrade of an app, or the upstream part
|
||||||
|
# of it, when it's not needed
|
||||||
|
#
|
||||||
|
# To force an upgrade, even if the package is up to date,
|
||||||
|
# you have to set the variable YNH_FORCE_UPGRADE before.
|
||||||
|
# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp
|
||||||
|
|
||||||
|
# usage: ynh_check_app_version_changed
|
||||||
|
ynh_check_app_version_changed () {
|
||||||
|
local force_upgrade=${YNH_FORCE_UPGRADE:-0}
|
||||||
|
local package_check=${PACKAGE_CHECK_EXEC:-0}
|
||||||
|
|
||||||
|
# By default, upstream app version has changed
|
||||||
|
local return_value="UPGRADE_APP"
|
||||||
|
|
||||||
|
local current_version=$(ynh_read_json "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" "version" || echo 1.0)
|
||||||
|
local current_upstream_version="${current_version/~ynh*/}"
|
||||||
|
local update_version=$(ynh_read_manifest "version" || echo 1.0)
|
||||||
|
local update_upstream_version="${update_version/~ynh*/}"
|
||||||
|
|
||||||
|
if [ "$current_version" == "$update_version" ] ; then
|
||||||
|
# Complete versions are the same
|
||||||
|
if [ "$force_upgrade" != "0" ]
|
||||||
|
then
|
||||||
|
echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2
|
||||||
|
unset YNH_FORCE_UPGRADE
|
||||||
|
elif [ "$package_check" != "0" ]
|
||||||
|
then
|
||||||
|
echo "Upgrade forced for package check." >&2
|
||||||
|
else
|
||||||
|
ynh_die "Up-to-date, nothing to do" 0
|
||||||
|
fi
|
||||||
|
elif [ "$current_upstream_version" == "$update_upstream_version" ] ; then
|
||||||
|
# Upstream versions are the same, only YunoHost package versions differ
|
||||||
|
return_value="UPGRADE_PACKAGE"
|
||||||
|
fi
|
||||||
|
echo $return_value
|
||||||
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ export port_chat=$(ynh_find_port 8072)
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
||||||
#=================================================
|
#=================================================
|
||||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||||
ynh_webpath_available $domain "/"
|
|
||||||
ynh_webpath_register $app $domain "/"
|
ynh_webpath_register $app $domain "/"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,14 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
# Retrieve app settings
|
# Retrieve app settings
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||||
|
conf_file=$(ynh_app_setting_get "$app" conf_file)
|
||||||
|
|
||||||
yunohost service stop $app
|
yunohost service stop $app
|
||||||
yunohost service remove $app
|
yunohost service remove $app
|
||||||
ynh_psql_remove_db $app $app
|
ynh_psql_remove_db $app $app
|
||||||
|
|
||||||
ynh_secure_remove "$final_path"
|
ynh_secure_remove "$final_path"
|
||||||
|
ynh_secure_remove "$conf_file"
|
||||||
|
|
||||||
ynh_remove_app_dependencies
|
ynh_remove_app_dependencies
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,13 @@ export db_pass=$(ynh_app_setting_get $app psqlpwd)
|
||||||
export final_path=$(ynh_app_setting_get $app final_path)
|
export final_path=$(ynh_app_setting_get $app final_path)
|
||||||
export conf_file=$(ynh_app_setting_get $app conf_file)
|
export conf_file=$(ynh_app_setting_get $app conf_file)
|
||||||
export is_public=0
|
export is_public=0
|
||||||
|
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"
|
||||||
|
fi
|
||||||
|
if [ "$app_version" = "8" ]; then
|
||||||
|
bin_file="$final_path/venv/bin/python $final_path/$APPNAME/$FORKNAME.py"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
|
|
|
@ -19,17 +19,18 @@ source _common.sh
|
||||||
export app=$YNH_APP_INSTANCE_NAME
|
export app=$YNH_APP_INSTANCE_NAME
|
||||||
export domain=$(ynh_app_setting_get "$app" domain)
|
export domain=$(ynh_app_setting_get "$app" domain)
|
||||||
export app_version=$(ynh_app_setting_get "$app" app_version)
|
export app_version=$(ynh_app_setting_get "$app" app_version)
|
||||||
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 port_chat=$(ynh_app_setting_get $app port_chat)
|
||||||
export is_public=0
|
export is_public=0
|
||||||
export major_upgrade=$(ynh_app_setting_get $app major_upgrade)
|
export final_path=$(ynh_app_setting_get $app final_path)
|
||||||
|
export conf_file=$(ynh_app_setting_get $app conf_file)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_abort_if_up_to_date
|
ynh_check_app_version_changed
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
|
@ -50,24 +51,6 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# STEP Migrations
|
# STEP Migrations
|
||||||
#=================================================
|
#=================================================
|
||||||
# Zamentur version https://github.com/zamentur/odoo_ynh/commit/cdeb9afbf218431781f752dedfbf4247afbd5b44
|
|
||||||
if ynh_version_le "9.0-0" ; then
|
|
||||||
# set new args
|
|
||||||
app_version=${app_version:-$(ynh_app_setting_get "$app" version)}
|
|
||||||
port=${port:-8069}
|
|
||||||
oca=${oca:-false}
|
|
||||||
ynh_save_args app_version oca is_master port
|
|
||||||
|
|
||||||
# Install official debian package
|
|
||||||
install_dependencies
|
|
||||||
fi
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
ynh_system_user_create $app
|
ynh_system_user_create $app
|
||||||
setup_files
|
setup_files
|
||||||
install_dependencies
|
install_dependencies
|
||||||
|
|
Loading…
Reference in a new issue