From 463bea48fd28373900b3d5847d7d09dab8f1c249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 16:48:42 +0100 Subject: [PATCH] fix permission, continue --- scripts/_common.sh | 18 +++++++++++++----- scripts/install | 3 ++- scripts/restore | 26 ++------------------------ 3 files changed, 17 insertions(+), 30 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 6abb099..309e2d2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -22,16 +22,24 @@ set_permission() { chown $app:root -R /var/lib/pgadmin mkdir -p /var/log/pgadmin chown $app:root -R /var/log/pgadmin - chown $app:root /var/log/uwsgi/$app - chown $app:root /etc/uwsgi/apps-available/$app.ini chmod u=rwX,g=rX,o= -R /var/lib/pgadmin } -_install_pgadmin_venv() { - ynh_exec_as "$app" python3 -m venv --upgrade "$install_dir/venv" - venvpy="$install_dir/venv/bin/python3" +ynh_install_venv() { + if [ -f "$install_dir/venv/bin/python" ]; then + ynh_exec_as "$app" python3 -m venv "$install_dir/venv" --upgrade + else + ynh_exec_as "$app" python3 -m venv "$install_dir/venv" + fi + ynh_use_venv ynh_exec_as "$app" "$venvpy" -m pip install --upgrade --no-cache-dir pip wheel +} +ynh_use_venv() { + venvpy="$install_dir/venv/bin/python3" +} + +_install_pgadmin_pip() { ynh_exec_as "$app" "$venvpy" -m pip install --upgrade --no-cache-dir --ignore-installed "psycopg[c]" cp "$YNH_APP_BASEDIR/conf/requirement_$(lsb_release --codename --short).txt" "$install_dir/requirements.txt" diff --git a/scripts/install b/scripts/install index 14c5049..2438a40 100644 --- a/scripts/install +++ b/scripts/install @@ -20,8 +20,9 @@ email=$(ynh_user_get_info --username $admin --key 'mail') # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." +ynh_install_venv -_install_pgadmin_venv +_install_pgadmin_pip setup_dir diff --git a/scripts/restore b/scripts/restore index a80929d..eef371c 100644 --- a/scripts/restore +++ b/scripts/restore @@ -23,15 +23,6 @@ ynh_restore_file --origin_path="$install_dir" ### ownership to all files such as after the ynh_setup_source step chown -R "$app:www-data" "$install_dir" - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." - - #================================================= # RESTORE THE POSTGRESQL SUPERUSER #================================================= @@ -39,19 +30,12 @@ ynh_script_progression --message="Restoring the Postgresql superuser..." --weigh ynh_psql_execute_as_root --sql "CREATE USER ${db_user} WITH PASSWORD '${db_pwd}' SUPERUSER CREATEDB CREATEROLE REPLICATION" -#================================================= -# SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=5 +ynh_script_progression --message="Updating python virtualenv..." --weight=5 -# Define and install dependencies -#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - -# Check that the good python version is installed -# If not upgrade the source -install_source +ynh_install_venv #================================================= # RESTORE SYSTEM CONFIGURATIONS @@ -79,12 +63,6 @@ ynh_restore_uwsgi_service ynh_script_progression --message="Protecting directory..." set_permission -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." - - #================================================= # START SYSTEMD SERVICE #=================================================