Entertain the possibility of there being more than one user

This commit is contained in:
Bob Mottram 2015-08-08 09:30:18 +01:00
parent b99e6b5b14
commit e066ab1537
1 changed files with 168 additions and 134 deletions

View File

@ -1961,6 +1961,12 @@ function create_backup_script {
echo ' USB_DRIVE=/dev/${1}1' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' USB_DRIVE=/dev/${1}1' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "ADMIN_USERNAME=$MY_USERNAME" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "MY_USERNAME=$MY_USERNAME" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'if [ $2 ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' MY_USERNAME=$2' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'if [ ! -b $USB_DRIVE ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME echo 'if [ ! -b $USB_DRIVE ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Please attach a USB drive"' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' echo "Please attach a USB drive"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' exit 1' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' exit 1' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2269,12 +2275,13 @@ function create_backup_script {
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup projects' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '# Backup projects' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ -d /home/$MY_USERNAME/projects ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo 'if [ -d /home/$MY_USERNAME/projects ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up projects"' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' echo "Backing up projects"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " if [ ! -d $USB_MOUNT/backup/projects ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " if [ ! -d $USB_MOUNT/backup/projects ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/projects" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " mkdir -p $USB_MOUNT/backup/projects" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rsyncrypto -v -r /home/$MY_USERNAME/projects $USB_MOUNT/backup/projects $USB_MOUNT/backup/projects.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME echo -n ' rsyncrypto -v -r /home/$MY_USERNAME/projects ' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "$USB_MOUNT/backup/projects $USB_MOUNT/backup/projects.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2284,12 +2291,13 @@ function create_backup_script {
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup personal settings' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '# Backup personal settings' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ -d /home/$MY_USERNAME/personal ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo 'if [ -d /home/$MY_USERNAME/personal ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up personal settings"' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' echo "Backing up personal settings"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " if [ ! -d $USB_MOUNT/backup/personal ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " if [ ! -d $USB_MOUNT/backup/personal ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/personal" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " mkdir -p $USB_MOUNT/backup/personal" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rsyncrypto -v -r /home/$MY_USERNAME/personal $USB_MOUNT/backup/personal $USB_MOUNT/backup/personal.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME echo -n ' rsyncrypto -v -r /home/$MY_USERNAME/personal ' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "$USB_MOUNT/backup/personal $USB_MOUNT/backup/personal.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2329,12 +2337,13 @@ function create_backup_script {
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup gpg keys' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '# Backup gpg keys' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ -d /home/$MY_USERNAME/.gnupg ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo 'if [ -d /home/$MY_USERNAME/.gnupg ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up gpg keys"' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' echo "Backing up gpg keys"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " if [ ! -d $USB_MOUNT/backup/gnupg ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " if [ ! -d $USB_MOUNT/backup/gnupg ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/gnupg" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " mkdir -p $USB_MOUNT/backup/gnupg" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rsyncrypto -v -r /home/$MY_USERNAME/.gnupg $USB_MOUNT/backup/gnupg $USB_MOUNT/backup/gnupg.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME echo -n ' rsyncrypto -v -r /home/$MY_USERNAME/.gnupg ' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "$USB_MOUNT/backup/gnupg $USB_MOUNT/backup/gnupg.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2344,12 +2353,13 @@ function create_backup_script {
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup ssh keys' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '# Backup ssh keys' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ -d /home/$MY_USERNAME/.ssh ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo 'if [ -d /home/$MY_USERNAME/.ssh ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up ssh keys"' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' echo "Backing up ssh keys"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " if [ ! -d $USB_MOUNT/backup/ssh ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " if [ ! -d $USB_MOUNT/backup/ssh ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/ssh" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " mkdir -p $USB_MOUNT/backup/ssh" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rsyncrypto -v -r /home/$MY_USERNAME/.ssh $USB_MOUNT/backup/ssh $USB_MOUNT/backup/ssh.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME echo -n ' rsyncrypto -v -r /home/$MY_USERNAME/.ssh ' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "$USB_MOUNT/backup/ssh $USB_MOUNT/backup/ssh.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2374,78 +2384,82 @@ function create_backup_script {
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup README file' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '# Backup README file' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ -f /home/$MY_USERNAME/README ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo 'if [ -f /home/$MY_USERNAME/README ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up README"' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' echo "Backing up README"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " if [ ! -d $USB_MOUNT/backup/readme ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " if [ ! -d $USB_MOUNT/backup/readme ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/readme" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " mkdir -p $USB_MOUNT/backup/readme" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " if [ ! -d /home/$MY_USERNAME/tempbackup ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' if [ ! -d /home/$MY_USERNAME/tempbackup ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' mkdir -p /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " cp -f /home/$MY_USERNAME/README /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' cp -f /home/$MY_USERNAME/README /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rsyncrypto -v -r /home/$MY_USERNAME/tempbackup $USB_MOUNT/backup/readme $USB_MOUNT/backup/readme.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME echo -n ' rsyncrypto -v -r /home/$MY_USERNAME/tempbackup ' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "$USB_MOUNT/backup/readme $USB_MOUNT/backup/readme.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' rm -rf /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' exit 848' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' exit 848' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' rm -rf /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup Mutt settings' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '# Backup Mutt settings' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ -f /home/$MY_USERNAME/.muttrc ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo 'if [ -f /home/$MY_USERNAME/.muttrc ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up Mutt settings"' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' echo "Backing up Mutt settings"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " if [ ! -d /home/$MY_USERNAME/tempbackup ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' if [ ! -d /home/$MY_USERNAME/tempbackup ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' mkdir -p /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " cp /home/$MY_USERNAME/.muttrc /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' cp /home/$MY_USERNAME/.muttrc /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ -f /etc/Muttrc ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' if [ -f /etc/Muttrc ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " cp /etc/Muttrc /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' cp /etc/Muttrc /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " if [ ! -d $USB_MOUNT/backup/mutt ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " if [ ! -d $USB_MOUNT/backup/mutt ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/mutt" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " mkdir -p $USB_MOUNT/backup/mutt" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rsyncrypto -v -r /home/$MY_USERNAME/tempbackup $USB_MOUNT/backup/mutt $USB_MOUNT/backup/mutt.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME echo -n ' rsyncrypto -v -r /home/$MY_USERNAME/tempbackup ' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "$USB_MOUNT/backup/mutt $USB_MOUNT/backup/mutt.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' rm -rf /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' exit 492' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' exit 492' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' rm -rf /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup procmail settings' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '# Backup procmail settings' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ -f /home/$MY_USERNAME/.procmailrc ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo 'if [ -f /home/$MY_USERNAME/.procmailrc ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up procmail settings"' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' echo "Backing up procmail settings"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " if [ ! -d /home/$MY_USERNAME/tempbackup ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' if [ ! -d /home/$MY_USERNAME/tempbackup ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' mkdir -p /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " cp /home/$MY_USERNAME/.procmailrc /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' cp /home/$MY_USERNAME/.procmailrc /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " if [ ! -d $USB_MOUNT/backup/procmail ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " if [ ! -d $USB_MOUNT/backup/procmail ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/procmail" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " mkdir -p $USB_MOUNT/backup/procmail" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rsyncrypto -v -r /home/$MY_USERNAME/tempbackup $USB_MOUNT/backup/procmail $USB_MOUNT/backup/procmail.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME echo -n ' rsyncrypto -v -r /home/$MY_USERNAME/tempbackup ' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "$USB_MOUNT/backup/procmail $USB_MOUNT/backup/procmail.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' rm -rf /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' exit 492' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' exit 492' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' rm -rf /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup spamassassin settings' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '# Backup spamassassin settings' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ -d /home/$MY_USERNAME/.spamassassin ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo 'if [ -d /home/$MY_USERNAME/.spamassassin ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up spamassassin settings"' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' echo "Backing up spamassassin settings"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " if [ ! -d $USB_MOUNT/backup/spamassassin ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " if [ ! -d $USB_MOUNT/backup/spamassassin ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/spamassassin" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " mkdir -p $USB_MOUNT/backup/spamassassin" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rsyncrypto -v -r /home/$MY_USERNAME/.spamassassin $USB_MOUNT/backup/spamassassin $USB_MOUNT/backup/spamassassin.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME echo -n ' rsyncrypto -v -r /home/$MY_USERNAME/.spamassassin ' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "$USB_MOUNT/backup/spamassassin $USB_MOUNT/backup/spamassassin.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2455,12 +2469,12 @@ function create_backup_script {
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '# Backup email' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '# Backup email' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ -d /home/$MY_USERNAME/Maildir ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo 'if [ -d /home/$MY_USERNAME/Maildir ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Creating an email archive"' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' echo "Creating an email archive"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! -d /root/backupemail ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' if [ ! -d /root/backupemail ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p /root/backupemail" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " mkdir -p /root/backupemail" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " tar -czvf /root/backupemail/maildir.tar.gz /home/$MY_USERNAME/Maildir" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' tar -czvf /root/backupemail/maildir.tar.gz /home/$MY_USERNAME/Maildir' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up emails"' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' echo "Backing up emails"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " if [ ! -d $USB_MOUNT/backup/mail ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " if [ ! -d $USB_MOUNT/backup/mail ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/mail" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " mkdir -p $USB_MOUNT/backup/mail" >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2494,22 +2508,25 @@ function create_backup_script {
echo '# Backup VoIP settings' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '# Backup VoIP settings' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "if [ -f /etc/$VOIP_CONFIG_FILE ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo "if [ -f /etc/$VOIP_CONFIG_FILE ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' echo "Backing up VoIP settings"' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' echo "Backing up VoIP settings"' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " if [ ! -d /home/$MY_USERNAME/tempbackup ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' if [ ! -d /home/$MY_USERNAME/tempbackup ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' mkdir -p /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " cp -f /etc/$VOIP_CONFIG_FILE /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo -n " cp -f /etc/$VOIP_CONFIG_FILE " >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " cp -f /var/lib/mumble-server/$VOIP_DATABASE /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo '/home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo -n " cp -f /var/lib/mumble-server/$VOIP_DATABASE " >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '/home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " if [ ! -d $USB_MOUNT/backup/voip ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " if [ ! -d $USB_MOUNT/backup/voip ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " mkdir -p $USB_MOUNT/backup/voip" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " mkdir -p $USB_MOUNT/backup/voip" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rsyncrypto -v -r /home/$MY_USERNAME/tempbackup $USB_MOUNT/backup/voip $USB_MOUNT/backup/voip.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME echo -n ' rsyncrypto -v -r /home/$MY_USERNAME/tempbackup ' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "$USB_MOUNT/backup/voip $USB_MOUNT/backup/voip.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' rm -rf /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' exit 2492' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' exit 2492' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_SCRIPT_NAME echo ' rm -rf /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
@ -2603,6 +2620,12 @@ function create_restore_script {
echo ' USB_DRIVE=/dev/${1}1' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' USB_DRIVE=/dev/${1}1' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo "ADMIN_USERNAME=$MY_USERNAME" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo "MY_USERNAME=$MY_USERNAME" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'if [ $2 ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' MY_USERNAME=$2' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'if [ ! -b $USB_DRIVE ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo 'if [ ! -b $USB_DRIVE ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Please attach a USB drive"' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Please attach a USB drive"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 1' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' exit 1' >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -2630,8 +2653,8 @@ function create_restore_script {
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'echo "Checking that user exists"' >> /usr/bin/$RESTORE_SCRIPT_NAME echo 'echo "Checking that user exists"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo "if [ ! -d /home/$MY_USERNAME ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo 'if [ ! -d /home/$MY_USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " echo 'Username $MY_USERNAME not found. Reinstall Freedombone with this username.'" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Username $MY_USERNAME not found. Reinstall Freedombone with this username."' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' exit 295' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' exit 295' >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -2639,7 +2662,7 @@ function create_restore_script {
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'echo "Copying GPG keys to root"' >> /usr/bin/$RESTORE_SCRIPT_NAME echo 'echo "Copying GPG keys to root"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo "cp -r /home/$MY_USERNAME/.gnupg /root" >> /usr/bin/$RESTORE_SCRIPT_NAME echo 'cp -r /home/$MY_USERNAME/.gnupg /root' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo "if [ -f $USB_MOUNT/backup/key.gpg ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo "if [ -f $USB_MOUNT/backup/key.gpg ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -2677,9 +2700,9 @@ function create_restore_script {
echo '# Make a backup of the original README file' >> /usr/bin/$RESTORE_SCRIPT_NAME echo '# Make a backup of the original README file' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '# incase old passwords need to be used' >> /usr/bin/$RESTORE_SCRIPT_NAME echo '# incase old passwords need to be used' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo "if [ -f /home/$MY_USERNAME/README ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo 'if [ -f /home/$MY_USERNAME/README ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " if [ ! -f /home/$MY_USERNAME/README_original ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! -f /home/$MY_USERNAME/README_original ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " cp /home/$MY_USERNAME/README /home/$MY_USERNAME/README_original" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' cp /home/$MY_USERNAME/README /home/$MY_USERNAME/README_original' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -2730,11 +2753,11 @@ function create_restore_script {
echo ' echo "Restoring Mutt settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring Mutt settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mkdir /root/tempmutt' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' mkdir /root/tempmutt' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rsyncrypto -v -d -r $USB_MOUNT/backup/mutt /root/tempmutt $USB_MOUNT/backup/mutt.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rsyncrypto -v -d -r $USB_MOUNT/backup/mutt /root/tempmutt $USB_MOUNT/backup/mutt.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " if [ -f /root/tempmutt/usb/backup/mutt/$MY_USERNAME/tempbackup/.muttrc ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ -f /root/tempmutt/usb/backup/mutt/$MY_USERNAME/tempbackup/.muttrc ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " cp -f /root/tempmutt/usb/backup/mutt/$MY_USERNAME/tempbackup/.muttrc /home/$MY_USERNAME/.muttrc" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' cp -f /root/tempmutt/usb/backup/mutt/$MY_USERNAME/tempbackup/.muttrc /home/$MY_USERNAME/.muttrc' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " if [ -f /root/tempmutt/usb/backup/mutt/$MY_USERNAME/tempbackup/Muttrc ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ -f /root/tempmutt/usb/backup/mutt/$MY_USERNAME/tempbackup/Muttrc ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " cp -f /root/tempmutt/usb/backup/mutt/$MY_USERNAME/tempbackup/Muttrc /etc/Muttrc" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' cp -f /root/tempmutt/usb/backup/mutt/$MY_USERNAME/tempbackup/Muttrc /etc/Muttrc' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -2750,7 +2773,7 @@ function create_restore_script {
echo ' echo "Restoring gnupg settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring gnupg settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mkdir /root/tempgnupg' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' mkdir /root/tempgnupg' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rsyncrypto -v -d -r $USB_MOUNT/backup/gnupg /root/tempgnupg $USB_MOUNT/backup/gnupg.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rsyncrypto -v -d -r $USB_MOUNT/backup/gnupg /root/tempgnupg $USB_MOUNT/backup/gnupg.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " cp -r /root/tempgnupg/usb/backup/gnupg/$MY_USERNAME/.gnupg /home/$MY_USERNAME/" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' cp -r /root/tempgnupg/usb/backup/gnupg/$MY_USERNAME/.gnupg /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -2758,7 +2781,7 @@ function create_restore_script {
echo ' exit 276' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' exit 276' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' rm -rf /root/tempgnupg' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' rm -rf /root/tempgnupg' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " cp -r /home/$MY_USERNAME/.gnupg /root" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' cp -r /home/$MY_USERNAME/.gnupg /root' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -2771,7 +2794,7 @@ function create_restore_script {
echo ' echo "Restoring procmail settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring procmail settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mkdir /root/tempprocmail' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' mkdir /root/tempprocmail' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rsyncrypto -v -d -r $USB_MOUNT/backup/procmail /root/tempprocmail $USB_MOUNT/backup/procmail.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rsyncrypto -v -d -r $USB_MOUNT/backup/procmail /root/tempprocmail $USB_MOUNT/backup/procmail.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " cp -f /root/tempprocmail/usb/backup/procmail/$MY_USERNAME/tempbackup/.procmailrc /home/$MY_USERNAME/" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' cp -f /root/tempprocmail/usb/backup/procmail/$MY_USERNAME/tempbackup/.procmailrc /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -2786,7 +2809,7 @@ function create_restore_script {
echo ' echo "Restoring spamassassin settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring spamassassin settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mkdir /root/tempspamassassin' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' mkdir /root/tempspamassassin' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rsyncrypto -v -d -r $USB_MOUNT/backup/spamassassin /root/tempspamassassin $USB_MOUNT/backup/spamassassin.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rsyncrypto -v -d -r $USB_MOUNT/backup/spamassassin /root/tempspamassassin $USB_MOUNT/backup/spamassassin.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " cp -rf /root/tempspamassassin/usb/backup/spamassassin/$MY_USERNAME/.spamassassin /home/$MY_USERNAME/" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' cp -rf /root/tempspamassassin/usb/backup/spamassassin/$MY_USERNAME/.spamassassin /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -2801,7 +2824,7 @@ function create_restore_script {
echo ' echo "Restoring README"' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring README"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mkdir /root/tempreadme' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' mkdir /root/tempreadme' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rsyncrypto -v -d -r $USB_MOUNT/backup/readme /root/tempreadme $USB_MOUNT/backup/readme.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rsyncrypto -v -d -r $USB_MOUNT/backup/readme /root/tempreadme $USB_MOUNT/backup/readme.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " cp -f /root/tempreadme/usb/backup/readme/$MY_USERNAME/tempbackup/README /home/$MY_USERNAME/" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' cp -f /root/tempreadme/usb/backup/readme/$MY_USERNAME/tempbackup/README /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -2816,7 +2839,7 @@ function create_restore_script {
echo ' echo "Restoring ssh keys"' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring ssh keys"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mkdir /root/tempssh' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' mkdir /root/tempssh' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rsyncrypto -v -d -r $USB_MOUNT/backup/ssh /root/tempssh $USB_MOUNT/backup/ssh.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rsyncrypto -v -d -r $USB_MOUNT/backup/ssh /root/tempssh $USB_MOUNT/backup/ssh.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " cp -r /root/tempssh/usb/backup/ssh/$MY_USERNAME/.ssh /home/$MY_USERNAME/" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' cp -r /root/tempssh/usb/backup/ssh/$MY_USERNAME/.ssh /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -2845,10 +2868,10 @@ function create_restore_script {
echo ' echo "Restoring projects"' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring projects"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mkdir /root/tempprojects' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' mkdir /root/tempprojects' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rsyncrypto -v -d -r $USB_MOUNT/backup/projects /root/tempprojects $USB_MOUNT/backup/projects.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rsyncrypto -v -d -r $USB_MOUNT/backup/projects /root/tempprojects $USB_MOUNT/backup/projects.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " if [ -d /home/$MY_USERNAME/projects ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ -d /home/$MY_USERNAME/projects ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf /home/$MY_USERNAME/projects" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' rm -rf /home/$MY_USERNAME/projects' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " mv /root/tempprojects/usb/backup/projects/$MY_USERNAME/projects /home/$MY_USERNAME" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' mv /root/tempprojects/usb/backup/projects/$MY_USERNAME/projects /home/$MY_USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -2862,10 +2885,10 @@ function create_restore_script {
echo ' echo "Restoring personal settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring personal settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mkdir /root/temppersonal' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' mkdir /root/temppersonal' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rsyncrypto -v -d -r $USB_MOUNT/backup/personal /root/temppersonal $USB_MOUNT/backup/personal.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rsyncrypto -v -d -r $USB_MOUNT/backup/personal /root/temppersonal $USB_MOUNT/backup/personal.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " if [ -d /home/$MY_USERNAME/personal ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ -d /home/$MY_USERNAME/personal ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf /home/$MY_USERNAME/personal" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' rm -rf /home/$MY_USERNAME/personal' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " mv /root/temppersonal/usb/backup/personal/$MY_USERNAME/personal /home/$MY_USERNAME" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' mv /root/temppersonal/usb/backup/personal/$MY_USERNAME/personal /home/$MY_USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -3052,7 +3075,7 @@ function create_restore_script {
echo ' chown -R www-data:www-data /var/lib/owncloud/data' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' chown -R www-data:www-data /var/lib/owncloud/data' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' chown -R www-data:www-data /var/lib/owncloud/backup' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' chown -R www-data:www-data /var/lib/owncloud/backup' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' chown -R www-data:www-data /var/lib/owncloud/assets' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' chown -R www-data:www-data /var/lib/owncloud/assets' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " occ files:scan $MY_USERNAME" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' occ files:scan $MY_USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' # Ensure that the bundled SSL cert is being used' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' # Ensure that the bundled SSL cert is being used' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " if [ -f /etc/ssl/certs/$OWNCLOUD_DOMAIN_NAME.bundle.crt ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " if [ -f /etc/ssl/certs/$OWNCLOUD_DOMAIN_NAME.bundle.crt ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " sed -i 's|$OWNCLOUD_DOMAIN_NAME.crt|$OWNCLOUD_DOMAIN_NAME.bundle.crt|g' /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " sed -i 's|$OWNCLOUD_DOMAIN_NAME.crt|$OWNCLOUD_DOMAIN_NAME.bundle.crt|g' /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME" >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -3208,8 +3231,8 @@ function create_restore_script {
echo ' echo "Restoring emails"' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring emails"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mkdir /root/tempmail' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' mkdir /root/tempmail' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rsyncrypto -v -d -r $USB_MOUNT/backup/mail /root/tempmail $USB_MOUNT/backup/mail.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rsyncrypto -v -d -r $USB_MOUNT/backup/mail /root/tempmail $USB_MOUNT/backup/mail.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " if [ ! -d /home/$MY_USERNAME/Maildir ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! -d /home/$MY_USERNAME/Maildir ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " mkdir /home/$MY_USERNAME/Maildir" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' mkdir /home/$MY_USERNAME/Maildir' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' tar -xzvf /root/tempmail/usb/backup/mail/backupemail/maildir.tar.gz -C /' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' tar -xzvf /root/tempmail/usb/backup/mail/backupemail/maildir.tar.gz -C /' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -3241,8 +3264,10 @@ function create_restore_script {
echo ' echo "Restoring VoIP settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' echo "Restoring VoIP settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' mkdir /root/tempvoip' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' mkdir /root/tempvoip' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rsyncrypto -v -d -r $USB_MOUNT/backup/voip /root/tempvoip $USB_MOUNT/backup/voip.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rsyncrypto -v -d -r $USB_MOUNT/backup/voip /root/tempvoip $USB_MOUNT/backup/voip.keys $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " cp -f /root/tempvoip/usb/backup/voip/$MY_USERNAME/tempbackup/$VOIP_CONFIG_FILE /etc/" >> /usr/bin/$RESTORE_SCRIPT_NAME echo -n ' cp -f /root/tempvoip/usb/backup/voip/$MY_USERNAME/tempbackup/' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " cp -f /root/tempvoip/usb/backup/voip/$MY_USERNAME/tempbackup/$VOIP_DATABASE /var/lib/mumble-server/" >> /usr/bin/$RESTORE_SCRIPT_NAME echo "$VOIP_CONFIG_FILE /etc/" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n ' cp -f /root/tempvoip/usb/backup/voip/$MY_USERNAME/tempbackup/' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo "$VOIP_DATABASE /var/lib/mumble-server/" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " umount $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME echo " rm -rf $USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -3285,7 +3310,7 @@ function create_restore_script {
fi fi
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'echo "Setting permissions"' >> /usr/bin/$RESTORE_SCRIPT_NAME echo 'echo "Setting permissions"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo "chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME" >> /usr/bin/$RESTORE_SCRIPT_NAME echo 'chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo 'if [[ $USB_DRIVE == /dev/mapper/encrypted_usb ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME echo 'if [[ $USB_DRIVE == /dev/mapper/encrypted_usb ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -3419,6 +3444,8 @@ function backup_to_friends_servers {
echo '# Temporary location for data to be backed up to other servers' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '# Temporary location for data to be backed up to other servers' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'SERVER_DIRECTORY=/root/remotebackup' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo 'SERVER_DIRECTORY=/root/remotebackup' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "MY_USERNAME=$MY_USERNAME" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "if [ ! -f $BACKUP_CERTIFICATE ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo "if [ ! -f $BACKUP_CERTIFICATE ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' echo "Creating backup key"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' echo "Creating backup key"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
@ -3750,12 +3777,12 @@ function backup_to_friends_servers {
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '# Backup projects' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '# Backup projects' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "if [ -d /home/$MY_USERNAME/projects ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo 'if [ -d /home/$MY_USERNAME/projects ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' echo "Backing up projects"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' echo "Backing up projects"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! -d $SERVER_DIRECTORY/backup/projects ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! -d $SERVER_DIRECTORY/backup/projects ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' mkdir -p $SERVER_DIRECTORY/backup/projects' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' mkdir -p $SERVER_DIRECTORY/backup/projects' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n " rsyncrypto -v -r /home/$MY_USERNAME/projects " >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n ' rsyncrypto -v -r /home/$MY_USERNAME/projects ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n '$SERVER_DIRECTORY/backup/projects $SERVER_DIRECTORY/backup/projects.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n '$SERVER_DIRECTORY/backup/projects $SERVER_DIRECTORY/backup/projects.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
@ -3768,12 +3795,12 @@ function backup_to_friends_servers {
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '# Backup personal settings' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '# Backup personal settings' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "if [ -d /home/$MY_USERNAME/personal ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo 'if [ -d /home/$MY_USERNAME/personal ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' echo "Backing up personal settings"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' echo "Backing up personal settings"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! -d $SERVER_DIRECTORY/backup/personal ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! -d $SERVER_DIRECTORY/backup/personal ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' mkdir -p $SERVER_DIRECTORY/backup/personal' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' mkdir -p $SERVER_DIRECTORY/backup/personal' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n " rsyncrypto -v -r /home/$MY_USERNAME/personal " >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n ' rsyncrypto -v -r /home/$MY_USERNAME/personal ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n '$SERVER_DIRECTORY/backup/personal $SERVER_DIRECTORY/backup/personal.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n '$SERVER_DIRECTORY/backup/personal $SERVER_DIRECTORY/backup/personal.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
@ -3822,12 +3849,12 @@ function backup_to_friends_servers {
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '# Backup gpg keys' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '# Backup gpg keys' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "if [ -d /home/$MY_USERNAME/.gnupg ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo 'if [ -d /home/$MY_USERNAME/.gnupg ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' echo "Backing up gpg keys"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' echo "Backing up gpg keys"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! -d $SERVER_DIRECTORY/backup/gnupg ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! -d $SERVER_DIRECTORY/backup/gnupg ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' mkdir -p $SERVER_DIRECTORY/backup/gnupg' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' mkdir -p $SERVER_DIRECTORY/backup/gnupg' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n " rsyncrypto -v -r /home/$MY_USERNAME/.gnupg " >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n ' rsyncrypto -v -r /home/$MY_USERNAME/.gnupg ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n '$SERVER_DIRECTORY/backup/gnupg $SERVER_DIRECTORY/backup/gnupg.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n '$SERVER_DIRECTORY/backup/gnupg $SERVER_DIRECTORY/backup/gnupg.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
@ -3840,12 +3867,12 @@ function backup_to_friends_servers {
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '# Backup ssh keys' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '# Backup ssh keys' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "if [ -d /home/$MY_USERNAME/.ssh ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo 'if [ -d /home/$MY_USERNAME/.ssh ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' echo "Backing up ssh keys"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' echo "Backing up ssh keys"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! -d $SERVER_DIRECTORY/backup/ssh ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! -d $SERVER_DIRECTORY/backup/ssh ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' mkdir -p $SERVER_DIRECTORY/backup/ssh' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' mkdir -p $SERVER_DIRECTORY/backup/ssh' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n " rsyncrypto -v -r /home/$MY_USERNAME/.ssh " >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n ' rsyncrypto -v -r /home/$MY_USERNAME/.ssh ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n '$SERVER_DIRECTORY/backup/ssh $SERVER_DIRECTORY/backup/ssh.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n '$SERVER_DIRECTORY/backup/ssh $SERVER_DIRECTORY/backup/ssh.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
@ -3872,43 +3899,43 @@ function backup_to_friends_servers {
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '# Backup README file' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '# Backup README file' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "if [ -f /home/$MY_USERNAME/README ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo 'if [ -f /home/$MY_USERNAME/README ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' echo "Backing up README"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' echo "Backing up README"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! -d $SERVER_DIRECTORY/backup/readme ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! -d $SERVER_DIRECTORY/backup/readme ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' mkdir -p $SERVER_DIRECTORY/backup/readme' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' mkdir -p $SERVER_DIRECTORY/backup/readme' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " if [ ! -d /home/$MY_USERNAME/tempbackup ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! -d /home/$MY_USERNAME/tempbackup ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " mkdir -p /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' mkdir -p /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " cp -f /home/$MY_USERNAME/README /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' cp -f /home/$MY_USERNAME/README /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n " rsyncrypto -v -r /home/$MY_USERNAME/tempbackup " >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n ' rsyncrypto -v -r /home/$MY_USERNAME/tempbackup ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n '$SERVER_DIRECTORY/backup/readme $SERVER_DIRECTORY/backup/readme.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n '$SERVER_DIRECTORY/backup/readme $SERVER_DIRECTORY/backup/readme.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " rm -rf /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' rm -rf /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' # Send a warning email' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' # Send a warning email' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n ' echo "Unable to encrypt README file" | mail -s "Freedombone backup to friends" ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n ' echo "Unable to encrypt README file" | mail -s "Freedombone backup to friends" ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "$MY_EMAIL_ADDRESS" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo "$MY_EMAIL_ADDRESS" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' exit 848' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' exit 848' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " rm -rf /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' rm -rf /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo 'fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '# Backup Mutt settings' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '# Backup Mutt settings' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "if [ -f /home/$MY_USERNAME/.muttrc ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo 'if [ -f /home/$MY_USERNAME/.muttrc ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' echo "Backing up Mutt settings"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' echo "Backing up Mutt settings"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " if [ ! -d /home/$MY_USERNAME/tempbackup ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! -d /home/$MY_USERNAME/tempbackup ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " mkdir -p /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' mkdir -p /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " cp /home/$MY_USERNAME/.muttrc /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' cp /home/$MY_USERNAME/.muttrc /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ -f /etc/Muttrc ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ -f /etc/Muttrc ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " cp /etc/Muttrc /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' cp /etc/Muttrc /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! -d $SERVER_DIRECTORY/backup/mutt ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! -d $SERVER_DIRECTORY/backup/mutt ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' mkdir -p $SERVER_DIRECTORY/backup/mutt' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' mkdir -p $SERVER_DIRECTORY/backup/mutt' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n " rsyncrypto -v -r /home/$MY_USERNAME/tempbackup " >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n ' rsyncrypto -v -r /home/$MY_USERNAME/tempbackup ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n '$SERVER_DIRECTORY/backup/mutt $SERVER_DIRECTORY/backup/mutt.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n '$SERVER_DIRECTORY/backup/mutt $SERVER_DIRECTORY/backup/mutt.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
@ -3923,16 +3950,16 @@ function backup_to_friends_servers {
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '# Backup procmail settings' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '# Backup procmail settings' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "if [ -f /home/$MY_USERNAME/.procmailrc ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo 'if [ -f /home/$MY_USERNAME/.procmailrc ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' echo "Backing up procmail settings"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' echo "Backing up procmail settings"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " if [ ! -d /home/$MY_USERNAME/tempbackup ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! -d /home/$MY_USERNAME/tempbackup ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " mkdir -p /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' mkdir -p /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " cp /home/$MY_USERNAME/.procmailrc /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' cp /home/$MY_USERNAME/.procmailrc /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! -d $SERVER_DIRECTORY/backup/procmail ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! -d $SERVER_DIRECTORY/backup/procmail ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' mkdir -p $SERVER_DIRECTORY/backup/procmail' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' mkdir -p $SERVER_DIRECTORY/backup/procmail' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n " rsyncrypto -v -r /home/$MY_USERNAME/tempbackup " >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n ' rsyncrypto -v -r /home/$MY_USERNAME/tempbackup ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n '$SERVER_DIRECTORY/backup/procmail $SERVER_DIRECTORY/backup/procmail.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n '$SERVER_DIRECTORY/backup/procmail $SERVER_DIRECTORY/backup/procmail.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
@ -3947,12 +3974,12 @@ function backup_to_friends_servers {
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '# Backup spamassassin settings' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '# Backup spamassassin settings' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "if [ -d /home/$MY_USERNAME/.spamassassin ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo 'if [ -d /home/$MY_USERNAME/.spamassassin ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' echo "Backing up spamassassin settings"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' echo "Backing up spamassassin settings"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! -d $SERVER_DIRECTORY/backup/spamassassin ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! -d $SERVER_DIRECTORY/backup/spamassassin ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' mkdir -p $SERVER_DIRECTORY/backup/spamassassin' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' mkdir -p $SERVER_DIRECTORY/backup/spamassassin' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n " rsyncrypto -v -r /home/$MY_USERNAME/.spamassassin " >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n ' rsyncrypto -v -r /home/$MY_USERNAME/.spamassassin ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n '$SERVER_DIRECTORY/backup/spamassassin $SERVER_DIRECTORY/backup/spamassassin.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n '$SERVER_DIRECTORY/backup/spamassassin $SERVER_DIRECTORY/backup/spamassassin.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
@ -3965,12 +3992,12 @@ function backup_to_friends_servers {
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '# Backup email' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '# Backup email' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "if [ -d /home/$MY_USERNAME/Maildir ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo 'if [ -d /home/$MY_USERNAME/Maildir ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' echo "Creating an email archive"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' echo "Creating an email archive"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! -d /root/backupemail ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! -d /root/backupemail ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " mkdir -p /root/backupemail" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo " mkdir -p /root/backupemail" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " tar -czvf /root/backupemail/maildir.tar.gz /home/$MY_USERNAME/Maildir" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' tar -czvf /root/backupemail/maildir.tar.gz /home/$MY_USERNAME/Maildir' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' echo "Backing up emails"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' echo "Backing up emails"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! -d $SERVER_DIRECTORY/backup/mail ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! -d $SERVER_DIRECTORY/backup/mail ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' mkdir -p $SERVER_DIRECTORY/backup/mail' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' mkdir -p $SERVER_DIRECTORY/backup/mail' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
@ -4007,15 +4034,17 @@ function backup_to_friends_servers {
echo '# Backup VoIP settings' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '# Backup VoIP settings' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "if [ -f /etc/$VOIP_CONFIG_FILE ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo "if [ -f /etc/$VOIP_CONFIG_FILE ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' echo "Backing up VoIP settings"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' echo "Backing up VoIP settings"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " if [ ! -d /home/$MY_USERNAME/tempbackup ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! -d /home/$MY_USERNAME/tempbackup ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " mkdir -p /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' mkdir -p /home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " cp -f /etc/$VOIP_CONFIG_FILE /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n " cp -f /etc/$VOIP_CONFIG_FILE " >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " cp -f /var/lib/mumble-server/$VOIP_DATABASE /home/$MY_USERNAME/tempbackup" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '/home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n " cp -f /var/lib/mumble-server/$VOIP_DATABASE " >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '/home/$MY_USERNAME/tempbackup' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! -d $SERVER_DIRECTORY/backup/voip ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! -d $SERVER_DIRECTORY/backup/voip ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' mkdir -p $SERVER_DIRECTORY/backup/voip' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' mkdir -p $SERVER_DIRECTORY/backup/voip' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n " rsyncrypto -v -r /home/$MY_USERNAME/tempbackup " >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n ' rsyncrypto -v -r /home/$MY_USERNAME/tempbackup ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n '$SERVER_DIRECTORY/backup/voip $SERVER_DIRECTORY/backup/voip.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n '$SERVER_DIRECTORY/backup/voip $SERVER_DIRECTORY/backup/voip.keys ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
@ -4116,9 +4145,9 @@ function backup_to_friends_servers {
if [[ $ENABLE_SOCIAL_KEY_MANAGEMENT == "yes" ]]; then if [[ $ENABLE_SOCIAL_KEY_MANAGEMENT == "yes" ]]; then
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' # Social key management' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' # Social key management' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " if [ -d /home/$MY_USERNAME/.gnupg_fragments ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ -d /home/$MY_USERNAME/.gnupg_fragments ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ $REMOTE_DOMAIN ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ $REMOTE_DOMAIN ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " cd /home/$MY_USERNAME/.gnupg_fragments" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' cd /home/$MY_USERNAME/.gnupg_fragments' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' no_of_shares=$(ls -afq keyshare.asc.* | wc -l)' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' no_of_shares=$(ls -afq keyshare.asc.* | wc -l)' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if (( no_of_shares > 0 )); then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if (( no_of_shares > 0 )); then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' # Pick a share index based on the domain name' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' # Pick a share index based on the domain name' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
@ -4127,17 +4156,17 @@ function backup_to_friends_servers {
echo ' share_index=$(echo $((0x${sharenumstr%% *} % ${no_of_shares})) | tr -d -)' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' share_index=$(echo $((0x${sharenumstr%% *} % ${no_of_shares})) | tr -d -)' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' # get the share filename' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' # get the share filename' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " share_files=(/home/$MY_USERNAME/.gnupg_fragments/keyshare.asc.*)" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' share_files=(/home/$MY_USERNAME/.gnupg_fragments/keyshare.asc.*)' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' share_filename=${share_files[share_index]}' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' share_filename=${share_files[share_index]}' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' # create a temp directory containing the share' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' # create a temp directory containing the share' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " mkdir -p /home/$MY_USERNAME/tempkey/.gnupg_fragments" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' mkdir -p /home/$MY_USERNAME/tempkey/.gnupg_fragments' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " cp $share_filename /home/$MY_USERNAME/tempkey/.gnupg_fragments/" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' cp $share_filename /home/$MY_USERNAME/tempkey/.gnupg_fragments/' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' # copy the fragments directory to the remote server' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' # copy the fragments directory to the remote server' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n ' /usr/bin/sshpass -p $REMOTE_PASSWORD ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n ' /usr/bin/sshpass -p $REMOTE_PASSWORD ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n 'scp -r -P $REMOTE_SSH_PORT ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n 'scp -r -P $REMOTE_SSH_PORT ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n "/home/$MY_USERNAME/tempkey/.gnupg_fragments " >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n '/home/$MY_USERNAME/tempkey/.gnupg_fragments ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '$REMOTE_SERVER' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '$REMOTE_SERVER' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' # Send a warning email' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' # Send a warning email' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
@ -4146,8 +4175,8 @@ function backup_to_friends_servers {
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' # remove the temp file/directory' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' # remove the temp file/directory' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " shred -zu /home/$MY_USERNAME/tempkey/.gnupg_fragments/*" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' shred -zu /home/$MY_USERNAME/tempkey/.gnupg_fragments/*' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo " rm -rf /home/$MY_USERNAME/tempkey" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' rm -rf /home/$MY_USERNAME/tempkey' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo ' # Send a confirmation email' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo ' # Send a confirmation email' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
echo -n ' echo "Key shared to $REMOTE_SERVER" | mail -s "Freedombone social key management" ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME echo -n ' echo "Key shared to $REMOTE_SERVER" | mail -s "Freedombone social key management" ' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
@ -4218,6 +4247,8 @@ function restore_from_friend {
echo '#!/bin/bash' > /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo '#!/bin/bash' > /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo 'SERVER_NAME=$1' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo 'SERVER_NAME=$1' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo "MY_USERNAME=$MY_USERNAME" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo '# Temporary location for data to be backed up to other servers' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo '# Temporary location for data to be backed up to other servers' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo 'SERVER_DIRECTORY=/root/remoterestore' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo 'SERVER_DIRECTORY=/root/remoterestore' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
@ -4332,11 +4363,11 @@ function restore_from_friend {
echo ' mkdir /root/tempmutt' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' mkdir /root/tempmutt' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/mutt /root/tempmutt $SERVER_DIRECTORY/backup/mutt.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/mutt /root/tempmutt $SERVER_DIRECTORY/backup/mutt.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " if [ -f /root/tempmutt/remoterestore/backup/mutt/$MY_USERNAME/tempbackup/.muttrc ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' if [ -f /root/tempmutt/remoterestore/backup/mutt/$MY_USERNAME/tempbackup/.muttrc ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " cp -f /root/tempmutt/remoterestore/backup/mutt/$MY_USERNAME/tempbackup/.muttrc /home/$MY_USERNAME/.muttrc" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' cp -f /root/tempmutt/remoterestore/backup/mutt/$MY_USERNAME/tempbackup/.muttrc /home/$MY_USERNAME/.muttrc' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " if [ -f /root/tempmutt/remoterestore/backup/mutt/$MY_USERNAME/tempbackup/Muttrc ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' if [ -f /root/tempmutt/remoterestore/backup/mutt/$MY_USERNAME/tempbackup/Muttrc ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " cp -f /root/tempmutt/remoterestore/backup/mutt/$MY_USERNAME/tempbackup/Muttrc /etc/Muttrc" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' cp -f /root/tempmutt/remoterestore/backup/mutt/$MY_USERNAME/tempbackup/Muttrc /etc/Muttrc' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' rm -rf /root/tempmutt' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' rm -rf /root/tempmutt' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
@ -4351,13 +4382,13 @@ function restore_from_friend {
echo ' mkdir /root/tempgnupg' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' mkdir /root/tempgnupg' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/gnupg /root/tempgnupg $SERVER_DIRECTORY/backup/gnupg.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/gnupg /root/tempgnupg $SERVER_DIRECTORY/backup/gnupg.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " cp -r /root/tempgnupg/remoterestore/backup/gnupg/$MY_USERNAME/.gnupg /home/$MY_USERNAME/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' cp -r /root/tempgnupg/remoterestore/backup/gnupg/$MY_USERNAME/.gnupg /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' rm -rf /root/tempgnupg' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' rm -rf /root/tempgnupg' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' rm -rf /root/tempgnupg' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' rm -rf /root/tempgnupg' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " cp -r /home/$MY_USERNAME/.gnupg /root" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' cp -r /home/$MY_USERNAME/.gnupg /root' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' exit 283' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' exit 283' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
@ -4369,7 +4400,7 @@ function restore_from_friend {
echo ' mkdir /root/tempprocmail' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' mkdir /root/tempprocmail' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/procmail /root/tempprocmail $SERVER_DIRECTORY/backup/procmail.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/procmail /root/tempprocmail $SERVER_DIRECTORY/backup/procmail.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " cp -f /root/tempprocmail/remoterestore/backup/procmail/$MY_USERNAME/tempbackup/.procmailrc /home/$MY_USERNAME/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' cp -f /root/tempprocmail/remoterestore/backup/procmail/$MY_USERNAME/tempbackup/.procmailrc /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' rm -rf /root/tempprocmail' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' rm -rf /root/tempprocmail' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
@ -4383,7 +4414,7 @@ function restore_from_friend {
echo ' mkdir /root/tempspamassassin' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' mkdir /root/tempspamassassin' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/spamassassin /root/tempspamassassin $SERVER_DIRECTORY/backup/spamassassin.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/spamassassin /root/tempspamassassin $SERVER_DIRECTORY/backup/spamassassin.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " cp -rf /root/tempspamassassin/remoterestore/backup/spamassassin/$MY_USERNAME/.spamassassin /home/$MY_USERNAME/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' cp -rf /root/tempspamassassin/remoterestore/backup/spamassassin/$MY_USERNAME/.spamassassin /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' rm -rf /root/tempspamassassin' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' rm -rf /root/tempspamassassin' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
@ -4397,7 +4428,7 @@ function restore_from_friend {
echo ' mkdir /root/tempreadme' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' mkdir /root/tempreadme' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/readme /root/tempreadme $SERVER_DIRECTORY/backup/readme.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/readme /root/tempreadme $SERVER_DIRECTORY/backup/readme.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " cp -f /root/tempreadme/remoterestore/backup/readme/$MY_USERNAME/tempbackup/README /home/$MY_USERNAME/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' cp -f /root/tempreadme/remoterestore/backup/readme/$MY_USERNAME/tempbackup/README /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' rm -rf /root/tempreadme' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' rm -rf /root/tempreadme' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
@ -4411,7 +4442,7 @@ function restore_from_friend {
echo ' mkdir /root/tempssh' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' mkdir /root/tempssh' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/ssh /root/tempssh $SERVER_DIRECTORY/backup/ssh.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/ssh /root/tempssh $SERVER_DIRECTORY/backup/ssh.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " cp -r /root/tempssh/remoterestore/backup/ssh/$MY_USERNAME/.ssh /home/$MY_USERNAME/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' cp -r /root/tempssh/remoterestore/backup/ssh/$MY_USERNAME/.ssh /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' rm -rf /root/tempssh' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' rm -rf /root/tempssh' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' exit 664' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' exit 664' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
@ -4438,10 +4469,10 @@ function restore_from_friend {
echo ' mkdir /root/tempprojects' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' mkdir /root/tempprojects' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/projects /root/tempprojects $SERVER_DIRECTORY/backup/projects.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/projects /root/tempprojects $SERVER_DIRECTORY/backup/projects.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " if [ -d /home/$MY_USERNAME/projects ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' if [ -d /home/$MY_USERNAME/projects ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " rm -rf /home/$MY_USERNAME/projects" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' rm -rf /home/$MY_USERNAME/projects' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " mv /root/tempprojects/remoterestore/backup/projects/$MY_USERNAME/projects /home/$MY_USERNAME" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' mv /root/tempprojects/remoterestore/backup/projects/$MY_USERNAME/projects /home/$MY_USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' exit 166' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' exit 166' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
@ -4454,10 +4485,10 @@ function restore_from_friend {
echo ' mkdir /root/temppersonal' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' mkdir /root/temppersonal' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/personal /root/temppersonal $SERVER_DIRECTORY/backup/personal.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/personal /root/temppersonal $SERVER_DIRECTORY/backup/personal.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " if [ -d /home/$MY_USERNAME/personal ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' if [ -d /home/$MY_USERNAME/personal ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " rm -rf /home/$MY_USERNAME/personal" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' rm -rf /home/$MY_USERNAME/personal' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " mv /root/temppersonal/remoterestore/backup/personal/$MY_USERNAME/personal /home/$MY_USERNAME" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' mv /root/temppersonal/remoterestore/backup/personal/$MY_USERNAME/personal /home/$MY_USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' exit 184' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' exit 184' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
@ -4627,7 +4658,7 @@ function restore_from_friend {
echo ' chown -R www-data:www-data /var/lib/owncloud/data' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' chown -R www-data:www-data /var/lib/owncloud/data' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' chown -R www-data:www-data /var/lib/owncloud/backup' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' chown -R www-data:www-data /var/lib/owncloud/backup' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' chown -R www-data:www-data /var/lib/owncloud/assets' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' chown -R www-data:www-data /var/lib/owncloud/assets' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " occ files:scan $MY_USERNAME" >> /usr/bin/$RESTORE_SCRIPT_NAME echo ' occ files:scan $MY_USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' # Ensure that the bundled SSL cert is being used' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' # Ensure that the bundled SSL cert is being used' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " if [ -f /etc/ssl/certs/$OWNCLOUD_DOMAIN_NAME.bundle.crt ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo " if [ -f /etc/ssl/certs/$OWNCLOUD_DOMAIN_NAME.bundle.crt ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " sed -i 's|$OWNCLOUD_DOMAIN_NAME.crt|$OWNCLOUD_DOMAIN_NAME.bundle.crt|g' /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo " sed -i 's|$OWNCLOUD_DOMAIN_NAME.crt|$OWNCLOUD_DOMAIN_NAME.bundle.crt|g' /etc/nginx/sites-available/$OWNCLOUD_DOMAIN_NAME" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
@ -4771,8 +4802,10 @@ function restore_from_friend {
echo ' mkdir /root/tempvoip' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' mkdir /root/tempvoip' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/voip /root/tempvoip $SERVER_DIRECTORY/backup/voip.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/voip /root/tempvoip $SERVER_DIRECTORY/backup/voip.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " cp -f /root/tempvoip/remoterestore/backup/voip/$MY_USERNAME/tempbackup/$VOIP_CONFIG_FILE /etc/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo -n ' cp -f /root/tempvoip/remoterestore/backup/voip/$MY_USERNAME/tempbackup/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " cp -f /root/tempvoip/remoterestore/backup/voip/$MY_USERNAME/tempbackup/$VOIP_DATABASE /var/lib/mumble-server/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo "$VOIP_CONFIG_FILE /etc/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n ' cp -f /root/tempvoip/remoterestore/backup/voip/$MY_USERNAME/tempbackup/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo "$VOIP_DATABASE /var/lib/mumble-server/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' rm -rf /root/tempvoip' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' rm -rf /root/tempvoip' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' exit 276' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
@ -4802,8 +4835,8 @@ function restore_from_friend {
echo ' mkdir /root/tempmail' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' mkdir /root/tempmail' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/mail /root/tempmail $SERVER_DIRECTORY/backup/mail.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo -n ' rsyncrypto -v -d -r $SERVER_DIRECTORY/backup/mail /root/tempmail $SERVER_DIRECTORY/backup/mail.keys ' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo "$BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " if [ ! -d /home/$MY_USERNAME/Maildir ]; then" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' if [ ! -d /home/$MY_USERNAME/Maildir ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo " mkdir /home/$MY_USERNAME/Maildir" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' mkdir /home/$MY_USERNAME/Maildir' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' tar -xzvf /root/tempmail/usb/backup/mail/backupemail/maildir.tar.gz -C /' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' tar -xzvf /root/tempmail/usb/backup/mail/backupemail/maildir.tar.gz -C /' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
@ -4831,7 +4864,8 @@ function restore_from_friend {
echo '' >> /usr/bin/$RESTORE_FROM_FRIENDS_SCRIPT_NAME echo '' >> /usr/bin/$RESTORE_FROM_FRIENDS_SCRIPT_NAME
echo '# Retrieve key fragments' >> /usr/bin/$RESTORE_FROM_FRIENDS_SCRIPT_NAME echo '# Retrieve key fragments' >> /usr/bin/$RESTORE_FROM_FRIENDS_SCRIPT_NAME
echo -n '/usr/bin/sshpass -p $REMOTE_PASSWORD ' >> /usr/bin/$RESTORE_FROM_FRIENDS_SCRIPT_NAME echo -n '/usr/bin/sshpass -p $REMOTE_PASSWORD ' >> /usr/bin/$RESTORE_FROM_FRIENDS_SCRIPT_NAME
echo "scp -r -P $REMOTE_SSH_PORT $REMOTE_SERVER/.gnupg_fragments /home/$MY_USERNAME/" >> /usr/bin/$RESTORE_FROM_FRIENDS_SCRIPT_NAME echo -n "scp -r -P $REMOTE_SSH_PORT $REMOTE_SERVER/.gnupg_fragments " >> /usr/bin/$RESTORE_FROM_FRIENDS_SCRIPT_NAME
echo '/home/$MY_USERNAME/' >> /usr/bin/$RESTORE_FROM_FRIENDS_SCRIPT_NAME
fi fi
echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME