1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pgadmin_ynh.git synced 2024-09-03 19:56:38 +02:00
pgadmin_ynh/scripts/upgrade
2021-04-04 12:48:21 +02:00

83 lines
2.8 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# IMPORT GENERIC HELPERS
source /usr/share/yunohost/helpers
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# LOAD SETTINGS
ynh_script_progression --message="Loading installation settings..."
domain=$(ynh_app_setting_get --app $app --key domain)
path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path))
admin=$(ynh_app_setting_get --app $app --key admin)
app_version=$(ynh_app_upstream_version)
app_main_version=$(echo $app_version | cut -d'-' -f1)
app_sub_version=$(echo $app_version | cut -d'-' -f2)
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10
ynh_backup_before_upgrade # Backup the current version of the app
ynh_clean_setup () {
ynh_restore_upgradebackup # restore it if the upgrade fails
}
test -e /etc/uwsgi/apps-available/$app.ini && \
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action stop
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
fi
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# Install dependance
ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $dependances
# Download, check integrity, uncompress and patch the source from app.src
ynh_script_progression --message="Upgrading source files..." --weight=6
install_source
# CONFIGURE PGADMIN
ynh_script_progression --message="Configuring application..."
config_pgadmin
# Config uwsgi
ynh_add_uwsgi_service 'pgadmin_user python_version'
# Create a dedicated nginx config
ynh_add_nginx_config
# Clean old uwsgi config
ynh_secure_remove /etc/uwsgi/apps-enabled/pgadmin.ini
#=================================================
# GENERIC FINALIZATION
#=================================================
# Set permission after initialisation
ynh_script_progression --message="Protecting directory..."
set_permission
# Configuration de logrotate
ynh_script_progression --message="Configuring log rotation..."
ynh_use_logrotate --logfile /var/log/pgadmin --nonappend
# reload uwsgi
ynh_script_progression --message="Restarting $app services..." --weight=3
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"
sleep 10
ynh_script_progression --message="Upgrade of $app completed" --last