1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/duniter_ynh.git synced 2024-09-03 18:26:35 +02:00
duniter_ynh/scripts/upgrade

141 lines
4.7 KiB
Text
Raw Normal View History

2015-05-24 23:01:16 +02:00
#!/bin/bash
2021-11-25 19:38:26 +01:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2021-11-25 19:38:26 +01:00
source _common.sh
source /usr/share/yunohost/helpers
2021-11-25 19:38:26 +01:00
#=================================================
# LOAD SETTINGS
#=================================================
2022-03-12 16:55:59 +01:00
ynh_script_progression --message="Loading installation settings..."
2021-11-25 19:38:26 +01:00
app=$YNH_APP_INSTANCE_NAME
2015-05-24 23:01:16 +02:00
2021-11-25 19:38:26 +01:00
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)
2022-03-12 16:55:59 +01:00
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
2022-03-13 22:46:09 +01:00
port=$(ynh_app_setting_get --app=$app --key=port)
2022-04-05 18:36:10 +02:00
architecture=$YNH_ARCH
2021-11-25 19:38:26 +01:00
#=================================================
# CHECK VERSION
#=================================================
2022-03-12 16:55:59 +01:00
ynh_script_progression --message="Checking version..."
2021-11-25 19:38:26 +01:00
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
2022-03-12 16:55:59 +01:00
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
2021-11-25 19:38:26 +01:00
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
2022-03-12 16:55:59 +01:00
ynh_clean_check_starting
2021-11-25 19:38:26 +01:00
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
2022-03-12 16:55:59 +01:00
#=================================================
2021-11-25 19:38:26 +01:00
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
2022-03-12 16:55:59 +01:00
ynh_script_progression --message="Stopping a systemd service..."
2021-11-25 19:38:26 +01:00
2022-03-12 16:55:59 +01:00
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
2021-11-25 19:38:26 +01:00
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
2022-03-12 16:55:59 +01:00
ynh_script_progression --message="Ensuring downward compatibility..."
2021-11-25 19:38:26 +01:00
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# CREATE DEDICATED USER
2021-11-25 19:38:26 +01:00
#=================================================
2022-03-12 16:55:59 +01:00
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
2022-03-12 16:55:59 +01:00
ynh_system_user_create --username=$app
2021-11-25 19:38:26 +01:00
2022-03-12 16:55:59 +01:00
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
2021-11-25 19:38:26 +01:00
#=================================================
# INSTALL DUNITER
#=================================================
2022-03-12 16:55:59 +01:00
ynh_script_progression --message="Building Duniter.. (this will take some time and resources!)"
2021-11-25 19:38:26 +01:00
dpkg -r duniter
tempdir="$(mktemp -d)"
2022-04-05 18:36:10 +02:00
ynh_setup_source --dest_dir=$tempdir --source_id=$architecture
ynh_exec_warn_less dpkg -i $tempdir/duniter-server-v1.8.*-linux-*.deb
2021-11-25 19:38:26 +01:00
#=================================================
# UPDATE A CONFIG FILE
#=================================================
2022-03-12 16:55:59 +01:00
ynh_script_progression --message="Updating a configuration file..."
2021-11-25 19:38:26 +01:00
duniter config --bma --ipv4 127.0.0.1 --port $port --remoteh $domain --remotep 443 --noupnp
duniter config --ws2p-host 127.0.0.1 --ws2p-port 20901 --ws2p-remote-host $domain --ws2p-remote-port 443 --ws2p-remote-path "/ws2p" --ws2p-noupnp
2021-11-25 19:38:26 +01:00
#=================================================
# SETUP SYSTEMD
#=================================================
2022-03-12 16:55:59 +01:00
ynh_script_progression --message="Upgrading systemd configuration..."
2021-11-25 19:38:26 +01:00
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
2022-03-12 16:55:59 +01:00
ynh_script_progression --message="Integrating service in YunoHost..."
2021-11-25 19:38:26 +01:00
2022-03-12 16:55:59 +01:00
yunohost service add $app
2021-11-25 19:38:26 +01:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2022-03-12 16:55:59 +01:00
ynh_script_progression --message="Starting a systemd service..."
2022-03-12 16:55:59 +01:00
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd
2021-11-25 19:38:26 +01:00
#=================================================
# RELOAD NGINX
#=================================================
2022-03-12 16:55:59 +01:00
ynh_script_progression --message="Reloading NGINX web server..."
2021-11-25 19:38:26 +01:00
ynh_systemd_action --service_name=nginx --action=reload
2020-06-11 18:26:52 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2021-11-25 19:38:26 +01:00
2022-03-12 16:55:59 +01:00
ynh_script_progression --message="Upgrade of $app completed"