2020-02-23 12:02:10 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
|
|
|
|
2020-11-15 11:32:24 +01:00
|
|
|
export app=$YNH_APP_INSTANCE_NAME
|
2020-11-14 18:03:13 +01:00
|
|
|
export final_path="/opt/yunohost/${app}"
|
2020-11-15 11:32:24 +01:00
|
|
|
export server=$(ynh_app_setting_get $app server)
|
|
|
|
export port=$(ynh_app_setting_get $app port)
|
|
|
|
export ssh_user=$(ynh_app_setting_get $app ssh_user)
|
|
|
|
export backup_path=$(ynh_app_setting_get $app backup_path)
|
|
|
|
export passphrase=$(ynh_app_setting_get $app passphrase)
|
|
|
|
export on_calendar=$(ynh_app_setting_get $app on_calendar)
|
|
|
|
export check_on_calendar=$(ynh_app_setting_get $app check_on_calendar)
|
|
|
|
export check_read_data_on_calendar=$(ynh_app_setting_get $app check_read_data_on_calendar)
|
|
|
|
export conf=$(ynh_app_setting_get $app conf)
|
|
|
|
export data=$(ynh_app_setting_get $app data)
|
|
|
|
export apps=$(ynh_app_setting_get $app apps)
|
|
|
|
export allow_extra_space_use=$(ynh_app_setting_get $app allow_extra_space_use)
|
|
|
|
|
2020-02-23 12:02:10 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK IF AN UPGRADE IS NEEDED
|
|
|
|
#=================================================
|
|
|
|
ynh_check_app_version_changed
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Backup the current version of the app
|
|
|
|
ynh_backup_before_upgrade
|
|
|
|
ynh_clean_setup () {
|
|
|
|
# restore it if the upgrade fails
|
|
|
|
ynh_restore_upgradebackup
|
|
|
|
}
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
|
|
|
|
if grep "restic.timer" /etc/yunohost/services.yml > /dev/null ; then
|
|
|
|
yunohost service remove $app.timer
|
|
|
|
systemctl enable $app.timer
|
|
|
|
systemctl start $app.timer
|
|
|
|
fi
|
|
|
|
|
2020-02-23 21:06:25 +01:00
|
|
|
#=================================================
|
2020-04-12 17:13:11 +02:00
|
|
|
# INSTALL RESTIC
|
2020-02-23 21:06:25 +01:00
|
|
|
#=================================================
|
|
|
|
install_restic
|
2020-11-14 18:03:13 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CONFIGURE SERVICES
|
|
|
|
#=================================================
|
|
|
|
ynh_add_systemd_config --service=${app} --template=systemd.service
|
|
|
|
ynh_configure systemd.timer "/etc/systemd/system/${app}.timer"
|
|
|
|
systemctl disable ${app}.service
|
|
|
|
systemctl enable ${app}.timer
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# ACTIVATE BACKUP METHODS
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Activating backup methods"
|
|
|
|
mkdir -p /etc/yunohost/hooks.d/backup_method || true
|
|
|
|
mkdir -p /usr/share/yunohost/backup_method || true
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP THE BACKUP METHOD
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Setting up backup methods"
|
|
|
|
ynh_configure backup_method "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
|
|
|
ynh_configure check_method "${final_path}/check_method"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP LOG SCRIPT
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Setting up log script"
|
|
|
|
ynh_configure restic_log "${final_path}/restic_log"
|
|
|
|
chmod u+x "${final_path}/restic_log"
|