1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pyinventory_ynh.git synced 2024-09-03 20:16:09 +02:00
JensDiemer 2022-01-17 18:41:37 +01:00
parent 877e54a8db
commit 74c4035c12
5 changed files with 32 additions and 44 deletions

View file

@ -27,6 +27,31 @@ log_file="${log_path}/pyinventory.log"
# dependencies used by the app # dependencies used by the app
pkg_dependencies="build-essential python3-dev python3-pip python3-venv git libpq-dev postgresql postgresql-contrib libjpeg-dev" pkg_dependencies="build-essential python3-dev python3-pip python3-venv git libpq-dev postgresql postgresql-contrib libjpeg-dev"
#=================================================
# PyInventory shared functions
#=================================================
setup_venv() {
ynh_script_progression --message="Setup Python virtualenv..." --weight=15
# Always recreate everything fresh with current python version
ynh_secure_remove "${final_path}/venv"
python3 -m venv --without-pip "${final_path}/venv"
cp ../conf/requirements.txt "$final_path/requirements.txt"
chown -R "$app:" "$final_path"
(
# Activate venv in sub shell
set +o nounset
source "${final_path}/venv/bin/activate"
set -o nounset
ynh_exec_as $app $final_path/venv/bin/python3 -m ensurepip
ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade wheel pip
ynh_exec_as $app $final_path/venv/bin/pip3 install --no-deps -r "$final_path/requirements.txt"
)
}
#================================================= #=================================================
# Redis HELPERS # Redis HELPERS
#================================================= #=================================================

View file

@ -38,7 +38,7 @@ redis_db=$(ynh_app_setting_get --app="$app" --key=redis_db)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=40 ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=15
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade

View file

@ -63,7 +63,7 @@ redis_db=$(ynh_redis_get_free_db)
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=40 ynh_script_progression --message="Installing dependencies..." --weight=10
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
@ -101,20 +101,7 @@ ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell
#================================================= #=================================================
# PIP INSTALLATION # PIP INSTALLATION
#================================================= #=================================================
ynh_script_progression --message="Install project via pip..." --weight=80 setup_venv # function defined in _common.sh
python3 -m venv "${final_path}/venv"
cp ../conf/requirements.txt "$final_path/requirements.txt"
chown -R "$app:" "$final_path"
#run source in a 'sub shell'
(
set +o nounset
source "${final_path}/venv/bin/activate"
set -o nounset
ynh_exec_as $app $final_path/venv/bin/pip install --upgrade wheel pip
ynh_exec_as $app $final_path/venv/bin/pip install --no-deps -r "$final_path/requirements.txt"
)
#================================================= #=================================================
# copy config files # copy config files

View file

@ -78,7 +78,7 @@ chown -R "$app:" "$final_path"
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=40 ynh_script_progression --message="Reinstalling dependencies..." --weight=10
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
@ -86,18 +86,7 @@ ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
# REINSTALL PYTHON VIRTUALENV # REINSTALL PYTHON VIRTUALENV
# Maybe the backup contains a other Python version # Maybe the backup contains a other Python version
#================================================= #=================================================
ynh_script_progression --message="Upgrade Python virtualenv..." --weight=10 setup_venv # function defined in _common.sh
python3 -m venv --upgrade "${final_path}/venv"
#run source in a 'sub shell'
(
set +o nounset
source "${final_path}/venv/bin/activate"
set -o nounset
ynh_exec_as $app $final_path/venv/bin/pip install --upgrade wheel pip
ynh_exec_as $app $final_path/venv/bin/pip install --no-deps -r "$final_path/requirements.txt"
)
#================================================= #=================================================
# RESTORE THE PostgreSQL DATABASE # RESTORE THE PostgreSQL DATABASE

View file

@ -29,7 +29,7 @@ redis_db=$(ynh_app_setting_get --app="$app" --key=redis_db)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=40 ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=15
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -85,20 +85,7 @@ ynh_add_systemd_config --service="$app" --template="pyinventory.service"
#================================================= #=================================================
# UPGRADE VENV # UPGRADE VENV
#================================================= #=================================================
ynh_script_progression --message="Upgrade project via pip..." --weight=80 setup_venv # function defined in _common.sh
python3 -m venv --upgrade "${final_path}/venv"
cp ../conf/requirements.txt "$final_path/requirements.txt"
chown -R "$app:" "$final_path"
#run source in a 'sub shell'
(
set +o nounset
source "${final_path}/venv/bin/activate"
set -o nounset
ynh_exec_as $app $final_path/venv/bin/pip install --upgrade wheel pip
ynh_exec_as $app $final_path/venv/bin/pip install --no-deps -r "$final_path/requirements.txt"
)
#================================================= #=================================================
# copy config files # copy config files