Skip to content
Snippets Groups Projects
Commit 6c904ee9 authored by Bob Mottram's avatar Bob Mottram
Browse files

We don't really need to backup mailpile

parent 364b57a3
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@
# License
# =======
#
# Copyright (C) 2016 Bob Mottram <bob@freedombone.net>
# Copyright (C) 2016-2017 Bob Mottram <bob@freedombone.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -110,118 +110,19 @@ function upgrade_mailpile {
}
function backup_local_mailpile {
if [ ! -f /etc/systemd/system/mailpile.service ]; then
return
fi
MAILPILE_DOMAIN_NAME='mailpile.local'
if grep -q "mailpile domain" $COMPLETION_FILE; then
MAILPILE_DOMAIN_NAME=$(get_completion_param "mailpile domain")
fi
source_directory=/var/www/${MAILPILE_DOMAIN_NAME}/mail/.local
if [ -d $source_directory ]; then
systemctl stop mailpile
function_check backup_directory_to_usb
backup_directory_to_usb $source_directory mailpile
systemctl start mailpile
fi
echo -n ''
}
function restore_local_mailpile {
if [ ! -f /etc/systemd/system/mailpile.service ]; then
return
fi
MAILPILE_DOMAIN_NAME='mailpile.local'
if grep -q "mailpile domain" $COMPLETION_FILE; then
MAILPILE_DOMAIN_NAME=$(get_completion_param "mailpile domain")
fi
if [ $MAILPILE_DOMAIN_NAME ]; then
systemctl stop mailpile
temp_restore_dir=/root/tempmailpile
restore_directory_from_usb $temp_restore_dir mailpile
if [ -d /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local ]; then
mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous
fi
temp_source_dir=$(find ${temp_restore_dir} -name ".local")
cp -r ${temp_source_dir} /var/www/${MAILPILE_DOMAIN_NAME}/mail/
if [ ! "$?" = "0" ]; then
if [ -d mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous ]; then
if [ -d /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous ]; then
rm -rf /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous
fi
mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local
fi
backup_unmount_drive
exit 3685
fi
rm -rf ${temp_restore_dir}
chown -R mailpile: /var/www/$MAILPILE_DOMAIN_NAME/mail/
if [ -d /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME} ]; then
ln -s /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${MAILPILE_DOMAIN_NAME}.key
ln -s /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${MAILPILE_DOMAIN_NAME}.pem
fi
systemctl start mailpile
fi
echo -n ''
}
function backup_remote_mailpile {
if [ ! -f /etc/systemd/system/mailpile.service ]; then
return
fi
MAILPILE_DOMAIN_NAME='mailpile.local'
if grep -q "mailpile domain" $COMPLETION_FILE; then
MAILPILE_DOMAIN_NAME=$(get_completion_param "mailpile domain")
fi
source_directory=/var/www/${MAILPILE_DOMAIN_NAME}/mail/.local
if [ -d $source_directory ]; then
systemctl stop mailpile
function_check backup_directory_to_usb
backup_directory_to_friend $source_directory mailpile
systemctl start mailpile
fi
echo -n ''
}
function restore_remote_mailpile {
if [ ! -f /etc/systemd/system/mailpile.service ]; then
return
fi
MAILPILE_DOMAIN_NAME='mailpile.local'
if grep -q "mailpile domain" $COMPLETION_FILE; then
MAILPILE_DOMAIN_NAME=$(get_completion_param "mailpile domain")
fi
if [ $MAILPILE_DOMAIN_NAME ]; then
systemctl stop mailpile
temp_restore_dir=/root/tempmailpile
restore_directory_from_friend $temp_restore_dir mailpile
if [ -d /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local ]; then
mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous
fi
temp_source_dir=$(find ${temp_restore_dir} -name ".local")
cp -r ${temp_source_dir} /var/www/${MAILPILE_DOMAIN_NAME}/mail/
if [ ! "$?" = "0" ]; then
if [ -d mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous ]; then
mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local
fi
backup_unmount_drive
exit 36732
fi
rm -rf ${temp_restore_dir}
chown -R mailpile: /var/www/$MAILPILE_DOMAIN_NAME/mail/
if [ -d /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME} ]; then
ln -s /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${MAILPILE_DOMAIN_NAME}.key
ln -s /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${MAILPILE_DOMAIN_NAME}.pem
fi
systemctl start mailpile
fi
echo -n ''
}
function remove_mailpile {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment