From 82784dc45d2d69ac185afa67388aeabd0c1594ea Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 5 Apr 2021 21:39:49 +0200 Subject: [PATCH] Merge firewall, dkim and dyndns backup hook into ynh_settings --- data/hooks/backup/20-conf_ynh_firewall | 13 ------------- data/hooks/backup/22-conf_mail | 9 --------- data/hooks/backup/40-conf_ynh_settings | 3 +++ data/hooks/backup/42-conf_ynh_dyndns | 10 ---------- data/hooks/restore/20-conf_ynh_firewall | 4 ---- data/hooks/restore/22-conf_mail | 9 --------- data/hooks/restore/40-conf_ynh_settings | 3 +++ data/hooks/restore/42-conf_ynh_dyndns | 9 --------- 8 files changed, 6 insertions(+), 54 deletions(-) delete mode 100644 data/hooks/backup/20-conf_ynh_firewall delete mode 100644 data/hooks/backup/22-conf_mail delete mode 100644 data/hooks/backup/42-conf_ynh_dyndns delete mode 100644 data/hooks/restore/20-conf_ynh_firewall delete mode 100644 data/hooks/restore/22-conf_mail delete mode 100644 data/hooks/restore/42-conf_ynh_dyndns diff --git a/data/hooks/backup/20-conf_ynh_firewall b/data/hooks/backup/20-conf_ynh_firewall deleted file mode 100644 index 98be3eb09..000000000 --- a/data/hooks/backup/20-conf_ynh_firewall +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# Exit hook on subcommand error or unset variable -set -eu - -# Source YNH helpers -source /usr/share/yunohost/helpers - -# Backup destination -backup_dir="${1}/conf/ynh/firewall" - -# Backup the configuration -ynh_backup "/etc/yunohost/firewall.yml" "${backup_dir}/firewall.yml" diff --git a/data/hooks/backup/22-conf_mail b/data/hooks/backup/22-conf_mail deleted file mode 100644 index b604d8aa8..000000000 --- a/data/hooks/backup/22-conf_mail +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -source /usr/share/yunohost/helpers -ynh_abort_if_errors -YNH_CWD="${YNH_BACKUP_DIR%/}/conf/dkim" -mkdir -p "$YNH_CWD" -cd "$YNH_CWD" - -ynh_backup --src_path="/etc/dkim" diff --git a/data/hooks/backup/40-conf_ynh_settings b/data/hooks/backup/40-conf_ynh_settings index 5b66da722..77148c4d9 100644 --- a/data/hooks/backup/40-conf_ynh_settings +++ b/data/hooks/backup/40-conf_ynh_settings @@ -10,5 +10,8 @@ source /usr/share/yunohost/helpers backup_dir="${1}/conf/ynh" # Backup the configuration +ynh_backup "/etc/yunohost/firewall.yml" "${backup_dir}/firewall.yml" ynh_backup "/etc/yunohost/current_host" "${backup_dir}/current_host" [ ! -e "/etc/yunohost/settings.json" ] || ynh_backup "/etc/yunohost/settings.json" "${backup_dir}/settings.json" +[ ! -d "/etc/yunohost/dyndns" ] || ynh_backup "/etc/yunohost/dyndns" "${backup_dir}/dyndns" +[ ! -d "/etc/dkim" ] || ynh_backup "/etc/dkim" "${backup_dir}/dkim" diff --git a/data/hooks/backup/42-conf_ynh_dyndns b/data/hooks/backup/42-conf_ynh_dyndns deleted file mode 100644 index 6343f9086..000000000 --- a/data/hooks/backup/42-conf_ynh_dyndns +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -source /usr/share/yunohost/helpers -ynh_abort_if_errors -YNH_CWD="${YNH_BACKUP_DIR%/}/conf/ynh/dyndns" -mkdir -p $YNH_CWD -cd "$YNH_CWD" - -# Backup the configuration -ynh_exec_warn_less ynh_backup --src_path="/etc/yunohost/dyndns" --not_mandatory diff --git a/data/hooks/restore/20-conf_ynh_firewall b/data/hooks/restore/20-conf_ynh_firewall deleted file mode 100644 index 1789aed1e..000000000 --- a/data/hooks/restore/20-conf_ynh_firewall +++ /dev/null @@ -1,4 +0,0 @@ -backup_dir="$1/conf/ynh/firewall" - -cp -a $backup_dir/. /etc/yunohost -yunohost firewall reload diff --git a/data/hooks/restore/22-conf_mail b/data/hooks/restore/22-conf_mail deleted file mode 100644 index 77e0a4d42..000000000 --- a/data/hooks/restore/22-conf_mail +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -backup_dir="$1/conf/dkim" - -cp -a $backup_dir/etc/dkim/. /etc/dkim - -chown -R root:root /etc/dkim -chown _rspamd:root /etc/dkim -chown _rspamd:root /etc/dkim/*.mail.key diff --git a/data/hooks/restore/40-conf_ynh_settings b/data/hooks/restore/40-conf_ynh_settings index 3bfa63162..4de29a4aa 100644 --- a/data/hooks/restore/40-conf_ynh_settings +++ b/data/hooks/restore/40-conf_ynh_settings @@ -1,4 +1,7 @@ backup_dir="$1/conf/ynh" cp -a "${backup_dir}/current_host" /etc/yunohost/current_host +cp -a "${backup_dir}/firewall.yml" /etc/yunohost/firewall.yml [ ! -e "${backup_dir}/settings.json" ] || cp -a "${backup_dir}/settings.json" "/etc/yunohost/settings.json" +[ ! -d "${backup_dir}/dyndns" ] || cp -raT "${backup_dir}/dyndns" "/etc/yunohost/dyndns" +[ ! -d "${backup_dir}/dkim" ] || cp -raT "${backup_dir}/dkim" "/etc/dkim" diff --git a/data/hooks/restore/42-conf_ynh_dyndns b/data/hooks/restore/42-conf_ynh_dyndns deleted file mode 100644 index 8ed4941ef..000000000 --- a/data/hooks/restore/42-conf_ynh_dyndns +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -source /usr/share/yunohost/helpers -ynh_abort_if_errors -YNH_CWD="${YNH_BACKUP_DIR%/}/conf/ynh/dyndns" -cd "$YNH_CWD" - -# Restore file if exists -ynh_restore_file --origin_path="/etc/yunohost/dyndns" --not_mandatory