1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pgadmin_ynh.git synced 2024-09-03 19:56:38 +02:00

update packagingv2

This commit is contained in:
Salamandar 2024-01-30 11:36:14 +01:00
parent da90e7957a
commit 205b0028dc
11 changed files with 196 additions and 251 deletions

View file

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

View file

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

View file

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

68
manifest.toml Normal file
View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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"
#=================================================

View file

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