2017-10-26 13:01:33 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2021-02-13 18:14:54 +01:00
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
|
|
|
source ../settings/scripts/_common.sh
|
2017-10-26 13:01:33 +02:00
|
|
|
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
|
|
|
|
#=================================================
|
2021-02-13 18:14:54 +01:00
|
|
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
2017-10-26 13:01:33 +02:00
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
2021-02-13 18:14:54 +01:00
|
|
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
|
|
|
username=$(ynh_app_setting_get --app=$app --key=username)
|
2023-04-22 09:24:09 +02:00
|
|
|
userpass=$(ynh_app_setting_get --app=$app --key=userpass)
|
2017-10-26 13:01:33 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC RESTORATION
|
|
|
|
#=================================================
|
|
|
|
# REINSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
2021-02-13 18:14:54 +01:00
|
|
|
ynh_script_progression --message="Reinstalling dependencies..." --weight=20
|
2017-10-26 13:01:33 +02:00
|
|
|
|
2023-04-10 18:24:41 +02:00
|
|
|
ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian bullseye main" --package="$extra_pkg_dependencies" --key="http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" --name="$app"
|
2017-10-26 13:01:33 +02:00
|
|
|
|
|
|
|
#=================================================
|
2021-02-13 18:14:54 +01:00
|
|
|
# RESTORE VARIOUS FILES
|
2017-10-26 13:01:33 +02:00
|
|
|
#=================================================
|
2022-06-20 01:41:47 +02:00
|
|
|
ynh_script_progression --message="Restoring various files..." --weight=1
|
2017-10-26 13:01:33 +02:00
|
|
|
|
2021-02-13 18:14:54 +01:00
|
|
|
# Restore the passwd file
|
2022-06-20 01:41:47 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/mosquitto/passwd"
|
2021-02-13 18:14:54 +01:00
|
|
|
|
|
|
|
# Restore the config file
|
2022-06-20 01:41:47 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/mosquitto/conf.d/default.conf"
|
2017-10-26 13:01:33 +02:00
|
|
|
|
|
|
|
#=================================================
|
2022-06-20 01:41:47 +02:00
|
|
|
# RESTORE THE LOGROTATE CONFIGURATION
|
2017-10-26 13:01:33 +02:00
|
|
|
#=================================================
|
2022-06-20 01:41:47 +02:00
|
|
|
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
|
2017-10-26 13:01:33 +02:00
|
|
|
|
2022-06-20 01:41:47 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
2017-10-26 13:01:33 +02:00
|
|
|
|
|
|
|
#=================================================
|
2022-06-20 01:41:47 +02:00
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
2017-10-26 13:01:33 +02:00
|
|
|
#=================================================
|
2022-06-20 01:41:47 +02:00
|
|
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
2017-10-26 13:01:33 +02:00
|
|
|
|
2022-06-20 01:41:47 +02:00
|
|
|
yunohost service add $app --description="Allows MQTT clients to send/receive data" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port"
|
2017-10-26 13:01:33 +02:00
|
|
|
|
2022-06-20 01:41:47 +02:00
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
|
|
|
|
ynh_systemd_action --service_name=$app --action="restart"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
2017-10-26 13:01:33 +02:00
|
|
|
#=================================================
|
2021-02-13 18:14:54 +01:00
|
|
|
# END OF SCRIPT
|
2017-10-26 13:01:33 +02:00
|
|
|
#=================================================
|
|
|
|
|
2021-02-13 18:14:54 +01:00
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|