From a0199d060b0cec122d6155364e2e9f18957ae9ae Mon Sep 17 00:00:00 2001 From: zamentur Date: Fri, 2 Oct 2015 18:57:10 +0200 Subject: [PATCH] [enh] Introduce data and conf hooks category --- data/hooks/backup/{05-system_ldap => 05-conf_ldap} | 2 +- data/hooks/backup/{08-system_ssh => 08-conf_ssh} | 2 +- data/hooks/backup/11-conf_mysql | 4 ++++ data/hooks/backup/11-system_mysql | 5 ----- data/hooks/backup/{14-system_ssowat => 14-conf_ssowat} | 2 +- data/hooks/backup/{17-system_home => 17-data_home} | 2 +- data/hooks/backup/20-conf_ynh_firewall | 4 ++++ data/hooks/backup/20-system_yunohost | 4 ---- data/hooks/backup/21-conf_ynh_certs | 4 ++++ data/hooks/backup/{23-system_mail => 23-data_mail} | 2 +- data/hooks/backup/{26-system_xmpp => 26-conf_xmpp} | 2 +- data/hooks/backup/{29-system_nginx => 29-conf_nginx} | 2 +- data/hooks/backup/{32-system_cron => 32-conf_cron} | 2 +- data/hooks/restore/{05-system_ldap => 05-conf_ldap} | 2 +- data/hooks/restore/{08-system_ssh => 08-conf_ssh} | 2 +- data/hooks/restore/{11-system_mysql => 11-conf_mysql} | 4 ++-- data/hooks/restore/{14-system_ssowat => 14-conf_ssowat} | 2 +- data/hooks/restore/{17-system_home => 17-data_home} | 2 +- data/hooks/restore/20-conf_ynh_firewall | 4 ++++ data/hooks/restore/20-system_yunohost | 9 --------- data/hooks/restore/21-conf_ynh_certs | 8 ++++++++ data/hooks/restore/{23-system_mail => 23-data_mail} | 2 +- data/hooks/restore/{26-system_xmpp => 26-conf_xmpp} | 2 +- data/hooks/restore/{29-system_nginx => 29-conf_nginx} | 2 +- data/hooks/restore/{32-system_cron => 32-conf_cron} | 2 +- 25 files changed, 42 insertions(+), 36 deletions(-) rename data/hooks/backup/{05-system_ldap => 05-conf_ldap} (89%) rename data/hooks/backup/{08-system_ssh => 08-conf_ssh} (69%) create mode 100644 data/hooks/backup/11-conf_mysql delete mode 100644 data/hooks/backup/11-system_mysql rename data/hooks/backup/{14-system_ssowat => 14-conf_ssowat} (67%) rename data/hooks/backup/{17-system_home => 17-data_home} (75%) create mode 100644 data/hooks/backup/20-conf_ynh_firewall delete mode 100644 data/hooks/backup/20-system_yunohost create mode 100644 data/hooks/backup/21-conf_ynh_certs rename data/hooks/backup/{23-system_mail => 23-data_mail} (58%) rename data/hooks/backup/{26-system_xmpp => 26-conf_xmpp} (82%) rename data/hooks/backup/{29-system_nginx => 29-conf_nginx} (70%) rename data/hooks/backup/{32-system_cron => 32-conf_cron} (72%) rename data/hooks/restore/{05-system_ldap => 05-conf_ldap} (97%) rename data/hooks/restore/{08-system_ssh => 08-conf_ssh} (70%) rename data/hooks/restore/{11-system_mysql => 11-conf_mysql} (51%) rename data/hooks/restore/{14-system_ssowat => 14-conf_ssowat} (57%) rename data/hooks/restore/{17-system_home => 17-data_home} (55%) create mode 100644 data/hooks/restore/20-conf_ynh_firewall delete mode 100644 data/hooks/restore/20-system_yunohost create mode 100644 data/hooks/restore/21-conf_ynh_certs rename data/hooks/restore/{23-system_mail => 23-data_mail} (83%) rename data/hooks/restore/{26-system_xmpp => 26-conf_xmpp} (86%) rename data/hooks/restore/{29-system_nginx => 29-conf_nginx} (80%) rename data/hooks/restore/{32-system_cron => 32-conf_cron} (77%) diff --git a/data/hooks/backup/05-system_ldap b/data/hooks/backup/05-conf_ldap similarity index 89% rename from data/hooks/backup/05-system_ldap rename to data/hooks/backup/05-conf_ldap index 9ef09b114..0a6cbc443 100644 --- a/data/hooks/backup/05-system_ldap +++ b/data/hooks/backup/05-conf_ldap @@ -1,4 +1,4 @@ -backup_dir="$1/ldap" +backup_dir="$1/conf/ldap" mkdir -p $backup_dir sudo cp -a /etc/ldap/slapd.conf $backup_dir/ diff --git a/data/hooks/backup/08-system_ssh b/data/hooks/backup/08-conf_ssh similarity index 69% rename from data/hooks/backup/08-system_ssh rename to data/hooks/backup/08-conf_ssh index e5f2570ea..f17ce48ee 100644 --- a/data/hooks/backup/08-system_ssh +++ b/data/hooks/backup/08-conf_ssh @@ -1,4 +1,4 @@ -backup_dir="$1/ssh" +backup_dir="$1/conf/ssh" mkdir -p $backup_dir sudo cp -a /etc/ssh/. $backup_dir diff --git a/data/hooks/backup/11-conf_mysql b/data/hooks/backup/11-conf_mysql new file mode 100644 index 000000000..d227df41d --- /dev/null +++ b/data/hooks/backup/11-conf_mysql @@ -0,0 +1,4 @@ +backup_dir="$1/conf/mysql" +mkdir -p $backup_dir + +mysqlpwd=$(sudo cat /etc/yunohost/mysql) diff --git a/data/hooks/backup/11-system_mysql b/data/hooks/backup/11-system_mysql deleted file mode 100644 index 984d52a61..000000000 --- a/data/hooks/backup/11-system_mysql +++ /dev/null @@ -1,5 +0,0 @@ -backup_dir="$1/mysql" -mkdir -p $backup_dir - -mysqlpwd=$(sudo cat /etc/yunohost/mysql) -sudo mysqldump -uroot -p"$mysqlpwd" mysql > $backup_dir/mysql.sql diff --git a/data/hooks/backup/14-system_ssowat b/data/hooks/backup/14-conf_ssowat similarity index 67% rename from data/hooks/backup/14-system_ssowat rename to data/hooks/backup/14-conf_ssowat index fbb78f196..bae115467 100644 --- a/data/hooks/backup/14-system_ssowat +++ b/data/hooks/backup/14-conf_ssowat @@ -1,4 +1,4 @@ -backup_dir="$1/ssowat" +backup_dir="$1/conf/ssowat" mkdir -p $backup_dir sudo cp -a /etc/ssowat/. $backup_dir diff --git a/data/hooks/backup/17-system_home b/data/hooks/backup/17-data_home similarity index 75% rename from data/hooks/backup/17-system_home rename to data/hooks/backup/17-data_home index b73b2dff3..96061f733 100644 --- a/data/hooks/backup/17-system_home +++ b/data/hooks/backup/17-data_home @@ -1,4 +1,4 @@ -backup_dir="$1/home" +backup_dir="$1/data/home" mkdir -p $backup_dir sudo rsync -a --exclude='/yunohost*' /home/ $backup_dir/ diff --git a/data/hooks/backup/20-conf_ynh_firewall b/data/hooks/backup/20-conf_ynh_firewall new file mode 100644 index 000000000..cb0a8493d --- /dev/null +++ b/data/hooks/backup/20-conf_ynh_firewall @@ -0,0 +1,4 @@ +backup_dir="$1/conf/ynh/firewall" +mkdir -p $backup_dir + +sudo cp -a /etc/yunohost/firewall* $backup_dir diff --git a/data/hooks/backup/20-system_yunohost b/data/hooks/backup/20-system_yunohost deleted file mode 100644 index e49b52899..000000000 --- a/data/hooks/backup/20-system_yunohost +++ /dev/null @@ -1,4 +0,0 @@ -backup_dir="$1/yunohost" -mkdir -p $backup_dir - -sudo cp -a /etc/yunohost/. $backup_dir diff --git a/data/hooks/backup/21-conf_ynh_certs b/data/hooks/backup/21-conf_ynh_certs new file mode 100644 index 000000000..061513f99 --- /dev/null +++ b/data/hooks/backup/21-conf_ynh_certs @@ -0,0 +1,4 @@ +backup_dir="$1/conf/ynh/certs" +mkdir -p $backup_dir + +sudo cp -a /etc/yunohost/certs/. $backup_dir diff --git a/data/hooks/backup/23-system_mail b/data/hooks/backup/23-data_mail similarity index 58% rename from data/hooks/backup/23-system_mail rename to data/hooks/backup/23-data_mail index 7fe210ce2..01b362fea 100644 --- a/data/hooks/backup/23-system_mail +++ b/data/hooks/backup/23-data_mail @@ -1,3 +1,3 @@ -backup_dir="$1/mail" +backup_dir="$1/data/mail" sudo cp -a /var/mail/. $backup_dir diff --git a/data/hooks/backup/26-system_xmpp b/data/hooks/backup/26-conf_xmpp similarity index 82% rename from data/hooks/backup/26-system_xmpp rename to data/hooks/backup/26-conf_xmpp index 2b87644d2..68461c03d 100644 --- a/data/hooks/backup/26-system_xmpp +++ b/data/hooks/backup/26-conf_xmpp @@ -1,4 +1,4 @@ -backup_dir="$1/xmpp" +backup_dir="$1/conf/xmpp" mkdir -p $backup_dir/{etc,var} sudo cp -a /etc/metronome/. $backup_dir/etc diff --git a/data/hooks/backup/29-system_nginx b/data/hooks/backup/29-conf_nginx similarity index 70% rename from data/hooks/backup/29-system_nginx rename to data/hooks/backup/29-conf_nginx index 976809122..caa9c9d59 100644 --- a/data/hooks/backup/29-system_nginx +++ b/data/hooks/backup/29-conf_nginx @@ -1,4 +1,4 @@ -backup_dir="$1/nginx" +backup_dir="$1/conf/nginx" mkdir -p $backup_dir sudo cp -a /etc/nginx/conf.d/. $backup_dir diff --git a/data/hooks/backup/32-system_cron b/data/hooks/backup/32-conf_cron similarity index 72% rename from data/hooks/backup/32-system_cron rename to data/hooks/backup/32-conf_cron index 87a2a4f2e..5052d50e5 100644 --- a/data/hooks/backup/32-system_cron +++ b/data/hooks/backup/32-conf_cron @@ -1,4 +1,4 @@ -backup_dir="$1/cron" +backup_dir="$1/conf/cron" mkdir -p $backup_dir sudo cp -a /etc/cron.d/yunohost* $backup_dir/ diff --git a/data/hooks/restore/05-system_ldap b/data/hooks/restore/05-conf_ldap similarity index 97% rename from data/hooks/restore/05-system_ldap rename to data/hooks/restore/05-conf_ldap index f16225c3e..22867e6cc 100644 --- a/data/hooks/restore/05-system_ldap +++ b/data/hooks/restore/05-conf_ldap @@ -1,4 +1,4 @@ -backup_dir="$1/ldap" +backup_dir="$1/conf/ldap" if [ -z "$2" ]; then diff --git a/data/hooks/restore/08-system_ssh b/data/hooks/restore/08-conf_ssh similarity index 70% rename from data/hooks/restore/08-system_ssh rename to data/hooks/restore/08-conf_ssh index bfe729f3f..71ac9df38 100644 --- a/data/hooks/restore/08-system_ssh +++ b/data/hooks/restore/08-conf_ssh @@ -1,4 +1,4 @@ -backup_dir="$1/ssh" +backup_dir="$1/conf/ssh" sudo cp -a $backup_dir/. /etc/ssh sudo service ssh restart diff --git a/data/hooks/restore/11-system_mysql b/data/hooks/restore/11-conf_mysql similarity index 51% rename from data/hooks/restore/11-system_mysql rename to data/hooks/restore/11-conf_mysql index f25e4ef6f..cc1320298 100644 --- a/data/hooks/restore/11-system_mysql +++ b/data/hooks/restore/11-conf_mysql @@ -1,5 +1,5 @@ -backup_dir="$1/mysql" +backup_dir="$1/conf/mysql" +service mysql restart mysqlpwd=$(sudo cat /etc/yunohost/mysql) -#sudo mysql -uroot -p"$mysqlpwd" mysql < $backup_dir/mysql.sql sudo mysqladmin flush-privileges -p"$mysqlpwd" diff --git a/data/hooks/restore/14-system_ssowat b/data/hooks/restore/14-conf_ssowat similarity index 57% rename from data/hooks/restore/14-system_ssowat rename to data/hooks/restore/14-conf_ssowat index 15bae3c77..01ac787ee 100644 --- a/data/hooks/restore/14-system_ssowat +++ b/data/hooks/restore/14-conf_ssowat @@ -1,3 +1,3 @@ -backup_dir="$1/ssowat" +backup_dir="$1/conf/ssowat" sudo cp -a $backup_dir/. /etc/ssowat diff --git a/data/hooks/restore/17-system_home b/data/hooks/restore/17-data_home similarity index 55% rename from data/hooks/restore/17-system_home rename to data/hooks/restore/17-data_home index d005bed07..a7ba2733c 100644 --- a/data/hooks/restore/17-system_home +++ b/data/hooks/restore/17-data_home @@ -1,3 +1,3 @@ -backup_dir="$1/home" +backup_dir="$1/data/home" sudo cp -a $backup_dir/. /home diff --git a/data/hooks/restore/20-conf_ynh_firewall b/data/hooks/restore/20-conf_ynh_firewall new file mode 100644 index 000000000..c0ee18818 --- /dev/null +++ b/data/hooks/restore/20-conf_ynh_firewall @@ -0,0 +1,4 @@ +backup_dir="$1/conf/ynh/firewall" + +sudo cp -a $backup_dir/. /etc/yunohost +sudo yunohost firewall reload diff --git a/data/hooks/restore/20-system_yunohost b/data/hooks/restore/20-system_yunohost deleted file mode 100644 index 2ceb2ada6..000000000 --- a/data/hooks/restore/20-system_yunohost +++ /dev/null @@ -1,9 +0,0 @@ -backup_dir="$1/yunohost" - -sudo cp -a $backup_dir/. /etc/yunohost -sudo yunohost app ssowatconf -sudo yunohost firewall reload - -# Reload interface name -sudo rm /etc/yunohost/interface -sudo apt-get install --reinstall -y yunohost-config-others diff --git a/data/hooks/restore/21-conf_ynh_certs b/data/hooks/restore/21-conf_ynh_certs new file mode 100644 index 000000000..897e303ff --- /dev/null +++ b/data/hooks/restore/21-conf_ynh_certs @@ -0,0 +1,8 @@ +backup_dir="$1/conf/ynh/certs" + +mkdir -p /etc/yunohost/certs/ + +sudo cp -a $backup_dir/. /etc/yunohost/certs/ +sudo yunohost app ssowatconf +sudo service nginx reload +sudo service metronome reload diff --git a/data/hooks/restore/23-system_mail b/data/hooks/restore/23-data_mail similarity index 83% rename from data/hooks/restore/23-system_mail rename to data/hooks/restore/23-data_mail index ecef0ec15..594c667dd 100644 --- a/data/hooks/restore/23-system_mail +++ b/data/hooks/restore/23-data_mail @@ -1,4 +1,4 @@ -backup_dir="$1/mail" +backup_dir="$1/data/mail" sudo cp -a $backup_dir/. /var/mail diff --git a/data/hooks/restore/26-system_xmpp b/data/hooks/restore/26-conf_xmpp similarity index 86% rename from data/hooks/restore/26-system_xmpp rename to data/hooks/restore/26-conf_xmpp index 70dc7e1c4..61692b316 100644 --- a/data/hooks/restore/26-system_xmpp +++ b/data/hooks/restore/26-conf_xmpp @@ -1,4 +1,4 @@ -backup_dir="$1/xmpp" +backup_dir="$1/conf/xmpp" sudo cp -a $backup_dir/etc/. /etc/metronome sudo cp -a $backup_dir/var/. /var/lib/metronome diff --git a/data/hooks/restore/29-system_nginx b/data/hooks/restore/29-conf_nginx similarity index 80% rename from data/hooks/restore/29-system_nginx rename to data/hooks/restore/29-conf_nginx index 5ffaf5c14..245c1248c 100644 --- a/data/hooks/restore/29-system_nginx +++ b/data/hooks/restore/29-conf_nginx @@ -1,4 +1,4 @@ -backup_dir="$1/nginx" +backup_dir="$1/conf/nginx" sudo cp -a $backup_dir/. /etc/nginx/conf.d diff --git a/data/hooks/restore/32-system_cron b/data/hooks/restore/32-conf_cron similarity index 77% rename from data/hooks/restore/32-system_cron rename to data/hooks/restore/32-conf_cron index 1e12d23b7..68657963e 100644 --- a/data/hooks/restore/32-system_cron +++ b/data/hooks/restore/32-conf_cron @@ -1,4 +1,4 @@ -backup_dir="$1/cron" +backup_dir="$1/conf/cron" sudo cp -a $backup_dir/. /etc/cron.d