2019-02-20 12:08:50 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-11-16 19:38:35 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2019-02-20 12:08:50 +01:00
|
|
|
|
2022-03-13 21:51:45 +01:00
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
2020-11-16 19:38:35 +01:00
|
|
|
source ../settings/scripts/_common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
2023-08-12 10:35:10 +02:00
|
|
|
#REMOVEME? ynh_clean_setup () {
|
2022-09-03 00:44:25 +02:00
|
|
|
true
|
2020-11-16 19:38:35 +01:00
|
|
|
}
|
|
|
|
# Exit if an error occurs during the execution of the script
|
2023-08-12 10:35:10 +02:00
|
|
|
#REMOVEME? ynh_abort_if_errors
|
2020-11-16 19:38:35 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2023-08-12 10:35:10 +02:00
|
|
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
2019-02-20 12:08:50 +01:00
|
|
|
|
2023-08-12 10:35:10 +02:00
|
|
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
2019-02-20 12:08:50 +01:00
|
|
|
|
2023-08-12 10:35:10 +02:00
|
|
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
|
|
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
|
|
|
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
2020-11-16 19:38:35 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE RESTORED
|
|
|
|
#=================================================
|
2023-08-12 10:35:10 +02:00
|
|
|
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=2
|
2020-11-16 19:38:35 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD RESTORATION STEPS
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC RESTORATION
|
|
|
|
#=================================================
|
|
|
|
# REINSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
2023-08-12 10:35:10 +02:00
|
|
|
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=7
|
2020-11-16 19:38:35 +01:00
|
|
|
|
|
|
|
# Define and install dependencies
|
2023-08-12 10:35:10 +02:00
|
|
|
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
2020-11-16 19:38:35 +01:00
|
|
|
|
2022-09-03 00:44:25 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
|
2020-11-16 19:38:35 +01:00
|
|
|
#=================================================
|
2022-03-13 21:51:45 +01:00
|
|
|
# RESTORE VARIOUS FILES
|
2020-11-16 19:38:35 +01:00
|
|
|
#=================================================
|
2022-09-03 00:44:25 +02:00
|
|
|
ynh_script_progression --message="Restoring various files..." --weight=1
|
2022-03-13 21:51:45 +01:00
|
|
|
|
|
|
|
ynh_replace_string --match_string="ListenStream=.*" --replace_string="ListenStream=$port" --target_file="/lib/systemd/system/cockpit.socket"
|
|
|
|
systemctl daemon-reload
|
|
|
|
systemctl restart $app.socket
|
2020-11-16 19:38:35 +01:00
|
|
|
|
2022-03-13 21:51:45 +01:00
|
|
|
ynh_restore_file --origin_path="/etc/cockpit/cockpit.conf"
|
2020-11-16 19:38:35 +01:00
|
|
|
|
|
|
|
#=================================================
|
2022-03-13 21:51:45 +01:00
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
2020-11-16 19:38:35 +01:00
|
|
|
#=================================================
|
2022-03-13 21:51:45 +01:00
|
|
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
2020-11-16 19:38:35 +01:00
|
|
|
|
2022-03-13 21:51:45 +01:00
|
|
|
yunohost service add $app
|
2020-11-16 19:38:35 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=2
|
|
|
|
|
2022-03-13 21:51:45 +01:00
|
|
|
ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Started"
|
2020-11-16 19:38:35 +01:00
|
|
|
|
|
|
|
#=================================================
|
2022-03-13 21:51:45 +01:00
|
|
|
# GENERIC FINALIZATION
|
2020-11-16 19:38:35 +01:00
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=2
|
|
|
|
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2019-02-20 12:08:50 +01:00
|
|
|
|
2022-05-31 01:08:23 +02:00
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|