2017-11-14 16:05:26 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-01-31 16:08:58 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
|
2017-11-14 16:05:26 +01:00
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
# Import common cmd
|
2018-01-31 16:08:58 +01:00
|
|
|
source ./experimental_helper.sh
|
2017-11-14 16:05:26 +01:00
|
|
|
source ./_common.sh
|
|
|
|
|
|
|
|
# LOAD SETTINGS
|
2019-06-06 22:39:49 +02:00
|
|
|
ynh_script_progression --message="Loading installation settings..."
|
|
|
|
domain=$(ynh_app_setting_get --app $app --key domain)
|
|
|
|
path_url=$(ynh_normalize_url_path $(ynh_app_setting_get --app $app --key path))
|
|
|
|
admin=$(ynh_app_setting_get --app $app --key admin)
|
2017-11-14 16:05:26 +01:00
|
|
|
|
|
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
2019-06-06 22:39:49 +02:00
|
|
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10
|
2017-11-14 16:05:26 +01:00
|
|
|
ynh_backup_before_upgrade # Backup the current version of the app
|
|
|
|
ynh_clean_setup () {
|
|
|
|
ynh_restore_upgradebackup # restore it if the upgrade fails
|
|
|
|
}
|
|
|
|
|
2019-06-06 22:39:49 +02:00
|
|
|
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action stop
|
|
|
|
|
2018-01-31 16:08:58 +01:00
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
|
2019-03-21 11:37:52 +01:00
|
|
|
# Install dependance
|
2019-06-06 22:39:49 +02:00
|
|
|
ynh_script_progression --message="Upgrading dependencies..."
|
|
|
|
ynh_install_app_dependencies $dependances
|
2019-03-21 11:37:52 +01:00
|
|
|
|
2017-11-14 16:05:26 +01:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2019-06-06 22:39:49 +02:00
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=6
|
2017-11-16 21:10:21 +01:00
|
|
|
install_source
|
2017-11-14 16:05:26 +01:00
|
|
|
|
2017-11-16 21:10:21 +01:00
|
|
|
# CONFIGURE PGADMIN
|
2019-06-06 22:39:49 +02:00
|
|
|
ynh_script_progression --message="Configuring application..."
|
2017-11-16 21:10:21 +01:00
|
|
|
config_pgadmin
|
2017-11-14 16:05:26 +01:00
|
|
|
|
2017-11-16 21:10:21 +01:00
|
|
|
# Config uwsgi
|
2019-06-06 22:39:49 +02:00
|
|
|
ynh_add_uwsgi_service 'pgadmin_user python_version'
|
|
|
|
|
|
|
|
# Create a dedicated nginx config
|
|
|
|
ynh_add_nginx_config
|
2017-11-14 16:05:26 +01:00
|
|
|
|
2018-01-31 16:08:58 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
|
2017-11-16 21:10:21 +01:00
|
|
|
# Set permission after initialisation
|
2019-06-06 22:39:49 +02:00
|
|
|
ynh_script_progression --message="Protecting directory"
|
2017-11-16 21:10:21 +01:00
|
|
|
set_permission
|
2017-11-14 16:05:26 +01:00
|
|
|
|
2019-06-06 22:39:49 +02:00
|
|
|
# Configuration de logrotate
|
|
|
|
ynh_script_progression --message="Configuring log rotation..."
|
|
|
|
ynh_use_logrotate /var/log/pgadmin --nonappend
|
2017-11-14 16:05:26 +01:00
|
|
|
|
2018-03-15 23:33:57 +01:00
|
|
|
# reload uwsgi
|
2019-06-06 22:39:49 +02:00
|
|
|
ynh_script_progression --message="Restarting pgadmin services..." --weight=3
|
|
|
|
ynh_systemd_action --service_name "uwsgi-app@$app.service" \
|
|
|
|
--line_match "WSGI app 0 (mountpoint='$path_url') ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/pgadmin.log"
|
|
|
|
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|