From da90e7957a1a365f3c840df02c41cd14592030db Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 31 Oct 2023 14:28:57 +0000 Subject: [PATCH 01/59] Auto-update README --- README.md | 1 + README_fr.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 5c2a548..d253d8c 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ This app actually don't support the SSO and don't support LDAP. After the instal * Official app website: * Official admin documentation: +* YunoHost Store: * Report a bug: ## Developer info diff --git a/README_fr.md b/README_fr.md index 68e9d2b..59b39a1 100644 --- a/README_fr.md +++ b/README_fr.md @@ -35,6 +35,7 @@ This app actually don't support the SSO and don't support LDAP. After the instal * Site officiel de l’app : * Documentation officielle de l’admin : +* YunoHost Store: * Signaler un bug : ## Informations pour les développeurs From 205b0028dc7fbd0ff82ea4ad81c9f31d71f3198c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 11:36:14 +0100 Subject: [PATCH 02/59] update packagingv2 --- conf/armv7_bookworm.src | 11 ---- conf/armv7_bullseye.src | 11 ---- conf/uwsgi.ini | 6 +- manifest.toml | 68 +++++++++++++++++++++++ scripts/_common.sh | 52 +++++++++--------- scripts/backup | 14 ++--- scripts/change_url | 73 ++++++++++++------------- scripts/install | 118 ++++------------------------------------ scripts/remove | 24 ++++---- scripts/restore | 33 ++++++----- scripts/upgrade | 37 ++++++------- 11 files changed, 196 insertions(+), 251 deletions(-) delete mode 100644 conf/armv7_bookworm.src delete mode 100644 conf/armv7_bullseye.src create mode 100644 manifest.toml diff --git a/conf/armv7_bookworm.src b/conf/armv7_bookworm.src deleted file mode 100644 index 27506b0..0000000 --- a/conf/armv7_bookworm.src +++ /dev/null @@ -1,11 +0,0 @@ -SOURCE_URL=https://github.com/Josue-T/pgadmin_python_build/releases/download/v4-7.7/pgadmin_4-7.7-bookworm-bin1_armv7l.tar.gz -SOURCE_SUM=e18206853ced73eb1922182c5a3c825d8af21d5e40fcd607311cc4e075a28e72 -# (Optional) Program to check the integrity (sha256sum, md5sum...) -# default: sha256 -SOURCE_SUM_PRG=sha256sum -# (Optional) Archive format -# default: tar.gz -SOURCE_FORMAT=tar.gz -# (Optional) Put false if sources are directly in the archive root -# default: true -SOURCE_IN_SUBDIR=true diff --git a/conf/armv7_bullseye.src b/conf/armv7_bullseye.src deleted file mode 100644 index 3095133..0000000 --- a/conf/armv7_bullseye.src +++ /dev/null @@ -1,11 +0,0 @@ -SOURCE_URL=https://github.com/Josue-T/pgadmin_python_build/releases/download/v4-7.7/pgadmin_4-7.7-bullseye-bin1_armv7l.tar.gz -SOURCE_SUM=76022eeab9c985a30dab8b24027db095f74eb491077de01db77100e320b4a2e5 -# (Optional) Program to check the integrity (sha256sum, md5sum...) -# default: sha256 -SOURCE_SUM_PRG=sha256sum -# (Optional) Archive format -# default: tar.gz -SOURCE_FORMAT=tar.gz -# (Optional) Put false if sources are directly in the archive root -# default: true -SOURCE_IN_SUBDIR=true diff --git a/conf/uwsgi.ini b/conf/uwsgi.ini index a202330..b5c0b7b 100644 --- a/conf/uwsgi.ini +++ b/conf/uwsgi.ini @@ -19,9 +19,9 @@ manage-script-name = true mount = __PATH__=pgAdmin4.py # Virtualenv and python path -virtualenv = __FINALPATH__ -pythonpath = __FINALPATH__ -chdir = __FINALPATH__/lib/python__PYTHON_VERSION__/site-packages/pgadmin4 +virtualenv = __INSTALL_DIR__ +pythonpath = __INSTALL_DIR__ +chdir = __INSTALL_DIR__/lib/python__PYTHON_VERSION__/site-packages/pgadmin4 # The variable holding flask application callable = app diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..1fd2129 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,68 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + +packaging_format = 2 + +id = "pgadmin" +name = "pgAdmin4" +description.en = "Manage PostgreSQL databases over the web" +description.fr = "Application web de gestion des bases de données PostgreSQL" + +version = "7.7~ynh1" + +maintainers = ["Josué Tille"] + +[upstream] +license = "PostgreSQL" +website = "https://www.pgadmin.org" +admindoc = "https://www.pgadmin.org/docs" +cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) +fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. + +[integration] +yunohost = ">= 11.0.11" +architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +multi_instance = false +ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. +sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. +disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... +ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +[install] + [install.domain] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "domain" + + [install.path] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "path" + default = "/pgadmin" + + [install.admin] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "user" + + [install.password] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "password" + +[resources] + [resources.sources] + [resources.sources.armv7_bullseye] + url = "https://github.com/Josue-T/pgadmin_python_build/releases/download/v4-7.7/pgadmin_4-7.7-bullseye-bin1_armv7l.tar.gz" + sha256 = "76022eeab9c985a30dab8b24027db095f74eb491077de01db77100e320b4a2e5" + + [resources.sources.armv7_bookworm] + url = "https://github.com/Josue-T/pgadmin_python_build/releases/download/v4-7.7/pgadmin_4-7.7-bookworm-bin1_armv7l.tar.gz" + sha256 = "e18206853ced73eb1922182c5a3c825d8af21d5e40fcd607311cc4e075a28e72" + + + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" + + [resources.apt] + packages = "python3-pip, build-essential, python3-dev, python3-venv, postgresql, uwsgi, uwsgi-plugin-python3, expect, libpq-dev, libkrb5-dev" diff --git a/scripts/_common.sh b/scripts/_common.sh index ea3c266..c44d65d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)" # dependencies used by the app -pkg_dependencies="python3-pip build-essential python3-dev python3-venv postgresql uwsgi uwsgi-plugin-python3 expect libpq-dev libkrb5-dev" +#REMOVEME? pkg_dependencies="python3-pip build-essential python3-dev python3-venv postgresql uwsgi uwsgi-plugin-python3 expect libpq-dev libkrb5-dev" #================================================= # DEFINE ALL COMMON FONCTIONS @@ -15,39 +15,39 @@ setup_dir() { # Create empty dir for pgadmin mkdir -p /var/lib/pgadmin mkdir -p /var/log/pgadmin - mkdir -p $final_path + mkdir -p $install_dir } install_source() { # Clean venv is it was on python with an old version in case major upgrade of debian - if [ ! -e $final_path/lib/python$python_version ]; then - ynh_secure_remove --file=$final_path/bin - ynh_secure_remove --file=$final_path/lib - ynh_secure_remove --file=$final_path/lib64 - ynh_secure_remove --file=$final_path/include - ynh_secure_remove --file=$final_path/share - ynh_secure_remove --file=$final_path/pyvenv.cfg + if [ ! -e $install_dir/lib/python$python_version ]; then +#REMOVEME? ynh_secure_remove --file=$install_dir/bin +#REMOVEME? ynh_secure_remove --file=$install_dir/lib +#REMOVEME? ynh_secure_remove --file=$install_dir/lib64 +#REMOVEME? ynh_secure_remove --file=$install_dir/include +#REMOVEME? ynh_secure_remove --file=$install_dir/share +#REMOVEME? ynh_secure_remove --file=$install_dir/pyvenv.cfg fi - mkdir -p $final_path - chown $pgadmin_user:root -R $final_path + mkdir -p $install_dir + chown $app:root -R $install_dir if [ -n "$(uname -m | grep arm)" ] then # Clean old file, sometime it could make some big issues if we don't do this !! - ynh_secure_remove --file=$final_path/bin - ynh_secure_remove --file=$final_path/lib - ynh_secure_remove --file=$final_path/include - ynh_secure_remove --file=$final_path/share - ynh_setup_source --dest_dir $final_path/ --source_id "armv7_$(lsb_release --codename --short)" +#REMOVEME? ynh_secure_remove --file=$install_dir/bin +#REMOVEME? ynh_secure_remove --file=$install_dir/lib +#REMOVEME? ynh_secure_remove --file=$install_dir/include +#REMOVEME? ynh_secure_remove --file=$install_dir/share + ynh_setup_source --dest_dir $install_dir/ --source_id "armv7_$(lsb_release --codename --short)" else # Install virtualenv if it don't exist - test -e $final_path/bin/python3 || python3 -m venv $final_path +#REMOVEME? test -e $install_dir/bin/python3 || python3 -m venv $install_dir # Install pgadmin in virtualenv u_arg='u' set +$u_arg; - source $final_path/bin/activate + source $install_dir/bin/activate set -$u_arg; pip3 install --upgrade pip wheel pip3 install -I --upgrade "psycopg[c]" @@ -60,17 +60,17 @@ install_source() { set_permission() { # Set permission - chown $pgadmin_user:root -R $final_path - chown $pgadmin_user:root -R /var/lib/pgadmin + chown $app:root -R $install_dir + chown $app:root -R /var/lib/pgadmin mkdir -p /var/log/pgadmin - chown $pgadmin_user:root -R /var/log/pgadmin - chown $pgadmin_user:root /var/log/uwsgi/$app - chown $pgadmin_user:root /etc/uwsgi/apps-available/$app.ini + 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 } config_pgadmin() { - cp ../conf/config_local.py $final_path/lib/python$python_version/site-packages/pgadmin4/config_local.py - ynh_replace_string --match_string __USER__ --replace_string $pgadmin_user --target_file $final_path/lib/python$python_version/site-packages/pgadmin4/config_local.py - ynh_replace_string --match_string __DOMAIN__ --replace_string $domain --target_file $final_path/lib/python$python_version/site-packages/pgadmin4/config_local.py + cp ../conf/config_local.py $install_dir/lib/python$python_version/site-packages/pgadmin4/config_local.py + ynh_replace_string --match_string __USER__ --replace_string $app --target_file $install_dir/lib/python$python_version/site-packages/pgadmin4/config_local.py + ynh_replace_string --match_string __DOMAIN__ --replace_string $domain --target_file $install_dir/lib/python$python_version/site-packages/pgadmin4/config_local.py } diff --git a/scripts/backup b/scripts/backup index 14d3473..5de4b4e 100644 --- a/scripts/backup +++ b/scripts/backup @@ -15,21 +15,21 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { true } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +#REMOVEME? ynh_print_info --message="Loading installation settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -40,7 +40,7 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index 2f5c7ba..56ed063 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -15,57 +15,54 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH +#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN +#REMOVEME? old_path=$YNH_APP_OLD_PATH -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH +#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN +#REMOVEME? new_path=$YNH_APP_NEW_PATH -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +#REMOVEME? ynh_script_progression --message="Loading installation settings..." -# Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -# Add settings here as needed by your application -pgadmin_user="$app" +#REMOVEME? # Needed for helper "ynh_add_nginx_config" +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) #================================================= # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." +#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - ynh_clean_check_starting +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { + #REMOVEME? ynh_clean_check_starting # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. - ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= -change_domain=0 -if [ "$old_domain" != "$new_domain" ] +#REMOVEME? change_domain=0 +#REMOVEME? if [ "$old_domain" != "$new_domain" ] then - change_domain=1 + #REMOVEME? change_domain=1 fi -change_path=0 -if [ "$old_path" != "$new_path" ] +#REMOVEME? change_path=0 +#REMOVEME? if [ "$old_path" != "$new_path" ] then - change_path=1 + #REMOVEME? change_path=1 fi #================================================= @@ -77,28 +74,30 @@ fi #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf +ynh_change_url_nginx_config + +#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf # Change the path in the NGINX config file if [ $change_path -eq 1 ] then # Make a backup of the original NGINX config file if modified - ynh_backup_if_checksum_is_different --file="$nginx_conf_path" +#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path" # Set global variables for NGINX helper - domain="$old_domain" - path_url="$new_path" +#REMOVEME? domain="$old_domain" +#REMOVEME? path="$new_path" # Create a dedicated NGINX config - ynh_add_nginx_config +#REMOVEME? ynh_add_nginx_config fi # Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location - ynh_delete_file_checksum --file="$nginx_conf_path" - mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf +#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" +#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location - ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= @@ -107,12 +106,12 @@ fi # UPDATE CONFIGURATION #================================================= ynh_script_progression --message="Updating configuration..." - +#REMOVEME? domain=$new_domain -path_url=$new_path +path=$new_path # Update UWSGI Config -ynh_add_uwsgi_service 'pgadmin_user python_version' +ynh_add_uwsgi_service #================================================= # GENERIC FINALISATION @@ -128,9 +127,9 @@ sleep 10 #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index ba612ea..92a95d9 100644 --- a/scripts/install +++ b/scripts/install @@ -10,100 +10,16 @@ source experimental_helper.sh source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -admin=$YNH_APP_ARG_ADMIN -admin_pwd=$YNH_APP_ARG_PASSWORD - -db_user="pgadmin" -db_pwd=$(ynh_string_random --length 30) -app_version=$(ynh_app_upstream_version) -app_sub_version=$(echo $app_version | cut -d'-' -f2) - -app=$YNH_APP_INSTANCE_NAME - -pgadmin_user="$app" - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -ynh_script_progression --message="Validating installation parameters..." - -final_path=/opt/yunohost/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url - -# Get user email and check that the user exist -email=$(ynh_user_get_info --username $admin --key 'mail') -if [[ -z $email ]] -then - ynh_die --message "Can't get user email, check that the user exist or that the user have an email" -fi - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -ynh_script_progression --message="Storing installation settings..." - -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=admin --value=$admin -ynh_app_setting_set --app=$app --key=admin_pwd --value="$admin_pwd" -ynh_app_setting_set --app=$app --key=db_user --value="$db_user" -ynh_app_setting_set --app=$app --key=db_pwd --value="$db_pwd" - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=7 - -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -# Create a system user -ynh_system_user_create --username=$pgadmin_user --home_dir=$final_path - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." -ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_script_progression --message="Installing sources files..." --weight=10 setup_dir install_source -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." - -# Create a dedicated NGINX config -ynh_add_nginx_config - #================================================= # SPECIFIC SETUP #================================================= @@ -116,26 +32,26 @@ ynh_script_progression --message="Configuring application..." config_pgadmin # Config uwsgi -ynh_add_uwsgi_service 'pgadmin_user python_version' +ynh_add_uwsgi_service ynh_script_progression --message="Configuring sqlite database..." # initialisation sqlite database for pgadmin chmod +x ../conf/setup.exp set +u; -source $final_path/bin/activate +source $install_dir/bin/activate set -u; ynh_replace_special_string --match_string "__ADMIN_PASSWORD__" --replace_string "$admin_pwd" --target_file "../conf/setup.exp" -../conf/setup.exp "$final_path/bin/python3" "$final_path/lib/python$python_version/site-packages/pgadmin4/setup.py" "$email" +../conf/setup.exp "$install_dir/bin/python3" "$install_dir/lib/python$python_version/site-packages/pgadmin4/setup.py" "$email" # POPULATE THE DATABASE ynh_script_progression --message="Configuring Postgresql database..." -ynh_psql_test_if_first_run +#REMOVEME? ynh_psql_test_if_first_run ynh_psql_execute_as_root \ --sql "CREATE USER ${db_user} WITH PASSWORD '${db_pwd}' SUPERUSER CREATEDB CREATEROLE REPLICATION" # Add Server In PGadmin database -$final_path/bin/python3 config_database.py "$db_user" "$db_pwd" +$install_dir/bin/python3 config_database.py "$db_user" "$db_pwd" set +u; deactivate set -u; @@ -145,11 +61,12 @@ ynh_script_progression --message="Protecting directory" set_permission #================================================= -# GENERIC FINALIZATION +# SYSTEM CONFIGURATION #================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 + +# Create a dedicated NGINX config +ynh_add_nginx_config ynh_use_logrotate --logfile="/var/log/pgadmin" @@ -161,21 +78,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=3 ynh_systemd_action --service_name "uwsgi-app@$app.service" --action="restart" --line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log" sleep 10 -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." - -# Restrict access to admin only -ynh_permission_update --permission="main" --remove="all_users" --add=$admin - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." - -ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 7ded04b..ab431d3 100644 --- a/scripts/remove +++ b/scripts/remove @@ -13,13 +13,13 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +#REMOVEME? ynh_script_progression --message="Loading installation settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -db_user=$(ynh_app_setting_get --app=$app --key=db_user) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? db_user=$(ynh_app_setting_get --app=$app --key=db_user) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) #================================================= # STANDARD REMOVE @@ -42,17 +42,17 @@ ynh_remove_logrotate #================================================= # REMOVE DB_USER #================================================= -ynh_script_progression --message="Cleaning the PostgreSQL database..." +#REMOVEME? ynh_script_progression --message="Cleaning the PostgreSQL database..." ynh_psql_drop_user $db_user #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --weight=4 +#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=4 # Remove the app directory securely -ynh_secure_remove --file="$final_path" +#REMOVEME? ynh_secure_remove --file="$install_dir" #================================================= # REMOVE NGINX CONFIGURATION @@ -65,10 +65,10 @@ ynh_remove_nginx_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --weight=10 +#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=10 # Remove metapackage and its dependencies -ynh_remove_app_dependencies || true +#REMOVEME? ynh_remove_app_dependencies || true #================================================= # SPECIFIC REMOVE @@ -88,10 +88,10 @@ ynh_secure_remove --file="/var/log/$app" #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." +#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user -ynh_system_user_delete --username=$app +#REMOVEME? ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 8891245..edc543a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -15,30 +15,29 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +#REMOVEME? ynh_script_progression --message="Loading installation settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -admin=$(ynh_app_setting_get --app=$app --key=admin) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_user=$(ynh_app_setting_get --app=$app --key=db_user) -db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? db_user=$(ynh_app_setting_get --app=$app --key=db_user) +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) app_version=$(ynh_app_upstream_version) app_sub_version=$(echo $app_version | cut -d'-' -f2) -pgadmin_user="$app" #================================================= # STANDARD RESTORATION STEPS @@ -52,27 +51,27 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." +#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) -ynh_system_user_create --username=$pgadmin_user --home_dir=$final_path +#REMOVEME? ynh_system_user_create --username=$app --home_dir=$install_dir #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=5 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=5 +#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=5 # Define and install dependencies -ynh_exec_warn_less ynh_install_app_dependencies $pkg_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 @@ -80,7 +79,7 @@ install_source # POPULATE THE DATABASE ynh_script_progression --message="Reconfiguring Postgresql database..." -ynh_psql_test_if_first_run +#REMOVEME? ynh_psql_test_if_first_run ynh_psql_execute_as_root --sql "CREATE USER ${db_user} WITH PASSWORD '${db_pwd}' SUPERUSER CREATEDB CREATEROLE REPLICATION" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 01a55da..c509957 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -13,19 +13,18 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +#REMOVEME? ynh_script_progression --message="Loading installation settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -admin=$(ynh_app_setting_get --app=$app --key=admin) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) app_version=$(ynh_app_upstream_version) app_sub_version=$(echo $app_version | cut -d'-' -f2) -pgadmin_user="$app" #================================================= # CHECK VERSION @@ -37,17 +36,17 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." +#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS @@ -64,8 +63,8 @@ test -e /etc/uwsgi/apps-available/$app.ini && \ #================================================= ynh_script_progression --message="Ensuring downward compatibility..." -if ! grep -q "$final_path" /etc/passwd; then - sed --in-place -r "s@$app\:x\:([[:digit:]]+\:[[:digit:]]+)\:\:/.*/$app\:/usr/sbin/nologin@$app\:x\:\1\:\:$final_path\:/usr/sbin/nologin@g" /etc/passwd +if ! grep -q "$install_dir" /etc/passwd; then + sed --in-place -r "s@$app\:x\:([[:digit:]]+\:[[:digit:]]+)\:\:/.*/$app\:/usr/sbin/nologin@$app\:x\:\1\:\:$install_dir\:/usr/sbin/nologin@g" /etc/passwd fi #================================================= @@ -79,9 +78,9 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." +#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # SPECIFIC UPGRADE @@ -97,7 +96,7 @@ ynh_script_progression --message="Configuring application..." config_pgadmin # Config uwsgi -ynh_add_uwsgi_service 'pgadmin_user python_version' +ynh_add_uwsgi_service # Clean old uwsgi config ynh_secure_remove /etc/uwsgi/apps-enabled/pgadmin.ini @@ -127,9 +126,9 @@ sleep 10 #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT From bb3b2335391adaaa91a4b11ec76cc4f799423268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 11:37:53 +0100 Subject: [PATCH 03/59] fix --- scripts/_common.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index c44d65d..b7327bf 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + #================================================= # SET ALL CONSTANTS #================================================= @@ -19,15 +21,15 @@ setup_dir() { } install_source() { - # Clean venv is it was on python with an old version in case major upgrade of debian - if [ ! -e $install_dir/lib/python$python_version ]; then -#REMOVEME? ynh_secure_remove --file=$install_dir/bin -#REMOVEME? ynh_secure_remove --file=$install_dir/lib -#REMOVEME? ynh_secure_remove --file=$install_dir/lib64 -#REMOVEME? ynh_secure_remove --file=$install_dir/include -#REMOVEME? ynh_secure_remove --file=$install_dir/share -#REMOVEME? ynh_secure_remove --file=$install_dir/pyvenv.cfg - fi +# # Clean venv is it was on python with an old version in case major upgrade of debian +# if [ ! -e $install_dir/lib/python$python_version ]; then +# #REMOVEME? ynh_secure_remove --file=$install_dir/bin +# #REMOVEME? ynh_secure_remove --file=$install_dir/lib +# #REMOVEME? ynh_secure_remove --file=$install_dir/lib64 +# #REMOVEME? ynh_secure_remove --file=$install_dir/include +# #REMOVEME? ynh_secure_remove --file=$install_dir/share +# #REMOVEME? ynh_secure_remove --file=$install_dir/pyvenv.cfg +# fi mkdir -p $install_dir chown $app:root -R $install_dir From c8f1c327b4b1ec0268edb50c0207358ad643a9d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 11:38:11 +0100 Subject: [PATCH 04/59] fix --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index b7327bf..85bd055 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -44,7 +44,7 @@ install_source() { ynh_setup_source --dest_dir $install_dir/ --source_id "armv7_$(lsb_release --codename --short)" else # Install virtualenv if it don't exist -#REMOVEME? test -e $install_dir/bin/python3 || python3 -m venv $install_dir + test -e $install_dir/bin/python3 || python3 -m venv $install_dir # Install pgadmin in virtualenv u_arg='u' From 3b3e6a379f539c0b18a1ea752552cf4993cda583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 13:14:46 +0100 Subject: [PATCH 05/59] remove old files, add tests.toml --- check_process | 22 ---------------------- manifest.json | 51 --------------------------------------------------- tests.toml | 5 +++++ 3 files changed, 5 insertions(+), 73 deletions(-) delete mode 100644 check_process delete mode 100644 manifest.json create mode 100644 tests.toml diff --git a/check_process b/check_process deleted file mode 100644 index b42cec3..0000000 --- a/check_process +++ /dev/null @@ -1,22 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - path="/path" - admin="john" - password="1Strong-Password" - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=0 - setup_public=0 - upgrade=1 - backup_restore=1 - multi_instance=0 - port_already_use=0 - change_url=1 -;;; Options -Email= -Notification=none -;;; Upgrade options diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 08855ed..0000000 --- a/manifest.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "pgAdmin4", - "id": "pgadmin", - "packaging_format": 1, - "description": { - "en": "Manage PostgreSQL databases over the web", - "fr": "Application web de gestion des bases de données PostgreSQL" - }, - "version": "7.7~ynh1", - "url": "https://www.pgadmin.org", - "upstream": { - "license": "PostgreSQL", - "website": "https://www.pgadmin.org", - "admindoc": "https://www.pgadmin.org/docs" - }, - "license": "PostgreSQL", - "maintainer": { - "name": "Josué Tille", - "email": "josue@tille.ch" - }, - "requirements": { - "yunohost": ">= 11.0.11" - }, - "multi_instance": false, - "services": [ - "nginx", - "uwsgi" - ], - "arguments": { - "install" : [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/pgadmin", - "default": "/pgadmin" - }, - { - "name": "admin", - "type": "user" - }, - { - "name": "password", - "type": "password" - } - ] - } -} diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..94abb79 --- /dev/null +++ b/tests.toml @@ -0,0 +1,5 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + +test_format = 1.0 + +[default] From 4c627be6b2ecb9cb654593cb4c3af0fce39e6c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 13:14:52 +0100 Subject: [PATCH 06/59] fix var name --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 92a95d9..3f590eb 100644 --- a/scripts/install +++ b/scripts/install @@ -41,7 +41,7 @@ chmod +x ../conf/setup.exp set +u; source $install_dir/bin/activate set -u; -ynh_replace_special_string --match_string "__ADMIN_PASSWORD__" --replace_string "$admin_pwd" --target_file "../conf/setup.exp" +ynh_replace_special_string --match_string "__ADMIN_PASSWORD__" --replace_string "$password" --target_file "../conf/setup.exp" ../conf/setup.exp "$install_dir/bin/python3" "$install_dir/lib/python$python_version/site-packages/pgadmin4/setup.py" "$email" # POPULATE THE DATABASE From 3998221bd1ae050b75d318c95d2385f91f02897d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 13:23:29 +0100 Subject: [PATCH 07/59] fix missing email --- scripts/install | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install b/scripts/install index 3f590eb..fb5f40a 100644 --- a/scripts/install +++ b/scripts/install @@ -10,6 +10,8 @@ source experimental_helper.sh source _common.sh source /usr/share/yunohost/helpers +email=$(ynh_user_get_info --username $admin --key 'mail') + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= From 4fd524134a61a2df3c30a327cf3c0988883e2b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 13:57:56 +0100 Subject: [PATCH 08/59] Fix missing psql --- manifest.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manifest.toml b/manifest.toml index 1fd2129..7b5163a 100644 --- a/manifest.toml +++ b/manifest.toml @@ -66,3 +66,6 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen [resources.apt] packages = "python3-pip, build-essential, python3-dev, python3-venv, postgresql, uwsgi, uwsgi-plugin-python3, expect, libpq-dev, libkrb5-dev" + + [resources.database] + type = "postgresql" From 0ac8cbb574cf141693c7c039588a5069b3852708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 15:02:44 +0100 Subject: [PATCH 09/59] fix install_dir --- scripts/config_database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/config_database.py b/scripts/config_database.py index d62f48a..15fb80a 100644 --- a/scripts/config_database.py +++ b/scripts/config_database.py @@ -6,7 +6,7 @@ import sys # Import crypto from pgadmin project __PYTHON_VERSION__ python_version = str(sys.version_info[0]) + "." + str(sys.version_info[1]) -crypto = SourceFileLoader('crypto', '/opt/yunohost/pgadmin/lib/python' + +crypto = SourceFileLoader('crypto', '/var/www/pgadmin/lib/python' + python_version + '/site-packages/pgadmin4/pgadmin/utils/crypto.py').load_module() # Get arguments From 295864a24d937977c2ba36e1c52b349c4f91825e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 15:12:37 +0100 Subject: [PATCH 10/59] fix uwsgi --- scripts/experimental_helper.sh | 12 ++++++------ scripts/install | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/experimental_helper.sh b/scripts/experimental_helper.sh index 605dd74..5c3c786 100644 --- a/scripts/experimental_helper.sh +++ b/scripts/experimental_helper.sh @@ -43,7 +43,7 @@ EOF # # __APP__ by $app # __PATH__ by $path_url -# __FINALPATH__ by $final_path +# __FINALPATH__ by $install_dir # # And dynamic variables (from the last example) : # __PATH_2__ by $path_2 @@ -51,7 +51,7 @@ EOF # # To be able to customise the settings of the systemd unit you can override the rules with the file "conf/uwsgi-app@override.service". # This file will be automatically placed on the good place -# +# # Note that the service need to be started manually at the end of the installation. # Generally you can start the service with this command: # ynh_systemd_action --service_name "uwsgi-app@$app.service" --line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log" @@ -73,8 +73,8 @@ ynh_add_uwsgi_service () { # To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable. # Substitute in a nginx config file only if the variable is not empty - if test -n "${final_path:-}"; then - ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$finaluwsgiini" + if test -n "${install_dir:-}"; then + ynh_replace_string --match_string="__INSTALL_DIR__" --replace_string="$install_dir" --target_file="$finaluwsgiini" fi if test -n "${path_url:-}"; then ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$finaluwsgiini" @@ -87,7 +87,7 @@ ynh_add_uwsgi_service () { for var_to_replace in $others_var do # ${var_to_replace^^} make the content of the variable on upper-cases - # ${!var_to_replace} get the content of the variable named $var_to_replace + # ${!var_to_replace} get the content of the variable named $var_to_replace ynh_replace_string --match_string="__${var_to_replace^^}__" --replace_string="${!var_to_replace}" --target_file="$finaluwsgiini" done @@ -136,7 +136,7 @@ ynh_restore_uwsgi_service () { mkdir -p /var/log/uwsgi/$app chown $app:root /var/log/uwsgi/$app chmod -R u=rwX,g=rX,o= /var/log/uwsgi/$app - + yunohost service add "uwsgi-app@$app" --log "/var/log/uwsgi/$app/$app.log" } diff --git a/scripts/install b/scripts/install index fb5f40a..20504ac 100644 --- a/scripts/install +++ b/scripts/install @@ -34,7 +34,7 @@ ynh_script_progression --message="Configuring application..." config_pgadmin # Config uwsgi -ynh_add_uwsgi_service +ynh_add_uwsgi_service "python_version" ynh_script_progression --message="Configuring sqlite database..." From 71c55c4aab42371e9dceedc2acb9d38ba01904e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 15:32:09 +0100 Subject: [PATCH 11/59] continue cleanup --- conf/config_local.py | 2 +- conf/uwsgi.ini | 4 +-- conf/virtualenv_activate | 78 ---------------------------------------- manifest.toml | 12 +++---- scripts/_common.sh | 60 +++++++------------------------ scripts/install | 14 +++++--- 6 files changed, 31 insertions(+), 139 deletions(-) delete mode 100644 conf/virtualenv_activate diff --git a/conf/config_local.py b/conf/config_local.py index bad0b92..1ddd489 100644 --- a/conf/config_local.py +++ b/conf/config_local.py @@ -1 +1 @@ -DESKTOP_USER = '__USER__@__DOMAIN__' \ No newline at end of file +DESKTOP_USER = '__APP__@__DOMAIN__' diff --git a/conf/uwsgi.ini b/conf/uwsgi.ini index b5c0b7b..a582f8b 100644 --- a/conf/uwsgi.ini +++ b/conf/uwsgi.ini @@ -16,12 +16,12 @@ plugin = python3 # Manage the subpath manage-script-name = true -mount = __PATH__=pgAdmin4.py +mount = __PATH__=pgAdmin4.py # Virtualenv and python path virtualenv = __INSTALL_DIR__ pythonpath = __INSTALL_DIR__ -chdir = __INSTALL_DIR__/lib/python__PYTHON_VERSION__/site-packages/pgadmin4 +chdir = __INSTALL_DIR__/venv/lib/python__PYTHON_VERSION__/site-packages/pgadmin4 # The variable holding flask application callable = app diff --git a/conf/virtualenv_activate b/conf/virtualenv_activate deleted file mode 100644 index 6aea9b1..0000000 --- a/conf/virtualenv_activate +++ /dev/null @@ -1,78 +0,0 @@ -# This file must be used with "source bin/activate" *from bash* -# you cannot run it directly - -deactivate () { - unset -f pydoc >/dev/null 2>&1 - - # reset old environment variables - # ! [ -z ${VAR+_} ] returns true if VAR is declared at all - if ! [ -z "${_OLD_VIRTUAL_PATH+_}" ] ; then - PATH="$_OLD_VIRTUAL_PATH" - export PATH - unset _OLD_VIRTUAL_PATH - fi - if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then - PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME" - export PYTHONHOME - unset _OLD_VIRTUAL_PYTHONHOME - fi - - # This should detect bash and zsh, which have a hash command that must - # be called to get it to forget past commands. Without forgetting - # past commands the $PATH changes we made may not be respected - if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then - hash -r 2>/dev/null - fi - - if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then - PS1="$_OLD_VIRTUAL_PS1" - export PS1 - unset _OLD_VIRTUAL_PS1 - fi - - unset VIRTUAL_ENV - if [ ! "${1-}" = "nondestructive" ] ; then - # Self destruct! - unset -f deactivate - fi -} - -# unset irrelevant variables -deactivate nondestructive - -VIRTUAL_ENV="/opt/yunohost/pgadmin" -export VIRTUAL_ENV - -_OLD_VIRTUAL_PATH="$PATH" -PATH="$VIRTUAL_ENV/bin:$PATH" -export PATH - -# unset PYTHONHOME if set -if ! [ -z "${PYTHONHOME+_}" ] ; then - _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME" - unset PYTHONHOME -fi - -if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then - _OLD_VIRTUAL_PS1="$PS1" - if [ "x" != x ] ; then - PS1="$PS1" - else - PS1="(`basename \"$VIRTUAL_ENV\"`) $PS1" - fi - export PS1 -fi - -# Make sure to unalias pydoc if it's already there -alias pydoc 2>/dev/null >/dev/null && unalias pydoc - -pydoc () { - python -m pydoc "$@" -} - -# This should detect bash and zsh, which have a hash command that must -# be called to get it to forget past commands. Without forgetting -# past commands the $PATH changes we made may not be respected -if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then - hash -r 2>/dev/null -fi diff --git a/manifest.toml b/manifest.toml index 7b5163a..4a57f2c 100644 --- a/manifest.toml +++ b/manifest.toml @@ -48,13 +48,13 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen [resources] [resources.sources] - [resources.sources.armv7_bullseye] - url = "https://github.com/Josue-T/pgadmin_python_build/releases/download/v4-7.7/pgadmin_4-7.7-bullseye-bin1_armv7l.tar.gz" - sha256 = "76022eeab9c985a30dab8b24027db095f74eb491077de01db77100e320b4a2e5" + [resources.sources.armv7_bullseye] + url = "https://github.com/Josue-T/pgadmin_python_build/releases/download/v4-7.7/pgadmin_4-7.7-bullseye-bin1_armv7l.tar.gz" + sha256 = "76022eeab9c985a30dab8b24027db095f74eb491077de01db77100e320b4a2e5" - [resources.sources.armv7_bookworm] - url = "https://github.com/Josue-T/pgadmin_python_build/releases/download/v4-7.7/pgadmin_4-7.7-bookworm-bin1_armv7l.tar.gz" - sha256 = "e18206853ced73eb1922182c5a3c825d8af21d5e40fcd607311cc4e075a28e72" + [resources.sources.armv7_bookworm] + url = "https://github.com/Josue-T/pgadmin_python_build/releases/download/v4-7.7/pgadmin_4-7.7-bookworm-bin1_armv7l.tar.gz" + sha256 = "e18206853ced73eb1922182c5a3c825d8af21d5e40fcd607311cc4e075a28e72" [resources.system_user] diff --git a/scripts/_common.sh b/scripts/_common.sh index 85bd055..bb16de0 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,9 +6,6 @@ python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)" -# dependencies used by the app -#REMOVEME? pkg_dependencies="python3-pip build-essential python3-dev python3-venv postgresql uwsgi uwsgi-plugin-python3 expect libpq-dev libkrb5-dev" - #================================================= # DEFINE ALL COMMON FONCTIONS #================================================= @@ -17,47 +14,6 @@ setup_dir() { # Create empty dir for pgadmin mkdir -p /var/lib/pgadmin mkdir -p /var/log/pgadmin - mkdir -p $install_dir -} - -install_source() { -# # Clean venv is it was on python with an old version in case major upgrade of debian -# if [ ! -e $install_dir/lib/python$python_version ]; then -# #REMOVEME? ynh_secure_remove --file=$install_dir/bin -# #REMOVEME? ynh_secure_remove --file=$install_dir/lib -# #REMOVEME? ynh_secure_remove --file=$install_dir/lib64 -# #REMOVEME? ynh_secure_remove --file=$install_dir/include -# #REMOVEME? ynh_secure_remove --file=$install_dir/share -# #REMOVEME? ynh_secure_remove --file=$install_dir/pyvenv.cfg -# fi - - mkdir -p $install_dir - chown $app:root -R $install_dir - - if [ -n "$(uname -m | grep arm)" ] - then - # Clean old file, sometime it could make some big issues if we don't do this !! -#REMOVEME? ynh_secure_remove --file=$install_dir/bin -#REMOVEME? ynh_secure_remove --file=$install_dir/lib -#REMOVEME? ynh_secure_remove --file=$install_dir/include -#REMOVEME? ynh_secure_remove --file=$install_dir/share - ynh_setup_source --dest_dir $install_dir/ --source_id "armv7_$(lsb_release --codename --short)" - else -# Install virtualenv if it don't exist - test -e $install_dir/bin/python3 || python3 -m venv $install_dir - -# Install pgadmin in virtualenv - u_arg='u' - set +$u_arg; - source $install_dir/bin/activate - set -$u_arg; - pip3 install --upgrade pip wheel - pip3 install -I --upgrade "psycopg[c]" - pip3 install --upgrade -r $YNH_APP_BASEDIR/conf/requirement_$(lsb_release --codename --short).txt - set +$u_arg; - deactivate - set -$u_arg; - fi } set_permission() { @@ -71,8 +27,16 @@ set_permission() { chmod u=rwX,g=rX,o= -R /var/lib/pgadmin } -config_pgadmin() { - cp ../conf/config_local.py $install_dir/lib/python$python_version/site-packages/pgadmin4/config_local.py - ynh_replace_string --match_string __USER__ --replace_string $app --target_file $install_dir/lib/python$python_version/site-packages/pgadmin4/config_local.py - ynh_replace_string --match_string __DOMAIN__ --replace_string $domain --target_file $install_dir/lib/python$python_version/site-packages/pgadmin4/config_local.py +_install_pgadmin_venv() { + ynh_exec_as "$app" python3 -m venv --upgrade "$install_dir/venv" + venvpy="$install_dir/venv/bin/python3" + + ynh_exec_as "$app" "$venvpy" -m pip install --upgrade --no-cache-dir pip wheel + ynh_exec_as "$app" "$venvpy" -m pip install --upgrade --no-cache-dir --ignore-installed "psycopg[c]" + + ynh_exec_as "$app" "$venvpy" -m pip install --upgrade -r "$YNH_APP_BASEDIR/conf/requirement_$(lsb_release --codename --short).txt" +} + +config_pgadmin() { + ynh_add_config --template="config_local.py" --destination="$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/config_local.py" } diff --git a/scripts/install b/scripts/install index 20504ac..b9696fd 100644 --- a/scripts/install +++ b/scripts/install @@ -10,6 +10,10 @@ source experimental_helper.sh source _common.sh source /usr/share/yunohost/helpers +#================================================= +# INITIALIZE AND STORE SETTINGS +#================================================= + email=$(ynh_user_get_info --username $admin --key 'mail') #================================================= @@ -19,8 +23,10 @@ ynh_script_progression --message="Setting up source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_script_progression --message="Installing sources files..." --weight=10 + setup_dir -install_source + +_install_pgadmin_venv #================================================= # SPECIFIC SETUP @@ -41,10 +47,10 @@ ynh_script_progression --message="Configuring sqlite database..." # initialisation sqlite database for pgadmin chmod +x ../conf/setup.exp set +u; -source $install_dir/bin/activate +source $install_dir/venv/bin/activate set -u; ynh_replace_special_string --match_string "__ADMIN_PASSWORD__" --replace_string "$password" --target_file "../conf/setup.exp" -../conf/setup.exp "$install_dir/bin/python3" "$install_dir/lib/python$python_version/site-packages/pgadmin4/setup.py" "$email" +../conf/setup.exp "$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" "$email" # POPULATE THE DATABASE ynh_script_progression --message="Configuring Postgresql database..." @@ -53,7 +59,7 @@ ynh_psql_execute_as_root \ --sql "CREATE USER ${db_user} WITH PASSWORD '${db_pwd}' SUPERUSER CREATEDB CREATEROLE REPLICATION" # Add Server In PGadmin database -$install_dir/bin/python3 config_database.py "$db_user" "$db_pwd" +$install_dir/venv/bin/python3 config_database.py "$db_user" "$db_pwd" set +u; deactivate set -u; From eae63a74cf8f5de43f9a5a6e9c888f5ddd20ee1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 15:36:17 +0100 Subject: [PATCH 12/59] fix permissions --- scripts/_common.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index bb16de0..6d5f31c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -34,7 +34,8 @@ _install_pgadmin_venv() { ynh_exec_as "$app" "$venvpy" -m pip install --upgrade --no-cache-dir pip wheel ynh_exec_as "$app" "$venvpy" -m pip install --upgrade --no-cache-dir --ignore-installed "psycopg[c]" - ynh_exec_as "$app" "$venvpy" -m pip install --upgrade -r "$YNH_APP_BASEDIR/conf/requirement_$(lsb_release --codename --short).txt" + cp "$YNH_APP_BASEDIR/conf/requirement_$(lsb_release --codename --short).txt" "$install_dir/requirements.txt" + ynh_exec_as "$app" "$venvpy" -m pip install --upgrade -r "$install_dir/requirements.txt" } config_pgadmin() { From 6356ba687aa8aeb31c9d43e8886788e965a4ba3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 15:50:21 +0100 Subject: [PATCH 13/59] useless activate venv --- scripts/install | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index b9696fd..ebd6dbd 100644 --- a/scripts/install +++ b/scripts/install @@ -46,9 +46,7 @@ ynh_script_progression --message="Configuring sqlite database..." # initialisation sqlite database for pgadmin chmod +x ../conf/setup.exp -set +u; -source $install_dir/venv/bin/activate -set -u; + ynh_replace_special_string --match_string "__ADMIN_PASSWORD__" --replace_string "$password" --target_file "../conf/setup.exp" ../conf/setup.exp "$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" "$email" @@ -60,9 +58,6 @@ ynh_psql_execute_as_root \ # Add Server In PGadmin database $install_dir/venv/bin/python3 config_database.py "$db_user" "$db_pwd" -set +u; -deactivate -set -u; # Set permission after initialisation ynh_script_progression --message="Protecting directory" From 6f9a12342cd4e3c0cf6ef99a87dab784d0935871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 16:00:07 +0100 Subject: [PATCH 14/59] venv dir --- scripts/config_database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/config_database.py b/scripts/config_database.py index 15fb80a..e2a62ab 100644 --- a/scripts/config_database.py +++ b/scripts/config_database.py @@ -6,7 +6,7 @@ import sys # Import crypto from pgadmin project __PYTHON_VERSION__ python_version = str(sys.version_info[0]) + "." + str(sys.version_info[1]) -crypto = SourceFileLoader('crypto', '/var/www/pgadmin/lib/python' + +crypto = SourceFileLoader('crypto', '/var/www/pgadmin/venv/lib/python' + python_version + '/site-packages/pgadmin4/pgadmin/utils/crypto.py').load_module() # Get arguments From 697dd1c30550c04fafa3fe43f577cede75136d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 16:06:46 +0100 Subject: [PATCH 15/59] Fix uwsgi --- conf/uwsgi.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/uwsgi.ini b/conf/uwsgi.ini index a582f8b..02be2d0 100644 --- a/conf/uwsgi.ini +++ b/conf/uwsgi.ini @@ -19,8 +19,8 @@ manage-script-name = true mount = __PATH__=pgAdmin4.py # Virtualenv and python path -virtualenv = __INSTALL_DIR__ -pythonpath = __INSTALL_DIR__ +virtualenv = __INSTALL_DIR__/venv +pythonpath = __INSTALL_DIR__/venv chdir = __INSTALL_DIR__/venv/lib/python__PYTHON_VERSION__/site-packages/pgadmin4 # The variable holding flask application From bbc3f1a0ea25dc8a878e713f6bf7323c8342c507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 16:22:11 +0100 Subject: [PATCH 16/59] cleanup install --- conf/setup.exp | 4 +-- scripts/_common.sh | 4 --- scripts/config_database.py | 55 -------------------------------------- scripts/install | 42 ++++++++++++----------------- 4 files changed, 19 insertions(+), 86 deletions(-) mode change 100644 => 100755 conf/setup.exp delete mode 100644 scripts/config_database.py diff --git a/conf/setup.exp b/conf/setup.exp old mode 100644 new mode 100755 index 9cec340..26efb02 --- a/conf/setup.exp +++ b/conf/setup.exp @@ -11,11 +11,11 @@ expect "Email address:" send "$user\r"; expect "Password:" -send {__ADMIN_PASSWORD__}; +send {__PASSWORD__}; send "\r"; expect "Retype password:" -send {__ADMIN_PASSWORD__}; +send {__PASSWORD__}; send "\r"; interact diff --git a/scripts/_common.sh b/scripts/_common.sh index 6d5f31c..6abb099 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -37,7 +37,3 @@ _install_pgadmin_venv() { cp "$YNH_APP_BASEDIR/conf/requirement_$(lsb_release --codename --short).txt" "$install_dir/requirements.txt" ynh_exec_as "$app" "$venvpy" -m pip install --upgrade -r "$install_dir/requirements.txt" } - -config_pgadmin() { - ynh_add_config --template="config_local.py" --destination="$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/config_local.py" -} diff --git a/scripts/config_database.py b/scripts/config_database.py deleted file mode 100644 index e2a62ab..0000000 --- a/scripts/config_database.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/python - -from importlib.machinery import SourceFileLoader -import sqlite3 -import sys - -# Import crypto from pgadmin project __PYTHON_VERSION__ -python_version = str(sys.version_info[0]) + "." + str(sys.version_info[1]) -crypto = SourceFileLoader('crypto', '/var/www/pgadmin/venv/lib/python' + - python_version + '/site-packages/pgadmin4/pgadmin/utils/crypto.py').load_module() - -# Get arguments -username = sys.argv[1] -password = sys.argv[2] - -# Connect to sqlite3 -conn = sqlite3.connect('/var/lib/pgadmin/pgadmin4.db') - -# Get encrypte user password from the database -cursor = conn.execute('SELECT `password`,1 FROM `user`') -user_encrypted_password = cursor.fetchone()[0] - -# Encrypt database password -crypted_password = crypto.encrypt(password, user_encrypted_password) - -# Declare database data to put in database -data = {'id': 1, 'user_id': 1, 'servergroup_id': 1, 'name': 'Yunohost Server', 'host': 'localhost', 'port': 5432, 'maintenance_db': 'postgres', - 'username': username, 'comment': '', 'password': crypted_password, 'role': '', 'discovery_id': '', - 'db_res': '', 'bgcolor': '', 'fgcolor': '', 'service': '', - 'use_ssh_tunnel': '', 'tunnel_host': '', 'tunnel_port': 22, 'tunnel_username': '', 'tunnel_authentication': '', 'tunnel_identity_file': '', 'tunnel_password': '', - 'save_password': 1, 'shared': '', 'kerberos_conn': 0, 'cloud_status': 0, 'passexec_cmd': '', 'passexec_expiration': '', - 'connection_params': '''{"sslmode": "prefer", "connect_timeout": 10, "sslcert": "/.postgresql/postgresql.crt", "sslkey": "/.postgresql/postgresql.key"}'''} - -# Insert new data in database -cursor = conn.cursor() -cursor.execute(''' - INSERT INTO `server` ( - `id`,`user_id`,`servergroup_id`,`name`,`host`,`port`,`maintenance_db`, - `username`,`comment`,`password`,`role`,`discovery_id`, - `db_res`,`bgcolor`,`fgcolor`,`service`, - `use_ssh_tunnel`,`tunnel_host`,`tunnel_port`,`tunnel_username`,`tunnel_authentication`,`tunnel_identity_file`,`tunnel_password`, - `save_password`,`shared`,`kerberos_conn`,`cloud_status`,`passexec_cmd`,`passexec_expiration`, - `connection_params` - ) VALUES ( - :id,:user_id,:servergroup_id,:name,:host,:port,:maintenance_db, - :username,:comment,:password,:role,:discovery_id, - :db_res,:bgcolor,:fgcolor,:service, - :use_ssh_tunnel,:tunnel_host,:tunnel_port,:tunnel_username,:tunnel_authentication,:tunnel_identity_file,:tunnel_password, - :save_password,:shared,:kerberos_conn,:cloud_status,:passexec_cmd,:passexec_expiration, - :connection_params - );''', data) -conn.commit() - -# Close connection -conn.close() diff --git a/scripts/install b/scripts/install index ebd6dbd..1c898e8 100644 --- a/scripts/install +++ b/scripts/install @@ -21,43 +21,32 @@ email=$(ynh_user_get_info --username $admin --key 'mail') #================================================= ynh_script_progression --message="Setting up source files..." -# Download, check integrity, uncompress and patch the source from app.src -ynh_script_progression --message="Installing sources files..." --weight=10 +_install_pgadmin_venv setup_dir -_install_pgadmin_venv - #================================================= -# SPECIFIC SETUP +# ADD A CONFIGURATION #================================================= -# ... -#================================================= - -ynh_script_progression --message="Configuring application..." +ynh_script_progression --message="Adding a configuration file..." --weight=1 # CONFIGURE PGADMIN -config_pgadmin +ynh_add_config --template="config_local.py" --destination="$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/config_local.py" -# Config uwsgi -ynh_add_uwsgi_service "python_version" +ynh_script_progression --message="Configuring $app..." -ynh_script_progression --message="Configuring sqlite database..." +ynh_add_config --template="setup.exp" --destination="$install_dir/setup.exp" +"$install_dir/setup.exp" "$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" "$email" -# initialisation sqlite database for pgadmin -chmod +x ../conf/setup.exp - -ynh_replace_special_string --match_string "__ADMIN_PASSWORD__" --replace_string "$password" --target_file "../conf/setup.exp" -../conf/setup.exp "$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" "$email" - -# POPULATE THE DATABASE -ynh_script_progression --message="Configuring Postgresql database..." -#REMOVEME? ynh_psql_test_if_first_run -ynh_psql_execute_as_root \ - --sql "CREATE USER ${db_user} WITH PASSWORD '${db_pwd}' SUPERUSER CREATEDB CREATEROLE REPLICATION" +#================================================= +# Postgresql superuser +#================================================= +ynh_script_progression --message="Configuring Postgresql superuser..." +ynh_psql_execute_as_root --sql "CREATE USER $db_user WITH PASSWORD '$db_pwd' SUPERUSER CREATEDB CREATEROLE REPLICATION" # Add Server In PGadmin database -$install_dir/venv/bin/python3 config_database.py "$db_user" "$db_pwd" +ynh_add_config --template="setup_database.py" --destination "$install_dir/setup_database.py" +"$install_dir/venv/bin/python3" "$install_dir/setup_database.py" "$db_user" "$db_pwd" # Set permission after initialisation ynh_script_progression --message="Protecting directory" @@ -71,6 +60,9 @@ ynh_script_progression --message="Adding system configurations related to $app.. # Create a dedicated NGINX config ynh_add_nginx_config +# Config uwsgi +ynh_add_uwsgi_service "python_version" + ynh_use_logrotate --logfile="/var/log/pgadmin" #================================================= From 701094e25bf184699da35aaccc3cdb3556bb95f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 16:37:46 +0100 Subject: [PATCH 17/59] fix permission --- conf/setup_database.py | 55 ++++++++++++++++++++++++++++++++++++++ scripts/backup | 32 +++------------------- scripts/install | 2 ++ scripts/remove | 57 +++++---------------------------------- scripts/restore | 60 ++++++++++++++---------------------------- 5 files changed, 87 insertions(+), 119 deletions(-) create mode 100644 conf/setup_database.py diff --git a/conf/setup_database.py b/conf/setup_database.py new file mode 100644 index 0000000..e2a62ab --- /dev/null +++ b/conf/setup_database.py @@ -0,0 +1,55 @@ +#!/usr/bin/python + +from importlib.machinery import SourceFileLoader +import sqlite3 +import sys + +# Import crypto from pgadmin project __PYTHON_VERSION__ +python_version = str(sys.version_info[0]) + "." + str(sys.version_info[1]) +crypto = SourceFileLoader('crypto', '/var/www/pgadmin/venv/lib/python' + + python_version + '/site-packages/pgadmin4/pgadmin/utils/crypto.py').load_module() + +# Get arguments +username = sys.argv[1] +password = sys.argv[2] + +# Connect to sqlite3 +conn = sqlite3.connect('/var/lib/pgadmin/pgadmin4.db') + +# Get encrypte user password from the database +cursor = conn.execute('SELECT `password`,1 FROM `user`') +user_encrypted_password = cursor.fetchone()[0] + +# Encrypt database password +crypted_password = crypto.encrypt(password, user_encrypted_password) + +# Declare database data to put in database +data = {'id': 1, 'user_id': 1, 'servergroup_id': 1, 'name': 'Yunohost Server', 'host': 'localhost', 'port': 5432, 'maintenance_db': 'postgres', + 'username': username, 'comment': '', 'password': crypted_password, 'role': '', 'discovery_id': '', + 'db_res': '', 'bgcolor': '', 'fgcolor': '', 'service': '', + 'use_ssh_tunnel': '', 'tunnel_host': '', 'tunnel_port': 22, 'tunnel_username': '', 'tunnel_authentication': '', 'tunnel_identity_file': '', 'tunnel_password': '', + 'save_password': 1, 'shared': '', 'kerberos_conn': 0, 'cloud_status': 0, 'passexec_cmd': '', 'passexec_expiration': '', + 'connection_params': '''{"sslmode": "prefer", "connect_timeout": 10, "sslcert": "/.postgresql/postgresql.crt", "sslkey": "/.postgresql/postgresql.key"}'''} + +# Insert new data in database +cursor = conn.cursor() +cursor.execute(''' + INSERT INTO `server` ( + `id`,`user_id`,`servergroup_id`,`name`,`host`,`port`,`maintenance_db`, + `username`,`comment`,`password`,`role`,`discovery_id`, + `db_res`,`bgcolor`,`fgcolor`,`service`, + `use_ssh_tunnel`,`tunnel_host`,`tunnel_port`,`tunnel_username`,`tunnel_authentication`,`tunnel_identity_file`,`tunnel_password`, + `save_password`,`shared`,`kerberos_conn`,`cloud_status`,`passexec_cmd`,`passexec_expiration`, + `connection_params` + ) VALUES ( + :id,:user_id,:servergroup_id,:name,:host,:port,:maintenance_db, + :username,:comment,:password,:role,:discovery_id, + :db_res,:bgcolor,:fgcolor,:service, + :use_ssh_tunnel,:tunnel_host,:tunnel_port,:tunnel_username,:tunnel_authentication,:tunnel_identity_file,:tunnel_password, + :save_password,:shared,:kerberos_conn,:cloud_status,:passexec_cmd,:passexec_expiration, + :connection_params + );''', data) +conn.commit() + +# Close connection +conn.close() diff --git a/scripts/backup b/scripts/backup index 5de4b4e..8f5c2a8 100644 --- a/scripts/backup +++ b/scripts/backup @@ -11,26 +11,6 @@ source ../settings/scripts/experimental_helper.sh source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_print_info --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -43,25 +23,19 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$install_dir" #================================================= -# BACKUP THE NGINX CONFIGURATION +# SYSTEM CONFIGURATION #================================================= ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= - ynh_backup --src_path="/etc/logrotate.d/$app" +ynh_backup --src_path="/etc/uwsgi/apps-available/$app.ini" + #================================================= # BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/etc/uwsgi/apps-available/$app.ini" - ynh_backup --src_path="/var/lib/pgadmin" #================================================= diff --git a/scripts/install b/scripts/install index 1c898e8..14c5049 100644 --- a/scripts/install +++ b/scripts/install @@ -36,6 +36,7 @@ ynh_add_config --template="config_local.py" --destination="$install_dir/venv/lib ynh_script_progression --message="Configuring $app..." ynh_add_config --template="setup.exp" --destination="$install_dir/setup.exp" +chmod +x "$install_dir/setup.exp" "$install_dir/setup.exp" "$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" "$email" #================================================= @@ -46,6 +47,7 @@ ynh_psql_execute_as_root --sql "CREATE USER $db_user WITH PASSWORD '$db_pwd' SUP # Add Server In PGadmin database ynh_add_config --template="setup_database.py" --destination "$install_dir/setup_database.py" +chmod +x "$install_dir/setup_database.py" "$install_dir/venv/bin/python3" "$install_dir/setup_database.py" "$db_user" "$db_pwd" # Set permission after initialisation diff --git a/scripts/remove b/scripts/remove index ab431d3..08ad141 100644 --- a/scripts/remove +++ b/scripts/remove @@ -11,19 +11,9 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? db_user=$(ynh_app_setting_get --app=$app --key=db_user) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) - -#================================================= -# STANDARD REMOVE +# REMOVE SYSTEM CONFIGURATIONS #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # Stop service ynh_systemd_action --service_name "uwsgi-app@$app.service" --action stop @@ -31,44 +21,18 @@ ynh_systemd_action --service_name "uwsgi-app@$app.service" --action stop # Remove uwsgi config ynh_remove_uwsgi_service -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." - # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE DB_USER -#================================================= -#REMOVEME? ynh_script_progression --message="Cleaning the PostgreSQL database..." - -ynh_psql_drop_user $db_user - -#================================================= -# REMOVE APP MAIN DIR -#================================================= -#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=4 - -# Remove the app directory securely -#REMOVEME? ynh_secure_remove --file="$install_dir" - -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." - # Remove the dedicated NGINX config ynh_remove_nginx_config #================================================= -# REMOVE DEPENDENCIES +# CONFIGURE POSTGRESQL #================================================= -#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=10 +ynh_script_progression --message="Removing the Postgresql superuser..." -# Remove metapackage and its dependencies -#REMOVEME? ynh_remove_app_dependencies || true +ynh_psql_drop_user "$db_user" #================================================= # SPECIFIC REMOVE @@ -83,15 +47,8 @@ ynh_secure_remove --file="/var/lib/$app" # Remove the log files ynh_secure_remove --file="/var/log/$app" -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." - -# Delete a system user -#REMOVEME? ynh_system_user_delete --username=$app +# Remove the log files +ynh_secure_remove --file="/var/log/uwsgi/$app" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index edc543a..a80929d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -12,31 +12,16 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= -# MANAGE SCRIPT FAILURE +# RESTORE THE APP MAIN DIR #================================================= +ynh_script_progression --message="Restoring the app main directory..." --weight=1 -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors +ynh_restore_file --origin_path="$install_dir" -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? db_user=$(ynh_app_setting_get --app=$app --key=db_user) -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) - -app_version=$(ynh_app_upstream_version) -app_sub_version=$(echo $app_version | cut -d'-' -f2) +### $install_dir will automatically be initialized with some decent +### permissions by default ... however, you may need to recursively reapply +### ownership to all files such as after the ynh_setup_source step +chown -R "$app:www-data" "$install_dir" #================================================= @@ -46,22 +31,13 @@ app_sub_version=$(echo $app_version | cut -d'-' -f2) #================================================= ynh_script_progression --message="Restoring the NGINX web server configuration..." -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# RECREATE THE DEDICATED USER +# RESTORE THE POSTGRESQL SUPERUSER #================================================= -#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." +ynh_script_progression --message="Restoring the Postgresql superuser..." --weight=1 -# Create the dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir=$install_dir - -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=5 - -ynh_restore_file --origin_path="$install_dir" +ynh_psql_execute_as_root --sql "CREATE USER ${db_user} WITH PASSWORD '${db_pwd}' SUPERUSER CREATEDB CREATEROLE REPLICATION" #================================================= # SPECIFIC RESTORATION @@ -77,17 +53,22 @@ ynh_restore_file --origin_path="$install_dir" # If not upgrade the source install_source -# POPULATE THE DATABASE -ynh_script_progression --message="Reconfiguring Postgresql database..." -#REMOVEME? ynh_psql_test_if_first_run -ynh_psql_execute_as_root --sql "CREATE USER ${db_user} WITH PASSWORD '${db_pwd}' SUPERUSER CREATEDB CREATEROLE REPLICATION" +#================================================= +# RESTORE SYSTEM CONFIGURATIONS +#================================================= +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + +ynh_restore_file --origin_path="/etc/uwsgi/apps-available/$app.ini" + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE VARIOUS FILES #================================================= ynh_script_progression --message="Restoring various files..." -ynh_restore_file --origin_path="/etc/uwsgi/apps-available/$app.ini" ynh_restore_file --origin_path="/var/lib/pgadmin" # Restore systemd configuration @@ -103,7 +84,6 @@ set_permission #================================================= ynh_script_progression --message="Restoring the logrotate configuration..." -ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # START SYSTEMD SERVICE 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 18/59] 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 #================================================= From 2f1835664dfbe3a79bd99f3c6cbf17015883f6b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 17:03:58 +0100 Subject: [PATCH 19/59] Update packagingv2 --- scripts/change_url | 93 +++------------------------------------------- scripts/restore | 17 +++------ scripts/upgrade | 82 ++++++---------------------------------- 3 files changed, 23 insertions(+), 169 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 56ed063..43964ea 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -11,63 +11,14 @@ source experimental_helper.sh source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN -#REMOVEME? old_path=$YNH_APP_OLD_PATH - -#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN -#REMOVEME? new_path=$YNH_APP_NEW_PATH - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." - -#REMOVEME? # Needed for helper "ynh_add_nginx_config" -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) - -#================================================= -# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - #REMOVEME? ynh_clean_check_starting - # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. -#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # Restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -#REMOVEME? change_domain=0 -#REMOVEME? if [ "$old_domain" != "$new_domain" ] -then - #REMOVEME? change_domain=1 -fi - -#REMOVEME? change_path=0 -#REMOVEME? if [ "$old_path" != "$new_path" ] -then - #REMOVEME? change_path=1 -fi - #================================================= # STANDARD MODIFICATIONS #================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="stop" --log_path="/var/log/uwsgi/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF @@ -76,39 +27,12 @@ ynh_script_progression --message="Updating NGINX web server configuration..." ynh_change_url_nginx_config -#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - -# Change the path in the NGINX config file -if [ $change_path -eq 1 ] -then - # Make a backup of the original NGINX config file if modified -#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for NGINX helper -#REMOVEME? domain="$old_domain" -#REMOVEME? path="$new_path" - # Create a dedicated NGINX config -#REMOVEME? ynh_add_nginx_config -fi - -# Change the domain for NGINX -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location -#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" -#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location -#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi - #================================================= # SPECIFIC MODIFICATIONS #================================================= # UPDATE CONFIGURATION #================================================= ynh_script_progression --message="Updating configuration..." -#REMOVEME? -domain=$new_domain -path=$new_path # Update UWSGI Config ynh_add_uwsgi_service @@ -124,13 +48,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=3 ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="restart" --line_match="WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path="/var/log/uwsgi/$app/$app.log" sleep 10 -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." - -#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index eef371c..6b492a3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -28,7 +28,7 @@ chown -R "$app:www-data" "$install_dir" #================================================= ynh_script_progression --message="Restoring the Postgresql superuser..." --weight=1 -ynh_psql_execute_as_root --sql "CREATE USER ${db_user} WITH PASSWORD '${db_pwd}' SUPERUSER CREATEDB CREATEROLE REPLICATION" +ynh_psql_execute_as_root --sql "CREATE USER $db_user WITH PASSWORD '$db_pwd' SUPERUSER CREATEDB CREATEROLE REPLICATION" #================================================= # REINSTALL DEPENDENCIES @@ -63,22 +63,17 @@ ynh_restore_uwsgi_service ynh_script_progression --message="Protecting directory..." set_permission -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=3 - -ynh_systemd_action --service_name "uwsgi-app@$app.service" --action="restart" --line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log" - #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 + +ynh_systemd_action --service_name "uwsgi-app@$app.service" --action="restart" --line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log" +sleep 10 ynh_systemd_action --service_name=nginx --action=reload -sleep 10 #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index c509957..c6e7fc8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -10,44 +10,6 @@ source experimental_helper.sh source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) - -app_version=$(ynh_app_upstream_version) -app_sub_version=$(echo $app_version | cut -d'-' -f2) - - -#================================================= -# CHECK VERSION -#================================================= -ynh_script_progression --message="Checking version..." - -upgrade_type=$(ynh_check_app_version_changed) - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting - # Restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -55,8 +17,9 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Stopping a systemd service..." -test -e /etc/uwsgi/apps-available/$app.ini && \ +if [ -f "/etc/uwsgi/apps-available/$app.ini" ]; then ynh_systemd_action --service_name "uwsgi-app@$app.service" --action stop +fi #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -67,20 +30,8 @@ if ! grep -q "$install_dir" /etc/passwd; then sed --in-place -r "s@$app\:x\:([[:digit:]]+\:[[:digit:]]+)\:\:/.*/$app\:/usr/sbin/nologin@$app\:x\:\1\:\:$install_dir\:/usr/sbin/nologin@g" /etc/passwd fi -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." - -# Create a dedicated NGINX config -ynh_add_nginx_config - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." - -#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +# Clean old uwsgi config +ynh_secure_remove /etc/uwsgi/apps-enabled/pgadmin.ini #================================================= # SPECIFIC UPGRADE @@ -95,22 +46,20 @@ install_source ynh_script_progression --message="Configuring application..." config_pgadmin -# Config uwsgi -ynh_add_uwsgi_service - -# Clean old uwsgi config -ynh_secure_remove /etc/uwsgi/apps-enabled/pgadmin.ini - # Set permission after initialisation ynh_script_progression --message="Protecting directory..." set_permission #================================================= -# GENERIC FINALIZATION +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 + +# Create a dedicated NGINX config +ynh_add_nginx_config + +# Config uwsgi +ynh_add_uwsgi_service # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --logfile /var/log/pgadmin --nonappend @@ -123,13 +72,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=3 ynh_systemd_action --service_name "uwsgi-app@$app.service" --action="restart" --line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log" sleep 10 -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= From 13e7fe0dd1bd8830a27bc073264b64726880d559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 17:05:46 +0100 Subject: [PATCH 20/59] Remove postgresql from manifest --- manifest.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.toml b/manifest.toml index 4a57f2c..3d8cbf3 100644 --- a/manifest.toml +++ b/manifest.toml @@ -67,5 +67,5 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen [resources.apt] packages = "python3-pip, build-essential, python3-dev, python3-venv, postgresql, uwsgi, uwsgi-plugin-python3, expect, libpq-dev, libkrb5-dev" - [resources.database] - type = "postgresql" + # [resources.database] + # type = "postgresql" From 1838024e42ef3319a6571df80ff4c70a292a9748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 17:20:58 +0100 Subject: [PATCH 21/59] handle psql user differently --- manifest.toml | 4 ++-- scripts/install | 2 +- scripts/remove | 7 ------- scripts/restore | 3 +-- scripts/upgrade | 5 ++--- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/manifest.toml b/manifest.toml index 3d8cbf3..4a57f2c 100644 --- a/manifest.toml +++ b/manifest.toml @@ -67,5 +67,5 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen [resources.apt] packages = "python3-pip, build-essential, python3-dev, python3-venv, postgresql, uwsgi, uwsgi-plugin-python3, expect, libpq-dev, libkrb5-dev" - # [resources.database] - # type = "postgresql" + [resources.database] + type = "postgresql" diff --git a/scripts/install b/scripts/install index 2438a40..75c299f 100644 --- a/scripts/install +++ b/scripts/install @@ -44,7 +44,7 @@ chmod +x "$install_dir/setup.exp" # Postgresql superuser #================================================= ynh_script_progression --message="Configuring Postgresql superuser..." -ynh_psql_execute_as_root --sql "CREATE USER $db_user WITH PASSWORD '$db_pwd' SUPERUSER CREATEDB CREATEROLE REPLICATION" +ynh_psql_execute_as_root --sql "ALTER USER $app WITH SUPERUSER CREATEDB CREATEROLE REPLICATION" # Add Server In PGadmin database ynh_add_config --template="setup_database.py" --destination "$install_dir/setup_database.py" diff --git a/scripts/remove b/scripts/remove index 08ad141..d7dcf48 100644 --- a/scripts/remove +++ b/scripts/remove @@ -27,13 +27,6 @@ ynh_remove_logrotate # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# CONFIGURE POSTGRESQL -#================================================= -ynh_script_progression --message="Removing the Postgresql superuser..." - -ynh_psql_drop_user "$db_user" - #================================================= # SPECIFIC REMOVE #================================================= diff --git a/scripts/restore b/scripts/restore index 6b492a3..4c08d5f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -27,8 +27,7 @@ chown -R "$app:www-data" "$install_dir" # RESTORE THE POSTGRESQL SUPERUSER #================================================= ynh_script_progression --message="Restoring the Postgresql superuser..." --weight=1 - -ynh_psql_execute_as_root --sql "CREATE USER $db_user WITH PASSWORD '$db_pwd' SUPERUSER CREATEDB CREATEROLE REPLICATION" +ynh_psql_execute_as_root --sql "ALTER USER $db_user WITH SUPERUSER CREATEDB CREATEROLE REPLICATION" #================================================= # REINSTALL DEPENDENCIES diff --git a/scripts/upgrade b/scripts/upgrade index c6e7fc8..d694fe8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -26,9 +26,8 @@ fi #================================================= ynh_script_progression --message="Ensuring downward compatibility..." -if ! grep -q "$install_dir" /etc/passwd; then - sed --in-place -r "s@$app\:x\:([[:digit:]]+\:[[:digit:]]+)\:\:/.*/$app\:/usr/sbin/nologin@$app\:x\:\1\:\:$install_dir\:/usr/sbin/nologin@g" /etc/passwd -fi +# Set the proper home directory +usermod -d "$install_dir" "$app" # Clean old uwsgi config ynh_secure_remove /etc/uwsgi/apps-enabled/pgadmin.ini From fa5931243b23e399d4e328632830d20091559324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 17:38:42 +0100 Subject: [PATCH 22/59] Add description to uwsgi systemd service --- scripts/experimental_helper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/experimental_helper.sh b/scripts/experimental_helper.sh index 5c3c786..3c816df 100644 --- a/scripts/experimental_helper.sh +++ b/scripts/experimental_helper.sh @@ -109,7 +109,7 @@ ynh_add_uwsgi_service () { systemctl enable "uwsgi-app@$app.service" # Add as a service - yunohost service add "uwsgi-app@$app" --log "/var/log/uwsgi/$app/$app.log" + yunohost service add "uwsgi-app@$app" --log "/var/log/uwsgi/$app/$app.log" --description="UWSGI service for $app" } # Remove the dedicated uwsgi ini file From bce58021f7c364471026338dd41d29aeb7cf52ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 18:01:12 +0100 Subject: [PATCH 23/59] fix upgrade --- scripts/upgrade | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index d694fe8..816e920 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -33,22 +33,33 @@ usermod -d "$install_dir" "$app" ynh_secure_remove /etc/uwsgi/apps-enabled/pgadmin.ini #================================================= -# SPECIFIC UPGRADE +# DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -# ... -#================================================= -# Download, check integrity, uncompress and patch the source from app.src ynh_script_progression --message="Upgrading source files..." --weight=6 -install_source +ynh_install_venv + +_install_pgadmin_pip + +setup_dir + +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a configuration file..." --weight=1 -# CONFIGURE PGADMIN -ynh_script_progression --message="Configuring application..." config_pgadmin -# Set permission after initialisation -ynh_script_progression --message="Protecting directory..." +# CONFIGURE PGADMIN +ynh_add_config --template="config_local.py" --destination="$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/config_local.py" + set_permission +#================================================= +# Postgresql superuser +#================================================= +ynh_script_progression --message="Configuring Postgresql superuser..." +ynh_psql_execute_as_root --sql "ALTER USER $app WITH SUPERUSER CREATEDB CREATEROLE REPLICATION" + #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= From 6c607fbcd998438f0a03e24eddaae34226aa3b34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 18:01:57 +0100 Subject: [PATCH 24/59] fix calls to add_uwsgi_config --- scripts/change_url | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 43964ea..fa4cd4c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -35,7 +35,7 @@ ynh_change_url_nginx_config ynh_script_progression --message="Updating configuration..." # Update UWSGI Config -ynh_add_uwsgi_service +ynh_add_uwsgi_service "python_version" #================================================= # GENERIC FINALISATION diff --git a/scripts/upgrade b/scripts/upgrade index 816e920..ee62989 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -69,7 +69,7 @@ ynh_script_progression --message="Upgrading system configurations related to $ap ynh_add_nginx_config # Config uwsgi -ynh_add_uwsgi_service +ynh_add_uwsgi_service "python_version" # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --logfile /var/log/pgadmin --nonappend From 2bec4025fc89b8edf69897d9ab684c1fa6a4760f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 18:03:19 +0100 Subject: [PATCH 25/59] Add test_upgrade_froms --- tests.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests.toml b/tests.toml index 94abb79..4354622 100644 --- a/tests.toml +++ b/tests.toml @@ -3,3 +3,6 @@ test_format = 1.0 [default] + + test_upgrade_from.da90e7957a1a365f3c840df02c41cd14592030db.name = "Last packaging v1 version" + test_upgrade_from.1eef99673bac443b9b3885f859033f385a004557.name = "6.14~ynh1" From fa88c455051754fdfb4c87f80dc0a1d88ed78f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 18:24:56 +0100 Subject: [PATCH 26/59] Add systemd description --- scripts/experimental_helper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/experimental_helper.sh b/scripts/experimental_helper.sh index 3c816df..4691926 100644 --- a/scripts/experimental_helper.sh +++ b/scripts/experimental_helper.sh @@ -137,7 +137,7 @@ ynh_restore_uwsgi_service () { chown $app:root /var/log/uwsgi/$app chmod -R u=rwX,g=rX,o= /var/log/uwsgi/$app - yunohost service add "uwsgi-app@$app" --log "/var/log/uwsgi/$app/$app.log" + yunohost service add "uwsgi-app@$app" --log "/var/log/uwsgi/$app/$app.log" --description="UWSGI service for $app" } #================================================= From 9ae52eee753626b619d936d93ca4e956e19201d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 18:40:43 +0100 Subject: [PATCH 27/59] don't instal psycopg manually --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 309e2d2..62a3ceb 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -40,7 +40,7 @@ ynh_use_venv() { } _install_pgadmin_pip() { - ynh_exec_as "$app" "$venvpy" -m pip install --upgrade --no-cache-dir --ignore-installed "psycopg[c]" + # 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" ynh_exec_as "$app" "$venvpy" -m pip install --upgrade -r "$install_dir/requirements.txt" From 1574463df402a5881d538e639bcc1df271963a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 18:46:29 +0100 Subject: [PATCH 28/59] Cleanup doc, manifest --- doc/DISCLAIMER.md | 3 --- manifest.toml | 38 ++++++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 19 deletions(-) delete mode 100644 doc/DISCLAIMER.md diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index 9f6167c..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1,3 +0,0 @@ -### Multi-users support - -This app actually don't support the SSO and don't support LDAP. After the install of the app you can create a other user. So this app is multi-users but independently of the LDAP database. diff --git a/manifest.toml b/manifest.toml index 4a57f2c..c553c97 100644 --- a/manifest.toml +++ b/manifest.toml @@ -15,46 +15,41 @@ maintainers = ["Josué Tille"] license = "PostgreSQL" website = "https://www.pgadmin.org" admindoc = "https://www.pgadmin.org/docs" -cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) -fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. +cpe = "cpe:2.3:a:pgadmin:pgadmin" [integration] yunohost = ">= 11.0.11" -architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +architectures = ["arm64"] multi_instance = false -ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. -sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. +ldap = false +sso = false disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... [install] [install.domain] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "domain" [install.path] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "path" default = "/pgadmin" [install.admin] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "user" [install.password] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "password" [resources] [resources.sources] - [resources.sources.armv7_bullseye] - url = "https://github.com/Josue-T/pgadmin_python_build/releases/download/v4-7.7/pgadmin_4-7.7-bullseye-bin1_armv7l.tar.gz" - sha256 = "76022eeab9c985a30dab8b24027db095f74eb491077de01db77100e320b4a2e5" + # [resources.sources.armv7_bullseye] + # url = "https://github.com/Josue-T/pgadmin_python_build/releases/download/v4-7.7/pgadmin_4-7.7-bullseye-bin1_armv7l.tar.gz" + # sha256 = "76022eeab9c985a30dab8b24027db095f74eb491077de01db77100e320b4a2e5" - [resources.sources.armv7_bookworm] - url = "https://github.com/Josue-T/pgadmin_python_build/releases/download/v4-7.7/pgadmin_4-7.7-bookworm-bin1_armv7l.tar.gz" - sha256 = "e18206853ced73eb1922182c5a3c825d8af21d5e40fcd607311cc4e075a28e72" + # [resources.sources.armv7_bookworm] + # url = "https://github.com/Josue-T/pgadmin_python_build/releases/download/v4-7.7/pgadmin_4-7.7-bookworm-bin1_armv7l.tar.gz" + # sha256 = "e18206853ced73eb1922182c5a3c825d8af21d5e40fcd607311cc4e075a28e72" [resources.system_user] @@ -65,7 +60,18 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen main.url = "/" [resources.apt] - packages = "python3-pip, build-essential, python3-dev, python3-venv, postgresql, uwsgi, uwsgi-plugin-python3, expect, libpq-dev, libkrb5-dev" + packages = [ + "python3-pip", + "build-essential", + "python3-dev", + "python3-venv", + "postgresql", + "uwsgi", + "uwsgi-plugin-python3", + "expect", + "libpq-dev", + "libkrb5-dev", + ] [resources.database] type = "postgresql" From b294ceb01b05a524f3408dac3ec61c359b6abaae Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 30 Jan 2024 17:46:34 +0000 Subject: [PATCH 29/59] Auto-update README --- README.md | 6 ------ README_fr.md | 6 ------ 2 files changed, 12 deletions(-) diff --git a/README.md b/README.md index d253d8c..eaad730 100644 --- a/README.md +++ b/README.md @@ -25,12 +25,6 @@ pgAdmin is a feature rich Open Source administration and development platform fo ![Screenshot of pgAdmin4](./doc/screenshots/pgadmin4-welcome-light.png) -## Disclaimers / important information - -### Multi-users support - -This app actually don't support the SSO and don't support LDAP. After the install of the app you can create a other user. So this app is multi-users but independently of the LDAP database. - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index 59b39a1..ee8de64 100644 --- a/README_fr.md +++ b/README_fr.md @@ -25,12 +25,6 @@ pgAdmin is a feature rich Open Source administration and development platform fo ![Capture d’écran de pgAdmin4](./doc/screenshots/pgadmin4-welcome-light.png) -## Avertissements / informations importantes - -### Multi-users support - -This app actually don't support the SSO and don't support LDAP. After the install of the app you can create a other user. So this app is multi-users but independently of the LDAP database. - ## Documentations et ressources * Site officiel de l’app : From 4db7bc7f7f4addf278308cbc5811cffb90d67db8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 19:29:30 +0100 Subject: [PATCH 30/59] fix upgrade --- scripts/upgrade | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index ee62989..963605d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -47,8 +47,6 @@ setup_dir #================================================= ynh_script_progression --message="Updating a configuration file..." --weight=1 -config_pgadmin - # CONFIGURE PGADMIN ynh_add_config --template="config_local.py" --destination="$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/config_local.py" From 36314ceac602d7507452904495fa94017537b19c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 19:34:33 +0100 Subject: [PATCH 31/59] fix arch --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index c553c97..4e4c150 100644 --- a/manifest.toml +++ b/manifest.toml @@ -19,7 +19,7 @@ cpe = "cpe:2.3:a:pgadmin:pgadmin" [integration] yunohost = ">= 11.0.11" -architectures = ["arm64"] +architectures = "all" multi_instance = false ldap = false sso = false From 22e8b5160f75f27f949c5767e7d1fc7e35125fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 22:43:59 +0100 Subject: [PATCH 32/59] fix upgrade_from --- manifest.toml | 10 ---------- tests.toml | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/manifest.toml b/manifest.toml index 4e4c150..50aebd7 100644 --- a/manifest.toml +++ b/manifest.toml @@ -42,16 +42,6 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen type = "password" [resources] - [resources.sources] - # [resources.sources.armv7_bullseye] - # url = "https://github.com/Josue-T/pgadmin_python_build/releases/download/v4-7.7/pgadmin_4-7.7-bullseye-bin1_armv7l.tar.gz" - # sha256 = "76022eeab9c985a30dab8b24027db095f74eb491077de01db77100e320b4a2e5" - - # [resources.sources.armv7_bookworm] - # url = "https://github.com/Josue-T/pgadmin_python_build/releases/download/v4-7.7/pgadmin_4-7.7-bookworm-bin1_armv7l.tar.gz" - # sha256 = "e18206853ced73eb1922182c5a3c825d8af21d5e40fcd607311cc4e075a28e72" - - [resources.system_user] [resources.install_dir] diff --git a/tests.toml b/tests.toml index 4354622..fef783d 100644 --- a/tests.toml +++ b/tests.toml @@ -5,4 +5,4 @@ test_format = 1.0 [default] test_upgrade_from.da90e7957a1a365f3c840df02c41cd14592030db.name = "Last packaging v1 version" - test_upgrade_from.1eef99673bac443b9b3885f859033f385a004557.name = "6.14~ynh1" + test_upgrade_from.067601ed5bb19dde70f74a1fa1f6230a30efe6b5.name = "7.2~ynh1" From c25d4f94dc0cbcad29b3375ef6127a302a71fe61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 22:44:43 +0100 Subject: [PATCH 33/59] remove some readmes from manifest --- manifest.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.toml b/manifest.toml index 50aebd7..29fe4e1 100644 --- a/manifest.toml +++ b/manifest.toml @@ -24,8 +24,8 @@ multi_instance = false ldap = false sso = false disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... -ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... -ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.build = "300M" +ram.runtime = "200M" [install] [install.domain] From 38661e133b8147a545002b36024f4c0b95b0074c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 22:50:25 +0100 Subject: [PATCH 34/59] Try with the requirements.txt from the sources --- conf/requirements_orig.txt | 56 ++++++++++++++++++++++++++++++++++++++ scripts/_common.sh | 3 +- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 conf/requirements_orig.txt diff --git a/conf/requirements_orig.txt b/conf/requirements_orig.txt new file mode 100644 index 0000000..17a881c --- /dev/null +++ b/conf/requirements_orig.txt @@ -0,0 +1,56 @@ +############################################################################### +# +# IMPORTANT: +# +# If runtime or build time dependencies are changed in this file, the committer +# *must* ensure the DEB and RPM package maintainers are informed as soon as +# possible. +# +############################################################################### + +Flask==2.2.* +Flask-Gravatar==0.* +Flask-Login==0.* +Flask-Mail==0.* +Flask-Migrate==4.* +greenlet==1.1.2; python_version <= '3.10' +Flask-SQLAlchemy==3.0.* +Flask-WTF==1.1.1 +Flask-Compress==1.* +Flask-Paranoid==0.* +Flask-Babel==3.1.* +Flask-Security-Too==5.1.* +Flask-SocketIO==5.3.* +WTForms==3.0.* +passlib==1.* +pytz==2023.* +speaklater3==1.* +sqlparse==0.* +psutil==5.9.* +psycopg[c]==3.1.9 +python-dateutil==2.* +SQLAlchemy==2.* +bcrypt==4.0.* +cryptography==41.0.* +sshtunnel==0.* +ldap3==2.* +gssapi==1.8.* +eventlet==0.33.3 +httpagentparser==1.9.* +user-agents==2.2.0 +pywinpty==2.0.*; sys_platform=="win32" +Authlib==1.2.* +pyotp==2.* +qrcode==7.* +Pillow==9.* +boto3==1.28.* +botocore==1.31.* +urllib3==1.26.* +azure-mgmt-rdbms==10.1.0 +azure-mgmt-resource==23.0.1 +azure-mgmt-subscription==3.1.1 +azure-identity==1.13.0 +google-api-python-client==2.* +google-auth-oauthlib==1.0.0 +Werkzeug==2.2.3 +keyring==23.* diff --git a/scripts/_common.sh b/scripts/_common.sh index 62a3ceb..d9b559b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -42,6 +42,7 @@ ynh_use_venv() { _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" + # cp "$YNH_APP_BASEDIR/conf/requirement_$(lsb_release --codename --short).txt" "$install_dir/requirements.txt" + cp "$YNH_APP_BASEDIR/conf/requirement_orig.txt" "$install_dir/requirements.txt" ynh_exec_as "$app" "$venvpy" -m pip install --upgrade -r "$install_dir/requirements.txt" } From 1acd01d6576cb9a408afa85405f8cacf890767b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 22:51:50 +0100 Subject: [PATCH 35/59] Add init_main_permission --- manifest.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manifest.toml b/manifest.toml index 29fe4e1..d89b966 100644 --- a/manifest.toml +++ b/manifest.toml @@ -35,6 +35,10 @@ ram.runtime = "200M" type = "path" default = "/pgadmin" + [install.init_main_permission] + type = "group" + default = "admins" + [install.admin] type = "user" From 3691adb99f604b3535daca0dc0c06fbb32b47be3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 22:52:11 +0100 Subject: [PATCH 36/59] Add disk usage --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index d89b966..8023363 100644 --- a/manifest.toml +++ b/manifest.toml @@ -23,7 +23,7 @@ architectures = "all" multi_instance = false ldap = false sso = false -disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... +disk = "100M" ram.build = "300M" ram.runtime = "200M" From d76552994e683f06d15f0c252d94992e65fb23ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 22:54:29 +0100 Subject: [PATCH 37/59] oops --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index d9b559b..9c01c1a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -43,6 +43,6 @@ _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" - cp "$YNH_APP_BASEDIR/conf/requirement_orig.txt" "$install_dir/requirements.txt" + cp "$YNH_APP_BASEDIR/conf/requirements_orig.txt" "$install_dir/requirements.txt" ynh_exec_as "$app" "$venvpy" -m pip install --upgrade -r "$install_dir/requirements.txt" } From 59bd4bc0cee6c9ec668b6cebcc295b642b9a866f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 30 Jan 2024 23:07:51 +0100 Subject: [PATCH 38/59] pip direct --- scripts/_common.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 9c01c1a..9e22eec 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -43,6 +43,7 @@ _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" - cp "$YNH_APP_BASEDIR/conf/requirements_orig.txt" "$install_dir/requirements.txt" - ynh_exec_as "$app" "$venvpy" -m pip install --upgrade -r "$install_dir/requirements.txt" + # cp "$YNH_APP_BASEDIR/conf/requirements_orig.txt" "$install_dir/requirements.txt" + # ynh_exec_as "$app" "$venvpy" -m pip install --upgrade -r "$install_dir/requirements.txt" + ynh_exec_as "$app" "$venvpy" -m pip install --upgrade "pgadmin4==7.7" } From c3912a48584d8fb5e9a48a4d1d4cc905ac4f2428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 00:09:54 +0100 Subject: [PATCH 39/59] Don't save the password. dump the hashed password on backup. --- scripts/backup | 3 +++ scripts/install | 5 +++-- scripts/restore | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/backup b/scripts/backup index 8f5c2a8..9b500dd 100644 --- a/scripts/backup +++ b/scripts/backup @@ -38,6 +38,9 @@ ynh_backup --src_path="/etc/uwsgi/apps-available/$app.ini" ynh_backup --src_path="/var/lib/pgadmin" +# Backup hashed password +ynh_psql_execute_as_root --sql="SELECT rolpassword FROM pg_authid WHERE rolname='$app';" | head -3 | tail -1 > hashed_password.txt + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index 75c299f..7b815e0 100644 --- a/scripts/install +++ b/scripts/install @@ -44,12 +44,13 @@ chmod +x "$install_dir/setup.exp" # Postgresql superuser #================================================= ynh_script_progression --message="Configuring Postgresql superuser..." -ynh_psql_execute_as_root --sql "ALTER USER $app WITH SUPERUSER CREATEDB CREATEROLE REPLICATION" +# We overwrite the existing db_pwd +ynh_psql_execute_as_root --sql "ALTER USER $app WITH PASSWORD '$password' SUPERUSER CREATEDB CREATEROLE REPLICATION" # Add Server In PGadmin database ynh_add_config --template="setup_database.py" --destination "$install_dir/setup_database.py" chmod +x "$install_dir/setup_database.py" -"$install_dir/venv/bin/python3" "$install_dir/setup_database.py" "$db_user" "$db_pwd" +"$install_dir/venv/bin/python3" "$install_dir/setup_database.py" "$db_user" "$password" # Set permission after initialisation ynh_script_progression --message="Protecting directory" diff --git a/scripts/restore b/scripts/restore index 4c08d5f..9870e27 100644 --- a/scripts/restore +++ b/scripts/restore @@ -27,7 +27,8 @@ chown -R "$app:www-data" "$install_dir" # RESTORE THE POSTGRESQL SUPERUSER #================================================= ynh_script_progression --message="Restoring the Postgresql superuser..." --weight=1 -ynh_psql_execute_as_root --sql "ALTER USER $db_user WITH SUPERUSER CREATEDB CREATEROLE REPLICATION" +password=$(cat hashed_password.txt) +ynh_psql_execute_as_root --sql "ALTER USER $app WITH PASSWORD '$password' SUPERUSER CREATEDB CREATEROLE REPLICATION" #================================================= # REINSTALL DEPENDENCIES From 28e6d7142e622d2c832bc5c69e7549b8f06959d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 00:33:09 +0100 Subject: [PATCH 40/59] bump package revisions --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 8023363..595915d 100644 --- a/manifest.toml +++ b/manifest.toml @@ -7,7 +7,7 @@ name = "pgAdmin4" description.en = "Manage PostgreSQL databases over the web" description.fr = "Application web de gestion des bases de données PostgreSQL" -version = "7.7~ynh1" +version = "7.7~ynh2" maintainers = ["Josué Tille"] From d845cdd0240ceca9f37405117bec80a7ee0a2773 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 30 Jan 2024 23:33:14 +0000 Subject: [PATCH 41/59] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eaad730..de92bea 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in pgAdmin is a feature rich Open Source administration and development platform for PostgreSQL. -**Shipped version:** 7.7~ynh1 +**Shipped version:** 7.7~ynh2 ## Screenshots diff --git a/README_fr.md b/README_fr.md index ee8de64..344e5c8 100644 --- a/README_fr.md +++ b/README_fr.md @@ -19,7 +19,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po pgAdmin is a feature rich Open Source administration and development platform for PostgreSQL. -**Version incluse :** 7.7~ynh1 +**Version incluse :** 7.7~ynh2 ## Captures d’écran From 670a55b6328dda7632b3913c85e1808e2dd4f8f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 12:17:37 +0100 Subject: [PATCH 42/59] do not overwrite db_pwd --- conf/setup.exp | 3 +-- scripts/install | 9 +++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/conf/setup.exp b/conf/setup.exp index 26efb02..5c67097 100755 --- a/conf/setup.exp +++ b/conf/setup.exp @@ -3,12 +3,11 @@ set timeout 20 set cmd [lindex $argv 0] set path [lindex $argv 1] -set user [lindex $argv 2] spawn $cmd $path expect "Email address:" -send "$user\r"; +send "__EMAIL__\r"; expect "Password:" send {__PASSWORD__}; diff --git a/scripts/install b/scripts/install index 7b815e0..ceabbcb 100644 --- a/scripts/install +++ b/scripts/install @@ -14,6 +14,7 @@ source /usr/share/yunohost/helpers # INITIALIZE AND STORE SETTINGS #================================================= +# Used in expect script email=$(ynh_user_get_info --username $admin --key 'mail') #================================================= @@ -38,19 +39,19 @@ ynh_script_progression --message="Configuring $app..." ynh_add_config --template="setup.exp" --destination="$install_dir/setup.exp" chmod +x "$install_dir/setup.exp" -"$install_dir/setup.exp" "$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" "$email" +"$install_dir/setup.exp" "$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" #================================================= # Postgresql superuser #================================================= ynh_script_progression --message="Configuring Postgresql superuser..." -# We overwrite the existing db_pwd -ynh_psql_execute_as_root --sql "ALTER USER $app WITH PASSWORD '$password' SUPERUSER CREATEDB CREATEROLE REPLICATION" + +ynh_psql_execute_as_root --sql "ALTER USER $app WITH SUPERUSER CREATEDB CREATEROLE REPLICATION" # Add Server In PGadmin database ynh_add_config --template="setup_database.py" --destination "$install_dir/setup_database.py" chmod +x "$install_dir/setup_database.py" -"$install_dir/venv/bin/python3" "$install_dir/setup_database.py" "$db_user" "$password" +"$install_dir/venv/bin/python3" "$install_dir/setup_database.py" "$db_user" "$db_pwd" # Set permission after initialisation ynh_script_progression --message="Protecting directory" From c86d24e009cbdfcc5a3ec788e06438cc4bceea92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 12:17:54 +0100 Subject: [PATCH 43/59] Add some doc --- doc/ADMIN.md | 4 ++++ doc/POST_INSTALL.md | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 doc/ADMIN.md create mode 100644 doc/POST_INSTALL.md diff --git a/doc/ADMIN.md b/doc/ADMIN.md new file mode 100644 index 0000000..0b5199f --- /dev/null +++ b/doc/ADMIN.md @@ -0,0 +1,4 @@ +The Postgresql admin user credentials: + +Username: __DB_USER__ +Password: __DB_PWD__ diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md new file mode 100644 index 0000000..0b5199f --- /dev/null +++ b/doc/POST_INSTALL.md @@ -0,0 +1,4 @@ +The Postgresql admin user credentials: + +Username: __DB_USER__ +Password: __DB_PWD__ From c114213d415d17b396b37ebaca0d60f24036a009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 12:21:14 +0100 Subject: [PATCH 44/59] fix doc --- doc/POST_INSTALL.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md index 0b5199f..fb9380b 100644 --- a/doc/POST_INSTALL.md +++ b/doc/POST_INSTALL.md @@ -2,3 +2,5 @@ The Postgresql admin user credentials: Username: __DB_USER__ Password: __DB_PWD__ + +You can connect to pgAdmin with your email and the password you provided at installation time. From 8ea379db49a4c9e64a65d611d9504dd0d2479243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 12:23:21 +0100 Subject: [PATCH 45/59] reword doc --- doc/POST_INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md index fb9380b..bd29885 100644 --- a/doc/POST_INSTALL.md +++ b/doc/POST_INSTALL.md @@ -1,4 +1,4 @@ -The Postgresql admin user credentials: +Although you usually don't need them, here are the Postgresql admin user credentials: Username: __DB_USER__ Password: __DB_PWD__ From b74f74013a4da181520fda16086f8bfa7d0eb0e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 12:23:49 +0100 Subject: [PATCH 46/59] Use json file to configure servers to pgadmin --- conf/server.json | 25 +++++++++++++++++++++++++ scripts/install | 9 ++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 conf/server.json diff --git a/conf/server.json b/conf/server.json new file mode 100644 index 0000000..8fae140 --- /dev/null +++ b/conf/server.json @@ -0,0 +1,25 @@ +{ + "Servers": { + "1": { + "Name": "YunoHost Server", + "Group": "Server Group 1", + "Host": "localhost", + "Port": 5432, + "Username": "__DB_USER__", + "Role": "__DB_USER__", + "MaintenanceDB": "postgres", + + "SSLMode": "prefer", + "SSLCert": "/.postgresql/postgresql.crt", + "SSLKey": "/.postgresql/postgresql.key", + + "Timeout": 10, + + "DBRestriction": "live_db test_db", + "PassFile": "/path/to/pgpassfile", + "Shared": false, + "Service": "postgresql-10", + "PasswordExecCommand": "echo '__DB_PWD__'" + } + } +} diff --git a/scripts/install b/scripts/install index ceabbcb..f61c811 100644 --- a/scripts/install +++ b/scripts/install @@ -49,9 +49,12 @@ ynh_script_progression --message="Configuring Postgresql superuser..." ynh_psql_execute_as_root --sql "ALTER USER $app WITH SUPERUSER CREATEDB CREATEROLE REPLICATION" # Add Server In PGadmin database -ynh_add_config --template="setup_database.py" --destination "$install_dir/setup_database.py" -chmod +x "$install_dir/setup_database.py" -"$install_dir/venv/bin/python3" "$install_dir/setup_database.py" "$db_user" "$db_pwd" +# ynh_add_config --template="setup_database.py" --destination "$install_dir/setup_database.py" +# chmod +x "$install_dir/setup_database.py" +# "$install_dir/venv/bin/python3" "$install_dir/setup_database.py" "$db_user" "$db_pwd" + +ynh_add_config --template="server.json" --destination="$install_dir/server.json" +"$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" --load-servers "$install_dir/server.json" # Set permission after initialisation ynh_script_progression --message="Protecting directory" From a79663c1ca223a1449479f4ba892e2d65ab82858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 14:06:03 +0100 Subject: [PATCH 47/59] fix install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index f61c811..42ddedc 100644 --- a/scripts/install +++ b/scripts/install @@ -54,7 +54,7 @@ ynh_psql_execute_as_root --sql "ALTER USER $app WITH SUPERUSER CREATEDB CREATERO # "$install_dir/venv/bin/python3" "$install_dir/setup_database.py" "$db_user" "$db_pwd" ynh_add_config --template="server.json" --destination="$install_dir/server.json" -"$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" --load-servers "$install_dir/server.json" +"$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" --user "$email" --load-servers "$install_dir/server.json" # Set permission after initialisation ynh_script_progression --message="Protecting directory" From 5f46b9788bb30efb02d065e440aef200370f6688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 14:25:14 +0100 Subject: [PATCH 48/59] Fix server.json --- conf/server.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/conf/server.json b/conf/server.json index 8fae140..76f4068 100644 --- a/conf/server.json +++ b/conf/server.json @@ -2,7 +2,7 @@ "Servers": { "1": { "Name": "YunoHost Server", - "Group": "Server Group 1", + "Group": "Servers", "Host": "localhost", "Port": 5432, "Username": "__DB_USER__", @@ -10,15 +10,13 @@ "MaintenanceDB": "postgres", "SSLMode": "prefer", - "SSLCert": "/.postgresql/postgresql.crt", - "SSLKey": "/.postgresql/postgresql.key", "Timeout": 10, "DBRestriction": "live_db test_db", "PassFile": "/path/to/pgpassfile", "Shared": false, - "Service": "postgresql-10", + "Service": "", "PasswordExecCommand": "echo '__DB_PWD__'" } } From e9907e22636a0920b50d41c918b99bcfd3eec6e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 14:38:11 +0100 Subject: [PATCH 49/59] fix server.json, cleanup --- conf/server.json | 17 +++++++---------- scripts/install | 28 ++++++++++------------------ 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/conf/server.json b/conf/server.json index 76f4068..e465494 100644 --- a/conf/server.json +++ b/conf/server.json @@ -5,19 +5,16 @@ "Group": "Servers", "Host": "localhost", "Port": 5432, + "MaintenanceDB": "postgres", "Username": "__DB_USER__", "Role": "__DB_USER__", - "MaintenanceDB": "postgres", - - "SSLMode": "prefer", - - "Timeout": 10, - - "DBRestriction": "live_db test_db", - "PassFile": "/path/to/pgpassfile", "Shared": false, - "Service": "", - "PasswordExecCommand": "echo '__DB_PWD__'" + "DBRestriction": "live_db test_db", + "KerberosAuthentication": false, + "ConnectionParameters": { + "sslmode": "prefer", + "connect_timeout": 10 + } } } } diff --git a/scripts/install b/scripts/install index 42ddedc..bbe6fe8 100644 --- a/scripts/install +++ b/scripts/install @@ -17,6 +17,13 @@ source /usr/share/yunohost/helpers # Used in expect script email=$(ynh_user_get_info --username $admin --key 'mail') +#================================================= +# Postgresql superuser +#================================================= +ynh_script_progression --message="Configuring Postgresql superuser..." + +ynh_psql_execute_as_root --sql "ALTER USER $app WITH SUPERUSER CREATEDB CREATEROLE REPLICATION" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -30,31 +37,16 @@ setup_dir #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression --message="Configuring pgAdmin..." --weight=1 -# CONFIGURE PGADMIN ynh_add_config --template="config_local.py" --destination="$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/config_local.py" -ynh_script_progression --message="Configuring $app..." - ynh_add_config --template="setup.exp" --destination="$install_dir/setup.exp" chmod +x "$install_dir/setup.exp" -"$install_dir/setup.exp" "$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" - -#================================================= -# Postgresql superuser -#================================================= -ynh_script_progression --message="Configuring Postgresql superuser..." - -ynh_psql_execute_as_root --sql "ALTER USER $app WITH SUPERUSER CREATEDB CREATEROLE REPLICATION" - -# Add Server In PGadmin database -# ynh_add_config --template="setup_database.py" --destination "$install_dir/setup_database.py" -# chmod +x "$install_dir/setup_database.py" -# "$install_dir/venv/bin/python3" "$install_dir/setup_database.py" "$db_user" "$db_pwd" +ynh_exec_as "$app" "$install_dir/setup.exp" "$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" ynh_add_config --template="server.json" --destination="$install_dir/server.json" -"$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" --user "$email" --load-servers "$install_dir/server.json" +ynh_exec_as "$app" "$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" --user "$email" --load-servers "$install_dir/server.json" # Set permission after initialisation ynh_script_progression --message="Protecting directory" From 61ab52989740c1767cfabb21315d136bc8689bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 14:44:14 +0100 Subject: [PATCH 50/59] reorder steps --- scripts/restore | 14 +++++++------- scripts/upgrade | 14 ++++++++------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/scripts/restore b/scripts/restore index 9870e27..8fed89b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -11,6 +11,13 @@ source ../settings/scripts/experimental_helper.sh source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# RESTORE THE POSTGRESQL SUPERUSER +#================================================= +ynh_script_progression --message="Restoring the Postgresql superuser..." --weight=1 + +ynh_psql_execute_as_root --sql "ALTER USER $app WITH SUPERUSER CREATEDB CREATEROLE REPLICATION" + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -23,13 +30,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" -#================================================= -# RESTORE THE POSTGRESQL SUPERUSER -#================================================= -ynh_script_progression --message="Restoring the Postgresql superuser..." --weight=1 -password=$(cat hashed_password.txt) -ynh_psql_execute_as_root --sql "ALTER USER $app WITH PASSWORD '$password' SUPERUSER CREATEDB CREATEROLE REPLICATION" - #================================================= # REINSTALL DEPENDENCIES #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 963605d..8d83eaa 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -32,6 +32,14 @@ usermod -d "$install_dir" "$app" # Clean old uwsgi config ynh_secure_remove /etc/uwsgi/apps-enabled/pgadmin.ini +#================================================= +# Postgresql superuser +#================================================= +ynh_script_progression --message="Configuring Postgresql superuser..." + +# Re-set the db_pwd just in case… +ynh_psql_execute_as_root --sql "ALTER USER $app WITH PASSWORD '$db_pwd' SUPERUSER CREATEDB CREATEROLE REPLICATION" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -52,12 +60,6 @@ ynh_add_config --template="config_local.py" --destination="$install_dir/venv/lib set_permission -#================================================= -# Postgresql superuser -#================================================= -ynh_script_progression --message="Configuring Postgresql superuser..." -ynh_psql_execute_as_root --sql "ALTER USER $app WITH SUPERUSER CREATEDB CREATEROLE REPLICATION" - #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= From 39cbd3f07e63a6b8359d6b313cbe475080a60f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 14:44:23 +0100 Subject: [PATCH 51/59] Add doc about this upgrade --- doc/POST_INSTALL.md | 9 ++++----- doc/POST_UPGRADE.d/7.7~ynh2.md | 5 +++++ 2 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 doc/POST_UPGRADE.d/7.7~ynh2.md diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md index bd29885..a0e8170 100644 --- a/doc/POST_INSTALL.md +++ b/doc/POST_INSTALL.md @@ -1,6 +1,5 @@ -Although you usually don't need them, here are the Postgresql admin user credentials: - -Username: __DB_USER__ -Password: __DB_PWD__ - You can connect to pgAdmin with your email and the password you provided at installation time. + +You will need to provide the Postgresql admin password once, so here it is: `__DB_PWD__`. + +pgAdmin will then store it encrypted, so you won't need anymore. diff --git a/doc/POST_UPGRADE.d/7.7~ynh2.md b/doc/POST_UPGRADE.d/7.7~ynh2.md new file mode 100644 index 0000000..bc743de --- /dev/null +++ b/doc/POST_UPGRADE.d/7.7~ynh2.md @@ -0,0 +1,5 @@ +This upgrade fixes authentication with PostgreSQL. + +Here is the Postgresql admin password: `__DB_PWD__`. + +You can log into pgAdmin with your email and the password you provided during installation. From 66d63af2db06b566763a0eca682102753f6ee27d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 14:52:39 +0100 Subject: [PATCH 52/59] Cleanup permissions --- scripts/_common.sh | 15 --------------- scripts/backup | 2 ++ scripts/install | 12 +++++++----- scripts/restore | 16 ++++++++-------- scripts/upgrade | 10 +++++++--- 5 files changed, 24 insertions(+), 31 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 9e22eec..58e8bcc 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -10,21 +10,6 @@ python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)" # DEFINE ALL COMMON FONCTIONS #================================================= -setup_dir() { - # Create empty dir for pgadmin - mkdir -p /var/lib/pgadmin - mkdir -p /var/log/pgadmin -} - -set_permission() { - # Set permission - chown $app:root -R $install_dir - chown $app:root -R /var/lib/pgadmin - mkdir -p /var/log/pgadmin - chown $app:root -R /var/log/pgadmin - chmod u=rwX,g=rX,o= -R /var/lib/pgadmin -} - ynh_install_venv() { if [ -f "$install_dir/venv/bin/python" ]; then ynh_exec_as "$app" python3 -m venv "$install_dir/venv" --upgrade diff --git a/scripts/backup b/scripts/backup index 9b500dd..9f52868 100644 --- a/scripts/backup +++ b/scripts/backup @@ -41,6 +41,8 @@ ynh_backup --src_path="/var/lib/pgadmin" # Backup hashed password ynh_psql_execute_as_root --sql="SELECT rolpassword FROM pg_authid WHERE rolname='$app';" | head -3 | tail -1 > hashed_password.txt +ynh_backup --src_path="/var/log/pgadmin" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index bbe6fe8..45d433a 100644 --- a/scripts/install +++ b/scripts/install @@ -32,7 +32,11 @@ ynh_install_venv _install_pgadmin_pip -setup_dir +chown -R "$app:root" "$install_dir" + +mkdir -p /var/lib/pgadmin +chmod -R 750 /var/lib/pgadmin +chown -R "$app:root" /var/lib/pgadmin #================================================= # ADD A CONFIGURATION @@ -40,6 +44,7 @@ setup_dir ynh_script_progression --message="Configuring pgAdmin..." --weight=1 ynh_add_config --template="config_local.py" --destination="$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/config_local.py" +chown -R "$app:root" "$install_dir" ynh_add_config --template="setup.exp" --destination="$install_dir/setup.exp" chmod +x "$install_dir/setup.exp" @@ -48,10 +53,6 @@ ynh_exec_as "$app" "$install_dir/setup.exp" "$install_dir/venv/bin/python3" "$in ynh_add_config --template="server.json" --destination="$install_dir/server.json" ynh_exec_as "$app" "$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" --user "$email" --load-servers "$install_dir/server.json" -# Set permission after initialisation -ynh_script_progression --message="Protecting directory" -set_permission - #================================================= # SYSTEM CONFIGURATION #================================================= @@ -64,6 +65,7 @@ ynh_add_nginx_config ynh_add_uwsgi_service "python_version" ynh_use_logrotate --logfile="/var/log/pgadmin" +chown -R "$app:root" /var/log/pgadmin #================================================= # START SYSTEMD SERVICE diff --git a/scripts/restore b/scripts/restore index 8fed89b..71a119a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -25,10 +25,7 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" -### $install_dir will automatically be initialized with some decent -### permissions by default ... however, you may need to recursively reapply -### ownership to all files such as after the ynh_setup_source step -chown -R "$app:www-data" "$install_dir" +chown -R "$app:root" "$install_dir" #================================================= # REINSTALL DEPENDENCIES @@ -54,15 +51,18 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_script_progression --message="Restoring various files..." ynh_restore_file --origin_path="/var/lib/pgadmin" +chmod -R 750 /var/lib/pgadmin +chown -R "$app:root" /var/lib/pgadmin + +ynh_restore_file --origin_path="/var/log/$app/" +chmod -R 750 /var/log/pgadmin +chown -R "$app:root" /var/log/pgadmin + # Restore systemd configuration ynh_script_progression --message="Reconfiguring application..." ynh_restore_uwsgi_service -# Set the permission -ynh_script_progression --message="Protecting directory..." -set_permission - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 8d83eaa..18f6fc4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -48,7 +48,11 @@ ynh_install_venv _install_pgadmin_pip -setup_dir +chown -R "$app:root" "$install_dir" + +mkdir -p /var/lib/pgadmin +chmod -R 750 /var/lib/pgadmin +chown -R "$app:root" /var/lib/pgadmin #================================================= # UPDATE A CONFIG FILE @@ -57,8 +61,7 @@ ynh_script_progression --message="Updating a configuration file..." --weight=1 # CONFIGURE PGADMIN ynh_add_config --template="config_local.py" --destination="$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/config_local.py" - -set_permission +chown -R "$app:root" "$install_dir" #================================================= # REAPPLY SYSTEM CONFIGURATIONS @@ -73,6 +76,7 @@ ynh_add_uwsgi_service "python_version" # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --logfile /var/log/pgadmin --nonappend +chown -R "$app:root" /var/log/pgadmin #================================================= # START SYSTEMD SERVICE From 334d0d0e01ef8641347fc72405ef2d1e882651e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 14:53:27 +0100 Subject: [PATCH 53/59] Cleanup requirements --- conf/requirement_bookworm.txt | 107 --------------------------------- conf/requirement_bullseye.txt | 108 ---------------------------------- conf/requirements_orig.txt | 56 ------------------ scripts/_common.sh | 5 -- 4 files changed, 276 deletions(-) delete mode 100644 conf/requirement_bookworm.txt delete mode 100644 conf/requirement_bullseye.txt delete mode 100644 conf/requirements_orig.txt diff --git a/conf/requirement_bookworm.txt b/conf/requirement_bookworm.txt deleted file mode 100644 index 40c04ed..0000000 --- a/conf/requirement_bookworm.txt +++ /dev/null @@ -1,107 +0,0 @@ -alembic==1.12.0 -Authlib==1.2.1 -azure-common==1.1.28 -azure-core==1.29.4 -azure-identity==1.13.0 -azure-mgmt-core==1.4.0 -azure-mgmt-rdbms==10.1.0 -azure-mgmt-resource==23.0.1 -azure-mgmt-subscription==3.1.1 -Babel==2.12.1 -bcrypt==4.0.1 -bidict==0.22.1 -blinker==1.6.2 -boto3==1.28.52 -botocore==1.31.52 -Brotli==1.1.0 -cachetools==5.3.1 -certifi==2023.7.22 -cffi==1.15.1 -charset-normalizer==3.2.0 -click==8.1.7 -cryptography==41.0.4 -dnspython==2.4.2 -email-validator==2.0.0.post2 -eventlet==0.33.3 -Flask==2.2.5 -flask-babel==3.1.0 -Flask-Compress==1.14 -Flask-Gravatar==0.5.0 -Flask-Login==0.6.2 -Flask-Mail==0.9.1 -Flask-Migrate==4.0.5 -Flask-Paranoid==0.3.0 -Flask-Principal==0.4.0 -Flask-Security-Too==5.1.2 -Flask-SocketIO==5.3.6 -Flask-SQLAlchemy==3.0.5 -Flask-WTF==1.1.1 -google-api-core==2.11.1 -google-api-python-client==2.100.0 -google-auth==2.23.0 -google-auth-httplib2==0.1.1 -google-auth-oauthlib==1.0.0 -googleapis-common-protos==1.60.0 -greenlet==2.0.2 -h11==0.14.0 -httpagentparser==1.9.5 -httplib2==0.22.0 -idna==3.4 -importlib-metadata==6.8.0 -isodate==0.6.1 -itsdangerous==2.1.2 -jaraco.classes==3.3.0 -jeepney==0.8.0 -Jinja2==3.1.2 -jmespath==1.0.1 -keyring==23.13.1 -ldap3==2.9.1 -Mako==1.2.4 -MarkupSafe==2.1.3 -more-itertools==10.1.0 -msal==1.24.0 -msal-extensions==1.0.0 -msrest==0.7.1 -oauthlib==3.2.2 -paramiko==3.3.1 -passlib==1.7.4 -pgadmin4==7.7 -Pillow==9.5.0 -portalocker==2.8.2 -protobuf==4.24.3 -psutil==5.9.5 -psycopg==3.1.9 -psycopg-c==3.1.9 -pyasn1==0.5.0 -pyasn1-modules==0.3.0 -pycparser==2.21 -PyJWT==2.8.0 -PyNaCl==1.5.0 -pyotp==2.9.0 -pyparsing==3.1.1 -pypng==0.20220715.0 -python-dateutil==2.8.2 -python-engineio==4.7.1 -python-socketio==5.9.0 -pytz==2023.3.post1 -qrcode==7.4.2 -requests==2.31.0 -requests-oauthlib==1.3.1 -rsa==4.9 -s3transfer==0.6.2 -SecretStorage==3.3.3 -simple-websocket==0.10.1 -six==1.16.0 -speaklater3==1.4 -SQLAlchemy==2.0.21 -sqlparse==0.4.4 -sshtunnel==0.4.0 -typing_extensions==4.8.0 -ua-parser==0.18.0 -uritemplate==4.1.1 -urllib3==1.26.16 -user-agents==2.2.0 -Werkzeug==2.2.3 -wsproto==1.2.0 -WTForms==3.0.1 -zipp==3.17.0 diff --git a/conf/requirement_bullseye.txt b/conf/requirement_bullseye.txt deleted file mode 100644 index 1c8e668..0000000 --- a/conf/requirement_bullseye.txt +++ /dev/null @@ -1,108 +0,0 @@ -alembic==1.12.0 -Authlib==1.2.1 -azure-common==1.1.28 -azure-core==1.29.4 -azure-identity==1.13.0 -azure-mgmt-core==1.4.0 -azure-mgmt-rdbms==10.1.0 -azure-mgmt-resource==23.0.1 -azure-mgmt-subscription==3.1.1 -Babel==2.12.1 -bcrypt==4.0.1 -bidict==0.22.1 -blinker==1.6.2 -boto3==1.28.52 -botocore==1.31.52 -Brotli==1.1.0 -cachetools==5.3.1 -certifi==2023.7.22 -cffi==1.15.1 -charset-normalizer==3.2.0 -click==8.1.7 -cryptography==41.0.4 -dnspython==2.4.2 -email-validator==2.0.0.post2 -eventlet==0.33.3 -Flask==2.2.5 -flask-babel==3.1.0 -Flask-Compress==1.14 -Flask-Gravatar==0.5.0 -Flask-Login==0.6.2 -Flask-Mail==0.9.1 -Flask-Migrate==4.0.5 -Flask-Paranoid==0.3.0 -Flask-Principal==0.4.0 -Flask-Security-Too==5.1.2 -Flask-SocketIO==5.3.6 -Flask-SQLAlchemy==3.0.5 -Flask-WTF==1.1.1 -google-api-core==2.11.1 -google-api-python-client==2.100.0 -google-auth==2.23.0 -google-auth-httplib2==0.1.1 -google-auth-oauthlib==1.0.0 -googleapis-common-protos==1.60.0 -greenlet==1.1.2 -h11==0.14.0 -httpagentparser==1.9.5 -httplib2==0.22.0 -idna==3.4 -importlib-metadata==6.8.0 -isodate==0.6.1 -itsdangerous==2.1.2 -jaraco.classes==3.3.0 -jeepney==0.8.0 -Jinja2==3.1.2 -jmespath==1.0.1 -keyring==23.13.1 -ldap3==2.9.1 -Mako==1.2.4 -MarkupSafe==2.1.3 -more-itertools==10.1.0 -msal==1.24.0 -msal-extensions==1.0.0 -msrest==0.7.1 -oauthlib==3.2.2 -paramiko==3.3.1 -passlib==1.7.4 -pgadmin4==7.7 -Pillow==9.5.0 -pkg_resources==0.0.0 -portalocker==2.8.2 -protobuf==4.24.3 -psutil==5.9.5 -psycopg==3.1.9 -psycopg-c==3.1.9 -pyasn1==0.5.0 -pyasn1-modules==0.3.0 -pycparser==2.21 -PyJWT==2.8.0 -PyNaCl==1.5.0 -pyotp==2.9.0 -pyparsing==3.1.1 -pypng==0.20220715.0 -python-dateutil==2.8.2 -python-engineio==4.7.1 -python-socketio==5.9.0 -pytz==2023.3.post1 -qrcode==7.4.2 -requests==2.31.0 -requests-oauthlib==1.3.1 -rsa==4.9 -s3transfer==0.6.2 -SecretStorage==3.3.3 -simple-websocket==0.10.1 -six==1.16.0 -speaklater3==1.4 -SQLAlchemy==2.0.21 -sqlparse==0.4.4 -sshtunnel==0.4.0 -typing_extensions==4.8.0 -ua-parser==0.18.0 -uritemplate==4.1.1 -urllib3==1.26.16 -user-agents==2.2.0 -Werkzeug==2.2.3 -wsproto==1.2.0 -WTForms==3.0.1 -zipp==3.17.0 diff --git a/conf/requirements_orig.txt b/conf/requirements_orig.txt deleted file mode 100644 index 17a881c..0000000 --- a/conf/requirements_orig.txt +++ /dev/null @@ -1,56 +0,0 @@ -############################################################################### -# -# IMPORTANT: -# -# If runtime or build time dependencies are changed in this file, the committer -# *must* ensure the DEB and RPM package maintainers are informed as soon as -# possible. -# -############################################################################### - -Flask==2.2.* -Flask-Gravatar==0.* -Flask-Login==0.* -Flask-Mail==0.* -Flask-Migrate==4.* -greenlet==1.1.2; python_version <= '3.10' -Flask-SQLAlchemy==3.0.* -Flask-WTF==1.1.1 -Flask-Compress==1.* -Flask-Paranoid==0.* -Flask-Babel==3.1.* -Flask-Security-Too==5.1.* -Flask-SocketIO==5.3.* -WTForms==3.0.* -passlib==1.* -pytz==2023.* -speaklater3==1.* -sqlparse==0.* -psutil==5.9.* -psycopg[c]==3.1.9 -python-dateutil==2.* -SQLAlchemy==2.* -bcrypt==4.0.* -cryptography==41.0.* -sshtunnel==0.* -ldap3==2.* -gssapi==1.8.* -eventlet==0.33.3 -httpagentparser==1.9.* -user-agents==2.2.0 -pywinpty==2.0.*; sys_platform=="win32" -Authlib==1.2.* -pyotp==2.* -qrcode==7.* -Pillow==9.* -boto3==1.28.* -botocore==1.31.* -urllib3==1.26.* -azure-mgmt-rdbms==10.1.0 -azure-mgmt-resource==23.0.1 -azure-mgmt-subscription==3.1.1 -azure-identity==1.13.0 -google-api-python-client==2.* -google-auth-oauthlib==1.0.0 -Werkzeug==2.2.3 -keyring==23.* diff --git a/scripts/_common.sh b/scripts/_common.sh index 58e8bcc..391b2d4 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -25,10 +25,5 @@ ynh_use_venv() { } _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" - # cp "$YNH_APP_BASEDIR/conf/requirements_orig.txt" "$install_dir/requirements.txt" - # ynh_exec_as "$app" "$venvpy" -m pip install --upgrade -r "$install_dir/requirements.txt" ynh_exec_as "$app" "$venvpy" -m pip install --upgrade "pgadmin4==7.7" } From 9cdd2075c1f18c1303082e44f380f63779de731b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 14:54:13 +0100 Subject: [PATCH 54/59] Remove legacy setup_database.py --- conf/setup_database.py | 55 ------------------------------------------ 1 file changed, 55 deletions(-) delete mode 100644 conf/setup_database.py diff --git a/conf/setup_database.py b/conf/setup_database.py deleted file mode 100644 index e2a62ab..0000000 --- a/conf/setup_database.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/python - -from importlib.machinery import SourceFileLoader -import sqlite3 -import sys - -# Import crypto from pgadmin project __PYTHON_VERSION__ -python_version = str(sys.version_info[0]) + "." + str(sys.version_info[1]) -crypto = SourceFileLoader('crypto', '/var/www/pgadmin/venv/lib/python' + - python_version + '/site-packages/pgadmin4/pgadmin/utils/crypto.py').load_module() - -# Get arguments -username = sys.argv[1] -password = sys.argv[2] - -# Connect to sqlite3 -conn = sqlite3.connect('/var/lib/pgadmin/pgadmin4.db') - -# Get encrypte user password from the database -cursor = conn.execute('SELECT `password`,1 FROM `user`') -user_encrypted_password = cursor.fetchone()[0] - -# Encrypt database password -crypted_password = crypto.encrypt(password, user_encrypted_password) - -# Declare database data to put in database -data = {'id': 1, 'user_id': 1, 'servergroup_id': 1, 'name': 'Yunohost Server', 'host': 'localhost', 'port': 5432, 'maintenance_db': 'postgres', - 'username': username, 'comment': '', 'password': crypted_password, 'role': '', 'discovery_id': '', - 'db_res': '', 'bgcolor': '', 'fgcolor': '', 'service': '', - 'use_ssh_tunnel': '', 'tunnel_host': '', 'tunnel_port': 22, 'tunnel_username': '', 'tunnel_authentication': '', 'tunnel_identity_file': '', 'tunnel_password': '', - 'save_password': 1, 'shared': '', 'kerberos_conn': 0, 'cloud_status': 0, 'passexec_cmd': '', 'passexec_expiration': '', - 'connection_params': '''{"sslmode": "prefer", "connect_timeout": 10, "sslcert": "/.postgresql/postgresql.crt", "sslkey": "/.postgresql/postgresql.key"}'''} - -# Insert new data in database -cursor = conn.cursor() -cursor.execute(''' - INSERT INTO `server` ( - `id`,`user_id`,`servergroup_id`,`name`,`host`,`port`,`maintenance_db`, - `username`,`comment`,`password`,`role`,`discovery_id`, - `db_res`,`bgcolor`,`fgcolor`,`service`, - `use_ssh_tunnel`,`tunnel_host`,`tunnel_port`,`tunnel_username`,`tunnel_authentication`,`tunnel_identity_file`,`tunnel_password`, - `save_password`,`shared`,`kerberos_conn`,`cloud_status`,`passexec_cmd`,`passexec_expiration`, - `connection_params` - ) VALUES ( - :id,:user_id,:servergroup_id,:name,:host,:port,:maintenance_db, - :username,:comment,:password,:role,:discovery_id, - :db_res,:bgcolor,:fgcolor,:service, - :use_ssh_tunnel,:tunnel_host,:tunnel_port,:tunnel_username,:tunnel_authentication,:tunnel_identity_file,:tunnel_password, - :save_password,:shared,:kerberos_conn,:cloud_status,:passexec_cmd,:passexec_expiration, - :connection_params - );''', data) -conn.commit() - -# Close connection -conn.close() From e995134e2107f3e619c086c760737215e1764994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 14:54:27 +0100 Subject: [PATCH 55/59] coding style python --- conf/config_local.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conf/config_local.py b/conf/config_local.py index 1ddd489..1397b47 100644 --- a/conf/config_local.py +++ b/conf/config_local.py @@ -1 +1,3 @@ +#!/usr/bin/env python3 + DESKTOP_USER = '__APP__@__DOMAIN__' From 68289e87fa76c6fbbc43b0808b8c32e6010dde29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 14:55:32 +0100 Subject: [PATCH 56/59] better upgrade doc --- doc/POST_UPGRADE.d/7.7~ynh2.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/POST_UPGRADE.d/7.7~ynh2.md b/doc/POST_UPGRADE.d/7.7~ynh2.md index bc743de..0b49770 100644 --- a/doc/POST_UPGRADE.d/7.7~ynh2.md +++ b/doc/POST_UPGRADE.d/7.7~ynh2.md @@ -1,5 +1,5 @@ -This upgrade fixes authentication with PostgreSQL. +This upgrade fixes authentication with PostgreSQL. -Here is the Postgresql admin password: `__DB_PWD__`. +You might need to re-enter in pgAdmin the Postgresql admin password: `__DB_PWD__`. You can log into pgAdmin with your email and the password you provided during installation. From dbb8b4dacbbe310a647f25ffc1e8cf0fed1441e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 15:31:53 +0100 Subject: [PATCH 57/59] fix install missing dir --- scripts/install | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/install b/scripts/install index 45d433a..486626b 100644 --- a/scripts/install +++ b/scripts/install @@ -38,6 +38,9 @@ mkdir -p /var/lib/pgadmin chmod -R 750 /var/lib/pgadmin chown -R "$app:root" /var/lib/pgadmin +mkdir -p /var/log/pgadmin +chown -R "$app:root" /var/log/pgadmin + #================================================= # ADD A CONFIGURATION #================================================= From 6ee06b09d803b4b19a08626c93e666af825166b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 15:56:14 +0100 Subject: [PATCH 58/59] do one request to unblock user? --- scripts/install | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 486626b..9d62b4e 100644 --- a/scripts/install +++ b/scripts/install @@ -22,7 +22,7 @@ email=$(ynh_user_get_info --username $admin --key 'mail') #================================================= ynh_script_progression --message="Configuring Postgresql superuser..." -ynh_psql_execute_as_root --sql "ALTER USER $app WITH SUPERUSER CREATEDB CREATEROLE REPLICATION" +ynh_psql_execute_as_root --sql "ALTER USER $db_user WITH SUPERUSER CREATEDB CREATEROLE REPLICATION" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -56,6 +56,9 @@ ynh_exec_as "$app" "$install_dir/setup.exp" "$install_dir/venv/bin/python3" "$in ynh_add_config --template="server.json" --destination="$install_dir/server.json" ynh_exec_as "$app" "$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" --user "$email" --load-servers "$install_dir/server.json" +# looks like we need to run one command as pgadmin to get access to the dbs ? +ynh_psql_connect_as --user="$db_user" --password="$db_pwd" <<< '\list;' >/dev/null + #================================================= # SYSTEM CONFIGURATION #================================================= From f0965a67c32d57400469958ecba39d4b419636cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 16:22:29 +0100 Subject: [PATCH 59/59] Bump to v7.8. automatically use upstream version in scripts. --- manifest.toml | 2 +- scripts/_common.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/manifest.toml b/manifest.toml index 595915d..2fa2b32 100644 --- a/manifest.toml +++ b/manifest.toml @@ -7,7 +7,7 @@ name = "pgAdmin4" description.en = "Manage PostgreSQL databases over the web" description.fr = "Application web de gestion des bases de données PostgreSQL" -version = "7.7~ynh2" +version = "7.8~ynh1" maintainers = ["Josué Tille"] diff --git a/scripts/_common.sh b/scripts/_common.sh index 391b2d4..5ac19ff 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -25,5 +25,6 @@ ynh_use_venv() { } _install_pgadmin_pip() { - ynh_exec_as "$app" "$venvpy" -m pip install --upgrade "pgadmin4==7.7" + version=$(ynh_app_upstream_version) + ynh_exec_as "$app" "$venvpy" -m pip install --upgrade "pgadmin4==$version" }