mirror of
https://github.com/YunoHost-Apps/pgadmin_ynh.git
synced 2024-09-03 19:56:38 +02:00
Merge 21253c0bca
into b1cd2eff16
This commit is contained in:
commit
133a998ec7
11 changed files with 90 additions and 134 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -8,3 +8,6 @@
|
||||||
auto_update_config.sh
|
auto_update_config.sh
|
||||||
auto_update/Synapse_build_*.log
|
auto_update/Synapse_build_*.log
|
||||||
auto_update/synapse_build_temp.log
|
auto_update/synapse_build_temp.log
|
||||||
|
*~
|
||||||
|
*.sw[op]
|
||||||
|
.DS_Store
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# WARNING: Don't edit this file. All change will be removed after each app upgrade
|
||||||
|
|
||||||
import builtins
|
import builtins
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -18,7 +18,8 @@ admindoc = "https://www.pgadmin.org/docs"
|
||||||
cpe = "cpe:2.3:a:pgadmin:pgadmin"
|
cpe = "cpe:2.3:a:pgadmin:pgadmin"
|
||||||
|
|
||||||
[integration]
|
[integration]
|
||||||
yunohost = ">= 11.2"
|
yunohost = ">= 11.2.30"
|
||||||
|
helpers_version = "2.1"
|
||||||
architectures = "all"
|
architectures = "all"
|
||||||
multi_instance = true
|
multi_instance = true
|
||||||
ldap = true
|
ldap = true
|
||||||
|
@ -52,10 +53,8 @@ ram.runtime = "200M"
|
||||||
|
|
||||||
[resources.system_user]
|
[resources.system_user]
|
||||||
allow_email = true
|
allow_email = true
|
||||||
home = "/opt/yunohost/__APP__"
|
|
||||||
|
|
||||||
[resources.install_dir]
|
[resources.install_dir]
|
||||||
dir = "/opt/yunohost/__APP__"
|
|
||||||
|
|
||||||
[resources.data_dir]
|
[resources.data_dir]
|
||||||
|
|
||||||
|
|
|
@ -13,21 +13,21 @@ postgresql_version="$(psql -V | cut -d' ' -f3 | cut -d. -f1)"
|
||||||
|
|
||||||
install_source() {
|
install_source() {
|
||||||
# Cleanup old venv files
|
# Cleanup old venv files
|
||||||
ynh_secure_remove --file="$install_dir"/bin
|
ynh_safe_rm "$install_dir"/bin
|
||||||
ynh_secure_remove --file="$install_dir"/lib
|
ynh_safe_rm "$install_dir"/lib
|
||||||
ynh_secure_remove --file="$install_dir"/lib64
|
ynh_safe_rm "$install_dir"/lib64
|
||||||
ynh_secure_remove --file="$install_dir"/include
|
ynh_safe_rm "$install_dir"/include
|
||||||
ynh_secure_remove --file="$install_dir"/share
|
ynh_safe_rm "$install_dir"/share
|
||||||
ynh_secure_remove --file="$install_dir"/pyvenv.cfg
|
ynh_safe_rm "$install_dir"/pyvenv.cfg
|
||||||
|
|
||||||
# Clean venv is it was on python with an old version in case major upgrade of debian
|
# Clean venv is it was on python with an old version in case major upgrade of debian
|
||||||
if [ ! -e "$install_dir/venv/lib/python$python_version" ] || ! grep -qF "$install_dir/venv/bin/python" "$install_dir"/venv/bin/pip; then
|
if [ ! -e "$install_dir/venv/lib/python$python_version" ] || ! grep -qF "$install_dir/venv/bin/python" "$install_dir"/venv/bin/pip; then
|
||||||
ynh_secure_remove --file="$install_dir"/venv/bin
|
ynh_safe_rm "$install_dir"/venv/bin
|
||||||
ynh_secure_remove --file="$install_dir"/venv/lib
|
ynh_safe_rm "$install_dir"/venv/lib
|
||||||
ynh_secure_remove --file="$install_dir"/venv/lib64
|
ynh_safe_rm "$install_dir"/venv/lib64
|
||||||
ynh_secure_remove --file="$install_dir"/venv/include
|
ynh_safe_rm "$install_dir"/venv/include
|
||||||
ynh_secure_remove --file="$install_dir"/venv/share
|
ynh_safe_rm "$install_dir"/venv/share
|
||||||
ynh_secure_remove --file="$install_dir"/venv/pyvenv.cfg
|
ynh_safe_rm "$install_dir"/venv/pyvenv.cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if uname -m | grep -q arm
|
if uname -m | grep -q arm
|
||||||
|
@ -37,7 +37,7 @@ install_source() {
|
||||||
# Fix multi-instance support
|
# Fix multi-instance support
|
||||||
for f in "$install_dir"/venv/bin/*; do
|
for f in "$install_dir"/venv/bin/*; do
|
||||||
if ! [[ $f =~ "__" ]]; then
|
if ! [[ $f =~ "__" ]]; then
|
||||||
ynh_replace_special_string --match_string='#!'/opt/yunohost/pgadmin/venv --replace_string='#!'"$install_dir"/venv --target_file="$f"
|
ynh_replace_regex --match='#!'/opt/yunohost/pgadmin/venv --replace='#!'"$install_dir"/venv --file="$f"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
|
@ -72,9 +72,9 @@ install_source() {
|
||||||
set_permission() {
|
set_permission() {
|
||||||
# Set permission
|
# Set permission
|
||||||
chown "$app:$app" -R "$install_dir"
|
chown "$app:$app" -R "$install_dir"
|
||||||
chmod u+rw,o= -R "$install_dir"
|
chmod u+rwX,g+rX-w,o= -R "$install_dir"
|
||||||
chown "$app:$app" -R "$data_dir"
|
chown "$app:$app" -R "$data_dir"
|
||||||
chmod u+rw,o= -R "$data_dir"
|
chmod u+rwX,g+rX-w,o= -R "$data_dir"
|
||||||
chown "$app:$app" -R /var/log/"$app"
|
chown "$app:$app" -R /var/log/"$app"
|
||||||
chmod u=rwX,g=rX,o= -R /var/log/"$app"
|
chmod u=rwX,g=rX,o= -R /var/log/"$app"
|
||||||
# Criticals files
|
# Criticals files
|
||||||
|
@ -83,4 +83,3 @@ set_permission() {
|
||||||
chown "$app":root "$install_dir"/postgres-reg.ini
|
chown "$app":root "$install_dir"/postgres-reg.ini
|
||||||
chmod u=r,g=,o= "$install_dir"/postgres-reg.ini
|
chmod u=r,g=,o= "$install_dir"/postgres-reg.ini
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,48 +1,39 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/experimental_helper.sh
|
source ../settings/scripts/experimental_helper.sh
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
ynh_print_info "Declaring files to be backed up..."
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
|
||||||
#=================================================
|
|
||||||
ynh_print_info --message="Declaring files to be backed up..."
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$install_dir"
|
ynh_backup "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP DATA
|
# BACKUP DATA
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$data_dir" --is_big=1
|
ynh_backup "$data_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SYSTEM CONFIGURATION
|
# SYSTEM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
ynh_backup --src_path=/etc/systemd/system/$app.service
|
ynh_backup /etc/systemd/system/$app.service
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP VARIOUS FILES
|
# BACKUP VARIOUS FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="/var/log/$app"
|
ynh_backup "/var/log/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||||
|
|
|
@ -1,31 +1,23 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC STARTING
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Import common cmd
|
# Import common cmd
|
||||||
source experimental_helper.sh
|
source experimental_helper.sh
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD MODIFICATIONS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# STOP SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
ynh_script_progression "Stopping $app's systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app.service" --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemctl --service="$app.service" --action="stop"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
ynh_script_progression "Updating NGINX web server configuration..."
|
||||||
|
|
||||||
ynh_change_url_nginx_config
|
ynh_config_change_url_nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC MODIFICATIONS
|
# SPECIFIC MODIFICATIONS
|
||||||
|
@ -33,18 +25,16 @@ ynh_change_url_nginx_config
|
||||||
|
|
||||||
set_permission
|
set_permission
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALISATION
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
ynh_script_progression "Starting $app's systemd service..."
|
||||||
|
|
||||||
# Start a systemd service
|
# Start a systemd service
|
||||||
ynh_systemd_action --service_name="$app.service" --action="restart" --line_match="Listening at: unix:/run/$app/app.socket" --log_path=systemd
|
ynh_systemctl --service="$app.service" --action="restart" --wait_until="Listening at: unix:/run/$app/app.socket" --log_path=systemd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
ynh_script_progression "Change of URL completed for $app"
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source experimental_helper.sh
|
source experimental_helper.sh
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
@ -13,12 +7,11 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# Postgresql superuser
|
# Postgresql superuser
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring Postgresql superuser..." --weight=1
|
ynh_script_progression "Configuring Postgresql superuser..."
|
||||||
|
|
||||||
ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH SUPERUSER CREATEDB CREATEROLE REPLICATION"
|
ynh_psql_db_shell <<< "ALTER USER $db_user WITH SUPERUSER CREATEDB CREATEROLE REPLICATION"
|
||||||
|
|
||||||
|
ynh_script_progression 'Creating base directory...'
|
||||||
ynh_script_progression --message='Creating base directory...'
|
|
||||||
|
|
||||||
if [ -n "$(ls -A "$data_dir")" ]; then
|
if [ -n "$(ls -A "$data_dir")" ]; then
|
||||||
old_data_dir_path="${data_dir}_$(date '+%Y%m%d.%H%M%S')"
|
old_data_dir_path="${data_dir}_$(date '+%Y%m%d.%H%M%S')"
|
||||||
|
@ -32,17 +25,17 @@ mkdir -p /var/log/"$app"
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Setting up source files..." --weight=5
|
ynh_script_progression "Setting up source files..."
|
||||||
|
|
||||||
install_source
|
install_source
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD A CONFIGURATION
|
# ADD A CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring pgAdmin..." --weight=1
|
ynh_script_progression "Configuring pgAdmin..."
|
||||||
|
|
||||||
ynh_add_config --template="config_local.py" --destination="$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/config_local.py"
|
ynh_config_add --template="config_local.py" --destination="$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/config_local.py"
|
||||||
ynh_add_config --template=postgres-reg.ini --destination="$install_dir"/postgres-reg.ini
|
ynh_config_add --template=postgres-reg.ini --destination="$install_dir"/postgres-reg.ini
|
||||||
ynh_string_random --length=60 > "$data_dir"/master_pwd
|
ynh_string_random --length=60 > "$data_dir"/master_pwd
|
||||||
set_permission
|
set_permission
|
||||||
|
|
||||||
|
@ -51,28 +44,28 @@ $install_dir/venv/bin/python3 "$install_dir/venv/lib/python$python_version/site-
|
||||||
#=================================================
|
#=================================================
|
||||||
# SYSTEM CONFIGURATION
|
# SYSTEM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
ynh_script_progression "Adding system configurations related to $app..."
|
||||||
|
|
||||||
# Create a dedicated NGINX config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
ynh_config_add_nginx
|
||||||
|
|
||||||
# Add systemd config
|
# Add systemd config
|
||||||
ynh_add_systemd_config --service=$app --template=pgadmin.service
|
ynh_config_add_systemd --template=pgadmin.service
|
||||||
|
|
||||||
yunohost service add $app --log "/var/log/$app/$app.log" --description 'PgAdmin application'
|
yunohost service add $app --log "/var/log/$app/$app.log" --description 'PgAdmin application'
|
||||||
|
|
||||||
ynh_use_logrotate --logfile="/var/log/$app"
|
ynh_config_add_logrotate "/var/log/$app"
|
||||||
set_permission
|
set_permission
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
ynh_script_progression "Starting $app's systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app.service" --action="restart" --line_match="Listening at: unix:/run/$app/app.socket" --log_path=systemd
|
ynh_systemctl --service="$app.service" --action="restart" --wait_until="Listening at: unix:/run/$app/app.socket" --log_path=systemd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Installation of $app completed" --last
|
ynh_script_progression "Installation of $app completed"
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source experimental_helper.sh
|
source experimental_helper.sh
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
@ -13,21 +7,22 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE SYSTEM CONFIGURATIONS
|
# REMOVE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
ynh_script_progression "Removing system configurations related to $app..."
|
||||||
|
|
||||||
# Stop service
|
# Stop service
|
||||||
ynh_systemd_action --service_name="$app.service" --action=stop
|
ynh_systemctl --service="$app.service" --action=stop
|
||||||
ynh_remove_systemd_config --service="$app"
|
ynh_config_remove_systemd
|
||||||
|
|
||||||
yunohost service remove "$app"
|
yunohost service remove "$app"
|
||||||
|
|
||||||
# Remove the app-specific logrotate config
|
# Remove the app-specific logrotate config
|
||||||
ynh_remove_logrotate
|
ynh_config_remove_logrotate
|
||||||
|
|
||||||
# Remove the dedicated NGINX config
|
# Remove the dedicated NGINX config
|
||||||
ynh_remove_nginx_config
|
ynh_config_remove_nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Removal of $app completed" --last
|
ynh_script_progression "Removal of $app completed"
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/experimental_helper.sh
|
source ../settings/scripts/experimental_helper.sh
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
|
@ -14,28 +8,27 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE POSTGRESQL SUPERUSER
|
# RESTORE THE POSTGRESQL SUPERUSER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the Postgresql superuser..." --weight=1
|
ynh_script_progression "Restoring the Postgresql superuser..."
|
||||||
|
|
||||||
ynh_psql_execute_as_root --sql="ALTER USER $app WITH SUPERUSER CREATEDB CREATEROLE REPLICATION"
|
ynh_psql_db_shell <<< "ALTER USER $app WITH SUPERUSER CREATEDB CREATEROLE REPLICATION"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE ALL CONFIG AND DATA
|
# RESTORE ALL CONFIG AND DATA
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Restoring directory and configuration..." --weight=10
|
ynh_script_progression "Restoring directory and configuration..."
|
||||||
ynh_restore
|
ynh_restore_everything
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
# REINSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating python virtualenv..." --weight=5
|
ynh_script_progression "Updating python virtualenv..."
|
||||||
|
|
||||||
install_source
|
install_source
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEMD
|
# RESTORE SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Enable systemd services" --weight=2
|
ynh_script_progression "Enable systemd services"
|
||||||
|
|
||||||
# systemctl daemon-reload
|
# systemctl daemon-reload
|
||||||
systemctl enable "$app".service --quiet
|
systemctl enable "$app".service --quiet
|
||||||
|
@ -43,19 +36,17 @@ yunohost service add "$app" --log "/var/log/$app/$app.log" --description 'PgAdmi
|
||||||
|
|
||||||
set_permission
|
set_permission
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX AND THE APP SERVICE
|
# RELOAD NGINX AND THE APP SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
ynh_script_progression "Reloading NGINX web server and $app's service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app.service" --action="restart" --line_match="Listening at: unix:/run/$app/app.socket" --log_path=systemd
|
ynh_systemctl --service="$app.service" --action="restart" --wait_until="Listening at: unix:/run/$app/app.socket" --log_path=systemd
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemctl --service=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Restoration completed for $app" --last
|
ynh_script_progression "Restoration completed for $app"
|
||||||
|
|
|
@ -1,53 +1,45 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source experimental_helper.sh
|
source experimental_helper.sh
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD UPGRADE STEPS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# STOP SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
ynh_script_progression "Stopping $app's systemd service..."
|
||||||
|
|
||||||
if [ -f "/etc/uwsgi/apps-available/$app.ini" ]; then
|
if [ -f "/etc/uwsgi/apps-available/$app.ini" ]; then
|
||||||
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action=stop
|
ynh_systemctl --service="uwsgi-app@$app.service" --action=stop
|
||||||
systemctl disable "uwsgi-app@$app.service" --quiet
|
systemctl disable "uwsgi-app@$app.service" --quiet
|
||||||
yunohost service remove "uwsgi-app@$app" || true
|
yunohost service remove "uwsgi-app@$app" || true
|
||||||
|
|
||||||
ynh_secure_remove --file="/etc/uwsgi/apps-available/$app.ini"
|
ynh_safe_rm "/etc/uwsgi/apps-available/$app.ini"
|
||||||
ynh_secure_remove --file="/etc/systemd/system/uwsgi-app@$app.service.d"
|
ynh_safe_rm "/etc/systemd/system/uwsgi-app@$app.service.d"
|
||||||
else
|
else
|
||||||
ynh_systemd_action --service_name="$app.service" --action=stop
|
ynh_systemctl --service="$app.service" --action=stop
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=2
|
ynh_script_progression "Ensuring downward compatibility..."
|
||||||
|
|
||||||
# Clean old uwsgi config
|
# Clean old uwsgi config
|
||||||
ynh_secure_remove /etc/uwsgi/apps-enabled/pgadmin.ini
|
ynh_safe_rm /etc/uwsgi/apps-enabled/pgadmin.ini
|
||||||
|
|
||||||
# Migrate data path
|
# Migrate data path
|
||||||
if [ -d "/var/lib/pgadmin" ]; then
|
if [ -d "/var/lib/pgadmin" ]; then
|
||||||
if [ ! -d "$install_dir/data" ]; then
|
if [ ! -d "$install_dir/data" ]; then
|
||||||
mv -t "$data_dir" /var/lib/pgadmin/*
|
mv -t "$data_dir" /var/lib/pgadmin/*
|
||||||
fi
|
fi
|
||||||
ynh_secure_remove "/var/lib/pgadmin"
|
ynh_safe_rm "/var/lib/pgadmin"
|
||||||
fi
|
fi
|
||||||
if [ -d "$install_dir/data" ]; then
|
if [ -d "$install_dir/data" ]; then
|
||||||
if [ ! -d "$install_dir/data" ]; then
|
if [ ! -d "$install_dir/data" ]; then
|
||||||
mv -t "$data_dir" "$install_dir"/data/*
|
mv -t "$data_dir" "$install_dir"/data/*
|
||||||
fi
|
fi
|
||||||
ynh_secure_remove "$install_dir/data"
|
ynh_safe_rm "$install_dir/data"
|
||||||
fi
|
fi
|
||||||
if [ ! -e "$data_dir"/master_pwd ]; then
|
if [ ! -e "$data_dir"/master_pwd ]; then
|
||||||
ynh_string_random --length=60 > "$data_dir"/master_pwd
|
ynh_string_random --length=60 > "$data_dir"/master_pwd
|
||||||
|
@ -56,53 +48,53 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# Postgresql superuser
|
# Postgresql superuser
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring Postgresql superuser..." --weight=1
|
ynh_script_progression "Configuring Postgresql superuser..."
|
||||||
|
|
||||||
# Re-set the db_pwd just in case…
|
# 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"
|
ynh_psql_db_shell <<< "ALTER USER $app WITH PASSWORD '$db_pwd' SUPERUSER CREATEDB CREATEROLE REPLICATION"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading source files..." --weight=6
|
ynh_script_progression "Upgrading source files..."
|
||||||
install_source
|
install_source
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPDATE A CONFIG FILE
|
# UPDATE A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
ynh_script_progression "Updating configuration..."
|
||||||
|
|
||||||
# CONFIGURE PGADMIN
|
# CONFIGURE PGADMIN
|
||||||
ynh_add_config --template="config_local.py" --destination="$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/config_local.py"
|
ynh_config_add --template="config_local.py" --destination="$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/config_local.py"
|
||||||
ynh_add_config --template=postgres-reg.ini --destination="$install_dir"/postgres-reg.ini
|
ynh_config_add --template=postgres-reg.ini --destination="$install_dir"/postgres-reg.ini
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REAPPLY SYSTEM CONFIGURATIONS
|
# REAPPLY SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
ynh_script_progression "Upgrading system configurations related to $app..."
|
||||||
|
|
||||||
# Create a dedicated NGINX config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
ynh_config_add_nginx
|
||||||
|
|
||||||
# Add systemd config
|
# Add systemd config
|
||||||
ynh_add_systemd_config --service="$app" --template=pgadmin.service
|
ynh_config_add_systemd --template=pgadmin.service
|
||||||
|
|
||||||
yunohost service add "$app" --log "/var/log/$app/$app.log" --description 'PgAdmin application'
|
yunohost service add "$app" --log "/var/log/$app/$app.log" --description 'PgAdmin application'
|
||||||
|
|
||||||
# Use logrotate to manage app-specific logfile(s)
|
# Use logrotate to manage app-specific logfile(s)
|
||||||
ynh_use_logrotate --logfile=/var/log/"$app" --nonappend
|
ynh_config_add_logrotate /var/log/"$app"
|
||||||
|
|
||||||
set_permission
|
set_permission
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
ynh_script_progression "Starting $app's systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app.service" --action="restart" --line_match="Listening at: unix:/run/$app/app.socket" --log_path=systemd
|
ynh_systemctl --service="$app.service" --action="restart" --wait_until="Listening at: unix:/run/$app/app.socket" --log_path=systemd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
ynh_script_progression "Upgrade of $app completed"
|
||||||
|
|
|
@ -19,3 +19,4 @@ test_format = 1.0
|
||||||
test_upgrade_from.067601ed5bb19dde70f74a1fa1f6230a30efe6b5.name = "7.2~ynh1"
|
test_upgrade_from.067601ed5bb19dde70f74a1fa1f6230a30efe6b5.name = "7.2~ynh1"
|
||||||
test_upgrade_from.da90e7957a1a365f3c840df02c41cd14592030db.name = "Last packaging v1 version"
|
test_upgrade_from.da90e7957a1a365f3c840df02c41cd14592030db.name = "Last packaging v1 version"
|
||||||
test_upgrade_from.55a5fd67889da37d03a5d4614168db76a8817cdb.name = "Pre improvements"
|
test_upgrade_from.55a5fd67889da37d03a5d4614168db76a8817cdb.name = "Pre improvements"
|
||||||
|
test_upgrade_from.b1cd2eff160238a6059c9806b7301edc9edd8572.name = "Before helper 2.1"
|
||||||
|
|
Loading…
Add table
Reference in a new issue