1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/borg_ynh.git synced 2024-09-03 18:16:05 +02:00
borg_ynh/scripts/restore
2021-08-15 16:49:20 +02:00

81 lines
2.6 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
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..."
app=$YNH_APP_INSTANCE_NAME
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..."
ynh_install_app_dependencies $pkg_dependencies
install_borg_with_pip
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app
#=================================================
# ACTIVATE BACKUP METHODS
#=================================================
mkdir -p /etc/yunohost/hooks.d/backup_method
mkdir -p /usr/share/yunohost/backup_method
mkdir -p /etc/yunohost/hooks.d/backup
mkdir -p /var/log/${app}
chown -R $app:$app /var/log/${app}
chmod u+w /var/log/${app}
#=================================================
# RESTORE FILES
#=================================================
ynh_restore
chmod go=--- "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
chmod u+x "/usr/local/bin/backup-with-$app"
chown $app:$app "/usr/local/bin/backup-with-$app"
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
systemctl enable $app.timer --quiet
systemctl start $app.timer
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
# Inactive services are ignored cause it's a timer
yunohost service add $app --description="Deduplicating backup program" --test_status="systemctl show $app.service -p ActiveState --value | grep -v failed"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last