mirror of
https://github.com/YunoHost-Apps/pgadmin_ynh.git
synced 2024-09-03 19:56:38 +02:00
108 lines
3.9 KiB
Bash
108 lines
3.9 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source experimental_helper.sh
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
# STOP SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
|
|
|
if [ -f "/etc/uwsgi/apps-available/$app.ini" ]; then
|
|
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action stop
|
|
systemctl disable "uwsgi-app@$app.service" --quiet
|
|
yunohost service remove "uwsgi-app@$app" || true
|
|
|
|
ynh_secure_remove --file="/etc/uwsgi/apps-available/$app.ini"
|
|
ynh_secure_remove --file="/etc/systemd/system/uwsgi-app@$app.service.d"
|
|
else
|
|
ynh_systemd_action --service_name "$app.service" --action stop
|
|
fi
|
|
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=2
|
|
|
|
# Clean old uwsgi config
|
|
ynh_secure_remove /etc/uwsgi/apps-enabled/pgadmin.ini
|
|
|
|
# Migrate data path
|
|
if [ -d "/var/lib/pgadmin" ]; then
|
|
if [ ! -d "$install_dir/data" ]; then
|
|
mv -t "$data_dir" /var/lib/pgadmin/*
|
|
fi
|
|
ynh_secure_remove "/var/lib/pgadmin"
|
|
fi
|
|
if [ -d "$install_dir/data" ]; then
|
|
if [ ! -d "$install_dir/data" ]; then
|
|
mv -t "$data_dir" "$install_dir"/data/*
|
|
fi
|
|
ynh_secure_remove "$install_dir/data"
|
|
fi
|
|
if [ ! -e $data_dir/master_pwd ]; then
|
|
ynh_string_random --length=60 > $data_dir/master_pwd
|
|
fi
|
|
|
|
#=================================================
|
|
# Postgresql superuser
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring Postgresql superuser..." --weight=1
|
|
|
|
# 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"
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading source files..." --weight=6
|
|
install_source
|
|
|
|
#=================================================
|
|
# UPDATE A CONFIG FILE
|
|
#=================================================
|
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
|
|
|
# CONFIGURE PGADMIN
|
|
ynh_add_config --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
|
|
|
|
#=================================================
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
# Add systemd config
|
|
ynh_add_systemd_config --service=$app --template=pgadmin.service
|
|
|
|
yunohost service add $app --log "/var/log/$app/$app.log" --description 'PgAdmin application'
|
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
|
ynh_use_logrotate --logfile /var/log/$app --nonappend
|
|
|
|
set_permission
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
|
|
|
ynh_systemd_action --service_name "$app.service" --action="restart" --line_match "Listening at: unix:/run/$app/app.socket" --log_path systemd
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|