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
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
# STOP SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2024-01-31 19:46:18 +01:00
|
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
2017-11-14 16:05:26 +01:00
|
|
|
|
2024-01-30 17:03:58 +01:00
|
|
|
if [ -f "/etc/uwsgi/apps-available/$app.ini" ]; then
|
2019-08-19 23:41:09 +02:00
|
|
|
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action stop
|
2024-01-30 17:03:58 +01:00
|
|
|
fi
|
2019-06-06 22:39:49 +02:00
|
|
|
|
2022-03-13 15:22:35 +01:00
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
2024-01-31 19:46:18 +01:00
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=2
|
2022-03-13 15:22:35 +01:00
|
|
|
|
2024-01-30 17:20:58 +01:00
|
|
|
# Set the proper home directory
|
|
|
|
usermod -d "$install_dir" "$app"
|
2021-04-04 12:48:21 +02:00
|
|
|
|
2024-01-30 17:03:58 +01:00
|
|
|
# Clean old uwsgi config
|
|
|
|
ynh_secure_remove /etc/uwsgi/apps-enabled/pgadmin.ini
|
2022-03-13 15:22:35 +01:00
|
|
|
|
2024-01-31 16:41:58 +01:00
|
|
|
if [ -d "/var/lib/pgadmin" ]; then
|
|
|
|
if [ ! -d "$install_dir/data" ]; then
|
|
|
|
mv "/var/lib/pgadmin" "$install_dir/data"
|
|
|
|
fi
|
|
|
|
ynh_secure_remove "/var/lib/pgadmin"
|
|
|
|
fi
|
|
|
|
|
2024-01-31 14:44:14 +01:00
|
|
|
#=================================================
|
|
|
|
# Postgresql superuser
|
|
|
|
#=================================================
|
2024-01-31 19:46:18 +01:00
|
|
|
ynh_script_progression --message="Configuring Postgresql superuser..." --weight=1
|
2024-01-31 14:44:14 +01:00
|
|
|
|
|
|
|
# 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"
|
|
|
|
|
2022-03-13 15:22:35 +01:00
|
|
|
#=================================================
|
2024-01-30 18:01:12 +01:00
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
2022-03-13 15:22:35 +01:00
|
|
|
#=================================================
|
2019-06-06 22:39:49 +02:00
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=6
|
2024-01-30 18:01:12 +01:00
|
|
|
ynh_install_venv
|
|
|
|
|
|
|
|
_install_pgadmin_pip
|
|
|
|
|
2024-01-31 14:52:39 +01:00
|
|
|
chown -R "$app:root" "$install_dir"
|
|
|
|
|
2024-01-30 18:01:12 +01:00
|
|
|
#=================================================
|
|
|
|
# UPDATE A CONFIG FILE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
2017-11-14 16:05:26 +01:00
|
|
|
|
2024-01-30 18:01:12 +01:00
|
|
|
# CONFIGURE PGADMIN
|
|
|
|
ynh_add_config --template="config_local.py" --destination="$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/config_local.py"
|
2024-01-31 14:52:39 +01:00
|
|
|
chown -R "$app:root" "$install_dir"
|
2017-11-14 16:05:26 +01:00
|
|
|
|
2024-01-30 18:01:12 +01:00
|
|
|
#=================================================
|
2024-01-30 17:03:58 +01:00
|
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
2022-03-13 15:22:35 +01:00
|
|
|
#=================================================
|
2024-01-30 17:03:58 +01:00
|
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
# Config uwsgi
|
2024-01-30 18:01:57 +01:00
|
|
|
ynh_add_uwsgi_service "python_version"
|
2022-03-13 15:22:35 +01:00
|
|
|
|
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
2019-10-01 21:31:45 +02:00
|
|
|
ynh_use_logrotate --logfile /var/log/pgadmin --nonappend
|
2024-01-31 14:52:39 +01:00
|
|
|
chown -R "$app:root" /var/log/pgadmin
|
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"
|
2019-06-06 22:39:49 +02:00
|
|
|
|
2022-03-13 15:22:35 +01:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2019-06-06 22:39:49 +02:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|