#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME port=$(ynh_app_setting_get --app=$app --key=port) username=$(ynh_app_setting_get --app=$app --key=username) password=$(ynh_app_setting_get --app=$app --key=password) #================================================= # STANDARD RESTORATION STEPS #================================================= # RESTORE FAIL2BAN CONFIGURATION #================================================= ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=1 #ynh_restore_file "/etc/fail2ban/jail.d/$app.conf" #ynh_restore_file "/etc/fail2ban/filter.d/$app.conf" #ynh_systemd_action --action=restart --service_name=fail2ban #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=20 ynh_install_extra_app_dependencies --repo="$extra_repo" --package="$pkg_dependencies" --key="$extra_repo_key" --name="$app" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --description="Allows MQTT clients to send/receive data" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port" #================================================= # RESTORE VARIOUS FILES #================================================= ynh_script_progression --message="Restoring the Mosquitto configuration..." --weight=1 # Restore the passwd file ynh_restore_file --origin_path="$password_file" # Restore the config file ynh_restore_file --origin_path="$config_file" #================================================= # RESTART SYSTEMD SERVICE #================================================= ynh_script_progression --message="Restarting systemd service..." --weight=1 ynh_systemd_action --service_name="$app" --action=restart #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= ynh_script_progression --message="Restoring the log rotation..." --weight=1 ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Restoration completed for $app" --last