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
|
2022-03-13 15:22:35 +01:00
|
|
|
#=================================================
|
2017-11-14 16:05:26 +01:00
|
|
|
|
2022-03-13 15:22:35 +01:00
|
|
|
source experimental_helper.sh
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
2017-11-14 16:05:26 +01:00
|
|
|
|
2022-03-13 15:22:35 +01:00
|
|
|
#=================================================
|
2017-11-14 16:05:26 +01:00
|
|
|
# LOAD SETTINGS
|
2022-03-13 15:22:35 +01:00
|
|
|
#=================================================
|
2019-06-06 22:39:49 +02:00
|
|
|
ynh_script_progression --message="Loading installation settings..."
|
2022-03-13 15:22:35 +01:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2020-11-28 17:31:42 +01:00
|
|
|
app_version=$(ynh_app_upstream_version)
|
|
|
|
app_main_version=$(echo $app_version | cut -d'-' -f1)
|
|
|
|
app_sub_version=$(echo $app_version | cut -d'-' -f2)
|
2017-11-14 16:05:26 +01:00
|
|
|
|
2022-03-13 15:22:35 +01:00
|
|
|
pgadmin_user="$app"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK VERSION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Checking version..."
|
|
|
|
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
|
|
|
#=================================================
|
2017-11-14 16:05:26 +01:00
|
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
2022-03-13 15:22:35 +01:00
|
|
|
#=================================================
|
|
|
|
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
|
2017-11-14 16:05:26 +01:00
|
|
|
ynh_clean_setup () {
|
2022-03-13 15:22:35 +01:00
|
|
|
ynh_clean_check_starting
|
|
|
|
# Restore it if the upgrade fails
|
|
|
|
ynh_restore_upgradebackup
|
2017-11-14 16:05:26 +01:00
|
|
|
}
|
2022-03-13 15:22:35 +01:00
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
# STOP SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Stopping a systemd service..."
|
2017-11-14 16:05:26 +01:00
|
|
|
|
2019-08-19 23:41:09 +02:00
|
|
|
test -e /etc/uwsgi/apps-available/$app.ini && \
|
|
|
|
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action stop
|
2019-06-06 22:39:49 +02:00
|
|
|
|
2022-03-13 15:22:35 +01:00
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
|
|
|
|
2021-04-04 12:48:21 +02:00
|
|
|
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
|
|
|
|
|
2018-01-31 16:08:58 +01:00
|
|
|
#=================================================
|
2022-03-13 15:22:35 +01:00
|
|
|
# NGINX CONFIGURATION
|
2018-01-31 16:08:58 +01:00
|
|
|
#=================================================
|
2022-03-13 15:22:35 +01:00
|
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2018-01-31 16:08:58 +01:00
|
|
|
|
2022-03-13 15:22:35 +01:00
|
|
|
#=================================================
|
|
|
|
# UPGRADE DEPENDENCIES
|
|
|
|
#=================================================
|
2019-06-06 22:39:49 +02:00
|
|
|
ynh_script_progression --message="Upgrading dependencies..."
|
2019-03-21 11:37:52 +01:00
|
|
|
|
2022-03-13 15:22:35 +01:00
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC UPGRADE
|
|
|
|
#=================================================
|
|
|
|
# ...
|
|
|
|
#=================================================
|
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'
|
|
|
|
|
2019-06-13 22:59:59 +02:00
|
|
|
# Clean old uwsgi config
|
|
|
|
ynh_secure_remove /etc/uwsgi/apps-enabled/pgadmin.ini
|
|
|
|
|
2017-11-16 21:10:21 +01:00
|
|
|
# Set permission after initialisation
|
2019-06-11 22:27:54 +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
|
|
|
|
2022-03-13 15:22:35 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# SETUP LOGROTATE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrading logrotate configuration..."
|
|
|
|
|
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
2019-10-01 21:31:45 +02:00
|
|
|
ynh_use_logrotate --logfile /var/log/pgadmin --nonappend
|
2017-11-14 16:05:26 +01:00
|
|
|
|
2022-03-13 15:22:35 +01:00
|
|
|
#=================================================
|
|
|
|
# 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"
|
2020-07-30 22:55:35 +02:00
|
|
|
sleep 10
|
2019-06-06 22:39:49 +02:00
|
|
|
|
2022-03-13 15:22:35 +01:00
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Reloading NGINX web server..."
|
|
|
|
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2019-06-06 22:39:49 +02:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|