2020-02-23 12:02:10 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2022-03-13 17:45:45 +01:00
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
2020-02-23 12:02:10 +01:00
|
|
|
source ../settings/scripts/_common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
2024-05-25 09:34:34 +02:00
|
|
|
# RESTORE THE APP MAIN DIR
|
2020-02-23 12:02:10 +01:00
|
|
|
#=================================================
|
2024-05-25 09:34:34 +02:00
|
|
|
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
2021-03-07 14:03:37 +01:00
|
|
|
|
2024-05-25 09:34:34 +02:00
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
2020-02-23 12:02:10 +01:00
|
|
|
|
2024-05-26 12:18:51 +02:00
|
|
|
# ynh_setup_source --source_id=main --dest_dir="$install_dir"
|
|
|
|
# chmod +x "$install_dir/restic"
|
2020-02-23 12:02:10 +01:00
|
|
|
|
2024-05-26 12:56:25 +02:00
|
|
|
_gen_and_save_public_key
|
|
|
|
|
2024-05-25 09:34:34 +02:00
|
|
|
chown -R "$app:$app" "$install_dir"
|
|
|
|
|
2020-02-23 12:02:10 +01:00
|
|
|
#=================================================
|
|
|
|
# ACTIVATE BACKUP METHODS
|
|
|
|
#=================================================
|
2024-05-25 09:34:34 +02:00
|
|
|
ynh_script_progression --message="Setting up backup method..." --weight=1
|
|
|
|
|
|
|
|
mkdir -p /etc/yunohost/hooks.d/backup
|
2020-02-23 12:02:10 +01:00
|
|
|
mkdir -p /etc/yunohost/hooks.d/backup_method
|
|
|
|
mkdir -p /usr/share/yunohost/backup_method
|
|
|
|
|
2024-05-25 09:34:34 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
|
|
|
chmod go=--- "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
|
|
|
|
2020-02-23 12:02:10 +01:00
|
|
|
#=================================================
|
2024-05-25 09:34:34 +02:00
|
|
|
# RESTORE SYSTEM CONFIGURATIONS
|
2020-02-23 12:02:10 +01:00
|
|
|
#=================================================
|
2024-05-25 09:34:34 +02:00
|
|
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
2022-03-13 17:45:45 +01:00
|
|
|
|
2024-05-25 09:34:34 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/sudoers.d/$app"
|
|
|
|
chown root:root "/etc/sudoers.d/$app"
|
2020-02-23 12:02:10 +01:00
|
|
|
|
2024-05-26 12:48:19 +02:00
|
|
|
ynh_restore_file --origin_path="/root/.ssh/id_${app}_ed25519"
|
|
|
|
ynh_restore_file --origin_path="/root/.ssh/id_${app}_ed25519.pub"
|
2024-05-25 09:34:34 +02:00
|
|
|
# FIXME: restore the .ssh/config instead?
|
|
|
|
_set_ssh_config
|
2022-03-13 17:45:45 +01:00
|
|
|
|
2024-05-25 09:34:34 +02:00
|
|
|
for suffix in "${systemd_services_suffixes[@]}"; do
|
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/$app$suffix.timer"
|
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/$app$suffix.service"
|
2024-05-25 22:25:00 +02:00
|
|
|
systemctl enable --quiet "$app$suffix.timer"
|
2024-05-25 22:27:44 +02:00
|
|
|
ynh_systemd_action --service_name="$app$suffix.timer" --action="start"
|
2024-05-25 22:26:49 +02:00
|
|
|
|
|
|
|
yunohost service add "$app$suffix" --description="Restic backup program ($app$suffix)" \
|
|
|
|
--test_status="systemctl show $app$suffix.service -p ActiveState --value | grep -v failed"
|
2024-05-25 09:34:34 +02:00
|
|
|
done
|
2022-03-13 17:45:45 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Restoration completed for $app"
|