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

97 lines
3.4 KiB
Text
Raw Normal View History

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
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
2022-03-13 21:51:45 +01:00
ynh_script_progression --message="Loading installation settings..." --weight=1
2019-02-20 12:08:50 +01:00
app=$YNH_APP_INSTANCE_NAME
2020-11-16 19:38:35 +01:00
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
2022-03-13 21:51:45 +01:00
port=$(ynh_app_setting_get --app=$app --key=port)
2020-11-16 19:38:35 +01:00
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=2
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
2022-03-13 21:51:45 +01:00
ynh_script_progression --message="Restoring the NGINX web server configuration..."
2020-11-16 19:38:35 +01:00
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=7
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
2022-03-13 21:51:45 +01:00
# RESTORE VARIOUS FILES
2020-11-16 19:38:35 +01:00
#=================================================
2022-03-13 21:51:45 +01:00
ynh_script_progression --message="Restoring various files..."
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
2021-07-07 19:08:59 +02:00
ynh_script_progression --message="Installation of $app completed" --last