Restore command
This commit is contained in:
parent
002fdbaaa2
commit
ee51dfaf8e
2
Makefile
2
Makefile
|
@ -20,6 +20,7 @@ install:
|
||||||
install -m 755 src/${APP}-meshweb ${DESTDIR}${PREFIX}/bin/meshweb
|
install -m 755 src/${APP}-meshweb ${DESTDIR}${PREFIX}/bin/meshweb
|
||||||
install -m 755 src/${APP}-controlpanel ${DESTDIR}${PREFIX}/bin/control
|
install -m 755 src/${APP}-controlpanel ${DESTDIR}${PREFIX}/bin/control
|
||||||
install -m 755 src/${APP}-backup-local ${DESTDIR}${PREFIX}/bin/backup
|
install -m 755 src/${APP}-backup-local ${DESTDIR}${PREFIX}/bin/backup
|
||||||
|
install -m 755 src/${APP}-restore-local ${DESTDIR}${PREFIX}/bin/restore
|
||||||
mkdir -m 755 -p ${DESTDIR}${PREFIX}/share/man/man1
|
mkdir -m 755 -p ${DESTDIR}${PREFIX}/share/man/man1
|
||||||
install -m 644 man/*.1.gz ${DESTDIR}${PREFIX}/share/man/man1
|
install -m 644 man/*.1.gz ${DESTDIR}${PREFIX}/share/man/man1
|
||||||
bash -c "./translate install"
|
bash -c "./translate install"
|
||||||
|
@ -30,6 +31,7 @@ uninstall:
|
||||||
rm -f ${PREFIX}/bin/zeronetavahi
|
rm -f ${PREFIX}/bin/zeronetavahi
|
||||||
rm -f ${PREFIX}/bin/mesh
|
rm -f ${PREFIX}/bin/mesh
|
||||||
rm -f ${PREFIX}/bin/backup
|
rm -f ${PREFIX}/bin/backup
|
||||||
|
rm -f ${PREFIX}/bin/restore
|
||||||
rm -f ${PREFIX}/bin/meshweb
|
rm -f ${PREFIX}/bin/meshweb
|
||||||
rm -rf /etc/freedombone
|
rm -rf /etc/freedombone
|
||||||
bash -c "./translate uninstall"
|
bash -c "./translate uninstall"
|
||||||
|
|
Binary file not shown.
873
src/freedombone
873
src/freedombone
|
@ -2889,871 +2889,6 @@ function restore_database {
|
||||||
echo '}' >> $script_name
|
echo '}' >> $script_name
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_restore_script {
|
|
||||||
if grep -Fxq "create_restore_script" $COMPLETION_FILE; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
apt-get -y install rsyncrypto cryptsetup obnam
|
|
||||||
|
|
||||||
get_mariadb_password
|
|
||||||
get_mariadb_gnusocial_admin_password
|
|
||||||
get_mariadb_hubzilla_admin_password
|
|
||||||
get_mariadb_owncloud_admin_password
|
|
||||||
get_mariadb_git_admin_password
|
|
||||||
|
|
||||||
echo '#!/bin/bash' > /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo "COMPLETION_FILE=$COMPLETION_FILE" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo "USB_DRIVE=$USB_DRIVE" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'if [ $1 ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' USB_DRIVE=/dev/${1}1' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo "USB_MOUNT=$USB_MOUNT" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n 'ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | ' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n "awk -F ':' '{print " >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n '$2' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo "}')" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'MY_USERNAME=$ADMIN_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 ' echo "Please attach a USB drive"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' exit 1' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'if [ ! -d $USB_MOUNT ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' mkdir $USB_MOUNT' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ -f /dev/mapper/encrypted_usb ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /dev/mapper/encrypted_usb' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' cryptsetup luksClose encrypted_usb' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' cryptsetup luksOpen $USB_DRIVE encrypted_usb' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' USB_DRIVE=/dev/mapper/encrypted_usb' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n ' mount $USB_DRIVE ' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '$USB_MOUNT' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'if [ ! -d $USB_MOUNT/backup ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "No backup directory found on the USB drive."' >> /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 ' exit 2' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /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 ' 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 ' rm -rf $USB_MOUNT' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' exit 295' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /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 '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
echo '# MariaDB password' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n 'DATABASE_PASSWORD=$(cat ' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo "$DATABASE_PASSWORD_FILE)" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
restore_directory_from_usb /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
restore_database /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
echo 'if [ -f $USB_MOUNT/backup/key.gpg ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " if [ -f $BACKUP_CERTIFICATE.new ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " rm $BACKUP_CERTIFICATE.new" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' cp $USB_MOUNT/backup/key.gpg /root/tempbackupkey.gpg' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " gpg /root/tempbackupkey.gpg" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " if [ -f /root/tempbackupkey ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Backup key decrypted"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " cp /root/tempbackupkey $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " shred -zu /root/tempbackupkey" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " chmod 400 $BACKUP_CERTIFICATE" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Backup certificate installed"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' else' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Unable to decrypt the backup key"' >> /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 ' exit 735' >> /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 "if [ ! -f $BACKUP_CERTIFICATE ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " echo 'No backup key was found. Copy your backup key to $BACKUP_CERTIFICATE'" >> /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 ' exit 563' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
fi
|
|
||||||
|
|
||||||
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 '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 ' 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 '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
if [[ $BACKUP_INCLUDES_DATABASES == "yes" ]]; then
|
|
||||||
RESTORE_SUBDIR='root/'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/mariadb/'
|
|
||||||
fi
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/mariadb ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring mysql settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempmariadb mariadb' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Get the MariaDB password from the backup"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " if [ ! -f /root/tempmariadb/${RESTORE_SUBDIR}tempmariadb/db ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "MariaDB password file not found"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' exit 495' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n ' BACKUP_MARIADB_PASSWORD=$(cat /root/tempmariadb/' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo "${RESTORE_SUBDIR}tempmariadb/db)" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [[ $BACKUP_MARIADB_PASSWORD != $DATABASE_PASSWORD ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restore the MariaDB user table"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n ' mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD mysql -o < ' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo "/root/tempmariadb/${RESTORE_SUBDIR}tempmariadb/mysql.sql)" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Try again using the password obtained from backup"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n ' mysqlsuccess=$(mysql -u root --password=$BACKUP_MARIADB_PASSWORD mysql -o < ' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo "/root/tempmariadb/${RESTORE_SUBDIR}tempmariadb/mysql.sql)" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "$mysqlsuccess"' >> /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 ' exit 962' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restarting database"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' service mysql restart' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Change the MariaDB password to the backup version"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' DATABASE_PASSWORD=$BACKUP_MARIADB_PASSWORD' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " shred -zu /root/tempmariadb/${RESTORE_SUBDIR}tempmariadb/db" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempmariadb' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' # Change database password file' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n ' echo "$DATABASE_PASSWORD" > ' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo "$DATABASE_PASSWORD_FILE" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " chmod 600 $DATABASE_PASSWORD_FILE" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
fi
|
|
||||||
|
|
||||||
RESTORE_SUBDIR='home/'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/letsencrypt/'
|
|
||||||
fi
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/letsencrypt ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring Lets Encrypt settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb / letsencrypt' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
RESTORE_SUBDIR='home/'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/mutt/'
|
|
||||||
fi
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/mutt ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' for d in $USB_MOUNT/backup/mutt/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $6}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring Mutt settings for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempmutt mutt/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n " if [ -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '$USERNAME/tempbackup/.muttrc ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n " cp -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '$USERNAME/tempbackup/.muttrc /home/$USERNAME/.muttrc' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n " if [ -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '$USERNAME/tempbackup/Muttrc ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n " cp -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '$USERNAME/tempbackup/Muttrc /etc/Muttrc' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 /root/tempmutt' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' exit 276' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempmutt' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
RESTORE_SUBDIR='home/'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/gnupg/'
|
|
||||||
fi
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/gnupg ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' for d in $USB_MOUNT/backup/gnupg/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $6}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring gnupg settings for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempgnupg gnupg/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n " cp -r /root/tempgnupg/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '$USERNAME/.gnupg /home/$USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 /root/tempgnupg' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' exit 276' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempgnupg' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [[ "$USERNAME" == "$MY_USERNAME" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' cp -r /home/$USERNAME/.gnupg /root' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 ' exit 283' >> /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 ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
RESTORE_SUBDIR='home/'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/procmail/'
|
|
||||||
fi
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/procmail ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' for d in $USB_MOUNT/backup/procmail/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $6}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring procmail settings for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempprocmail procmail/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n " cp -f /root/tempprocmail/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '$USERNAME/tempbackup/.procmailrc /home/$USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 /root/tempprocmail' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' exit 276' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempprocmail' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
RESTORE_SUBDIR='home/'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/spamassassin/'
|
|
||||||
fi
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/spamassassin ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' for d in $USB_MOUNT/backup/spamassassin/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $6}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ -d $USB_MOUNT/backup/spamassassin/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring spamassassin settings for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempspamassassin spamassassin/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n " cp -rf /root/tempspamassassin/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '$USERNAME/.spamassassin /home/$USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 /root/tempspamassassin' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' exit 276' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempspamassassin' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
RESTORE_SUBDIR='home/'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/readme/'
|
|
||||||
fi
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/readme ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring README"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempreadme readme' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n " cp -f /root/tempreadme/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '$MY_USERNAME/tempbackup/README /home/$MY_USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 /root/tempreadme' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' exit 276' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempreadme' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
RESTORE_SUBDIR='home/'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/ipfs/'
|
|
||||||
fi
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/ipfs ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring IPFS"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempipfs ipfs' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n " cp -rf /root/tempipfs/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '$MY_USERNAME/.ipfs/* /home/$MY_USERNAME/.ipfs' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 /root/tempipfs' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' exit 276' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempipfs' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
RESTORE_SUBDIR='home/'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/ssh/'
|
|
||||||
fi
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/ssh ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' for d in $USB_MOUNT/backup/ssh/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $6}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring ssh keys for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempssh ssh/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n " cp -r /root/tempssh/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '$USERNAME/.ssh /home/$USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 /root/tempssh' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' exit 664' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempssh' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
RESTORE_SUBDIR='home/'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/config/'
|
|
||||||
fi
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/config ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' for d in $USB_MOUNT/backup/config/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $6}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring config files for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempconfig config/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n " cp -r /root/tempconfig/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '$USERNAME/.config /home/$USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 /root/tempconfig' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' exit 664' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempconfig' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
RESTORE_SUBDIR='etc/'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/ssl/'
|
|
||||||
fi
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/ssl ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring certificates"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' mkdir /root/tempssl' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempssl ssl' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " cp -r /root/tempssl/${RESTORE_SUBDIR}ssl/* /etc/ssl" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 ' exit 276' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempssl' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
RESTORE_SUBDIR='home/'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/projects/'
|
|
||||||
fi
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/projects ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' for d in $USB_MOUNT/backup/projects/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $6}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring projects for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempprojects projects/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ -d /home/$USERNAME/projects ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /home/$USERNAME/projects' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n " mv /root/tempprojects/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '$USERNAME/projects /home/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 ' exit 166' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempprojects' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
RESTORE_SUBDIR='home/'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/personal/'
|
|
||||||
fi
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/personal ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' for d in $USB_MOUNT/backup/personal/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $6}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ -d $USB_MOUNT/backup/personal/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring personal settings for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/temppersonal personal/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ -d /home/$USERNAME/personal ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /home/$USERNAME/personal' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n " mv /root/temppersonal/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '$USERNAME/personal /home/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 ' exit 184' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/temppersonal' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
RESTORE_SUBDIR='root/'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/mailinglist/'
|
|
||||||
fi
|
|
||||||
echo "if [ -d $PUBLIC_MAILING_LIST_DIRECTORY ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring public mailing list"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempmailinglist mailinglist' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " cp -r /root/tempmailinglist/${RESTORE_SUBDIR}spool/mlmmj/* $PUBLIC_MAILING_LIST_DIRECTORY" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 ' exit 526' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempmailinglist' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
RESTORE_SUBDIR='var/'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/xmpp/'
|
|
||||||
fi
|
|
||||||
echo "if [ -d $XMPP_DIRECTORY ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring XMPP settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempxmpp xmpp' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " cp -r /root/tempxmpp/${RESTORE_SUBDIR}lib/prosody/* $XMPP_DIRECTORY" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 ' exit 725' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempxmpp' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' service prosody restart' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' chown -R prosody:prosody /var/lib/prosody/*' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
BACKUP_INCLUDES_WEBSITES="no"
|
|
||||||
|
|
||||||
if grep -Fxq "install_gnu_social" $COMPLETION_FILE; then
|
|
||||||
BACKUP_INCLUDES_WEBSITES="yes"
|
|
||||||
echo "restore_database gnusocial $MICROBLOG_DOMAIN_NAME" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'if [ -d /root/tempgnusocial ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempgnusocial' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
fi
|
|
||||||
|
|
||||||
if grep -Fxq "install_hubzilla" $COMPLETION_FILE; then
|
|
||||||
BACKUP_INCLUDES_WEBSITES="yes"
|
|
||||||
echo "restore_database hubzilla $HUBZILLA_DOMAIN_NAME" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/hubzilla ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " if [ ! -d /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store/[data]/smarty3 ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " mkdir -p /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store/[data]/smarty3" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " fi" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " chmod 777 /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/store/[data]/smarty3" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " chown -R www-data:www-data /var/www/$HUBZILLA_DOMAIN_NAME/htdocs/*" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ -d /root/temphubzilla ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/temphubzilla' >> /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
|
|
||||||
fi
|
|
||||||
|
|
||||||
if grep -Fxq "install_owncloud" $COMPLETION_FILE; then
|
|
||||||
BACKUP_INCLUDES_WEBSITES="yes"
|
|
||||||
echo "restore_database owncloud $OWNCLOUD_DOMAIN_NAME" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/owncloud2 ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'restore_directory_from_usb /root/tempowncloud2 owncloud2' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
RESTORE_SUBDIR='etc/'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/owncloud2/'
|
|
||||||
fi
|
|
||||||
echo " cp -r /root/tempowncloud2/${RESTORE_SUBDIR}owncloud/* /etc/owncloud/" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 ' exit 982' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempowncloud' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempowncloud2' >> /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/assets' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' occ files:scan $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " ln -s /usr/share/owncloud /var/www/$OWNCLOUD_DOMAIN_NAME/htdocs" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
fi
|
|
||||||
|
|
||||||
if grep -Fxq "install_gogs" $COMPLETION_FILE; then
|
|
||||||
BACKUP_INCLUDES_WEBSITES="yes"
|
|
||||||
echo "restore_database gogs $GIT_DOMAIN_NAME" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
RESTORE_SUBDIR='home'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/gogs'
|
|
||||||
fi
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/gogs ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring Gogs settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! -d /home/git/go/src/github.com/gogits/gogs/custom ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' mkdir -p /home/git/go/src/github.com/gogits/gogs/custom' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " cp -r /root/tempgogs/${RESTORE_SUBDIR}/git/go/src/github.com/gogits/gogs/custom/* /home/git/go/src/github.com/gogits/gogs/custom" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 ' exit 981' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring Gogs repos"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'restore_directory_from_usb /root/tempgogsrepos gogsrepos' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/gogsrepos'
|
|
||||||
fi
|
|
||||||
echo " cp -r /root/tempgogsrepos/${RESTORE_SUBDIR}/git/gogs-repositories/* /home/git/gogs-repositories/" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 ' exit 67574' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring Gogs authorized_keys"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempgogsssh gogsssh' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! -d /home/git/.ssh ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' mkdir /home/git/.ssh' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/gogsssh'
|
|
||||||
fi
|
|
||||||
echo " cp -r /root/tempgogsssh/${RESTORE_SUBDIR}/git/.ssh/* /home/git/.ssh/" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 ' exit 8463' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempgogs' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempgogsrepos' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempgogsssh' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' chown -R git:git /home/git' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
fi
|
|
||||||
|
|
||||||
RESTORE_SUBDIR='var'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/wiki'
|
|
||||||
fi
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/wiki ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring Wiki installation"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempwiki wiki' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " cp -r /root/tempwiki/${RESTORE_SUBDIR}/lib/dokuwiki/* /var/lib/dokuwiki/" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 ' exit 868' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempwiki2 wiki2' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
RESTORE_SUBDIR='etc'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/wiki2'
|
|
||||||
fi
|
|
||||||
echo " cp -r /root/tempwiki2/${RESTORE_SUBDIR}/dokuwiki/* /etc/dokuwiki/" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 ' exit 869' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempwiki' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempwiki2' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' chown -R www-data:www-data /var/lib/dokuwiki/*' >> /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/$WIKI_DOMAIN_NAME.bundle.crt ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " sed -i 's|$WIKI_DOMAIN_NAME.crt|$WIKI_DOMAIN_NAME.bundle.crt|g' /etc/nginx/sites-available/$WIKI_DOMAIN_NAME" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " if [ -d /etc/letsencrypt/live/${WIKI_DOMAIN_NAME} ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${WIKI_DOMAIN_NAME}.key" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${WIKI_DOMAIN_NAME}.pem" >> /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
|
|
||||||
|
|
||||||
RESTORE_SUBDIR='var'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/blog'
|
|
||||||
fi
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/blog ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring blog installation"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempblog blog' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " rm -rf /var/www/$FULLBLOG_DOMAIN_NAME/htdocs" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " cp -r /root/tempblog/${RESTORE_SUBDIR}/www/$FULLBLOG_DOMAIN_NAME/htdocs /var/www/$FULLBLOG_DOMAIN_NAME/" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 ' exit 593' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempblog' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " if [ ! -d /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/content ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "No content directory found after restoring blog"' >> /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 ' exit 287' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " chown -R www-data:www-data /var/www/$FULLBLOG_DOMAIN_NAME/htdocs" >> /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/$FULLBLOG_DOMAIN_NAME.bundle.crt ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " sed -i 's|$FULLBLOG_DOMAIN_NAME.crt|$FULLBLOG_DOMAIN_NAME.bundle.crt|g' /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n " if [ -d /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/content" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '/$USERNAME/blog/uncategorized/post ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n " mv /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/content" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n '/$USERNAME/blog/*.md ' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n "/var/www/$FULLBLOG_DOMAIN_NAME/htdocs/content" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '/$USERNAME/blog/uncategorized/post ' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " if [ -d /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME} ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${FULLBLOG_DOMAIN_NAME}.key" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.pem" >> /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
|
|
||||||
|
|
||||||
RESTORE_SUBDIR='etc'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/cjdns'
|
|
||||||
fi
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/cjdns ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring cjdns installation"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempcjdns cjdns' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " rm -rf /etc/cjdns" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " cp -r /root/tempcjdns/${RESTORE_SUBDIR}/cjdns /etc/" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 ' exit 8472' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempcjdns' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
RESTORE_SUBDIR='root'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/mail'
|
|
||||||
fi
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/mail ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' for d in $USB_MOUNT/backup/mail/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $6}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring emails for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempmail mail/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! -d /home/$USERNAME/Maildir ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' mkdir /home/$USERNAME/Maildir' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n " tar -xzvf /root/tempmail/${RESTORE_SUBDIR}/tempbackupemail/" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '$USERNAME/maildir.tar.gz -C /' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 ' exit 927' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempmail' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
RESTORE_SUBDIR='var'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/dlna'
|
|
||||||
fi
|
|
||||||
echo "if [ -d /var/cache/minidlna ]; then" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ -d $USB_MOUNT/backup/dlna ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring DLNA cache"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempdlna dlna' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo " cp -r /root/tempdlna/${RESTORE_SUBDIR}/cache/minidlna/* /var/cache/minidlna/" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 ' exit 982' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempdlna' >> /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 'if [ -d $USB_MOUNT/backup/voip ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring VoIP settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb /root/tempvoip voip' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
RESTORE_SUBDIR='home'
|
|
||||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
|
||||||
RESTORE_SUBDIR='usb/backup/voip'
|
|
||||||
fi
|
|
||||||
echo -n " cp -f /root/tempvoip/${RESTORE_SUBDIR}/" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n '$MY_USERNAME/tempbackup/' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo "$VOIP_CONFIG_FILE /etc/" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 /root/tempvoip' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' exit 3679' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n " cp -f /root/tempvoip/${RESTORE_SUBDIR}/" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n '$MY_USERNAME/tempbackup/' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'sipwitch.conf /etc/sipwitch.conf' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 /root/tempvoip' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' exit 3679' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n " cp -f /root/tempvoip/${RESTORE_SUBDIR}/" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo -n '$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 ' umount $USB_MOUNT' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf $USB_MOUNT' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempvoip' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' exit 276' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /root/tempvoip' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' cp /etc/ssl/certs/mumble* /var/lib/mumble-server' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' cp /etc/ssl/private/mumble* /var/lib/mumble-server' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' chown -R mumble-server:mumble-server /var/lib/mumble-server' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' service sipwitch restart' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' service mumble-server restart' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
echo 'if [ -d $USB_MOUNT/backup/tox ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' echo "Restoring Tox node settings"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' restore_directory_from_usb / tox' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /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 ' exit 6393' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' cp /var/lib/tox-bootstrapd/tox-bootstrapd.conf /etc/tox-bootstrapd.conf' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' systemctl restart tox-bootstrapd.service' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' systemctl status tox-bootstrapd.service' >> /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 ' exit 59369' >> /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 'sync' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo "# Unmount the USB drive" >> /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 '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
if [[ $BACKUP_INCLUDES_WEBSITES == "yes" ]]; then
|
|
||||||
echo "# Restart the web server" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo "service nginx restart" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo "service php5-fpm restart" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
fi
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'echo "Setting permissions"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' chown -R $USERNAME:$USERNAME /home/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'done' >> /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 ' echo "Unmount encrypted USB"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' cryptsetup luksClose encrypted_usb' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'if [ -f /dev/mapper/encrypted_usb ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo ' rm -rf /dev/mapper/encrypted_usb' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
echo 'echo "Restore from USB drive is complete. You can now remove it."' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
echo 'exit 0' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
chmod 400 /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
chmod +x /usr/bin/$RESTORE_SCRIPT_NAME
|
|
||||||
|
|
||||||
echo 'create_restore_script' >> $COMPLETION_FILE
|
|
||||||
}
|
|
||||||
|
|
||||||
function create_restore_hubzilla_script {
|
function create_restore_hubzilla_script {
|
||||||
if grep -Fxq "create_restore_hubzilla_script" $COMPLETION_FILE; then
|
if grep -Fxq "create_restore_hubzilla_script" $COMPLETION_FILE; then
|
||||||
return
|
return
|
||||||
|
@ -7988,7 +7123,6 @@ function import_email {
|
||||||
'
|
'
|
||||||
if grep -Fxq "import_email" $COMPLETION_FILE; then
|
if grep -Fxq "import_email" $COMPLETION_FILE; then
|
||||||
if [[ $SYSTEM_TYPE == "$VARIANT_MAILBOX" ]]; then
|
if [[ $SYSTEM_TYPE == "$VARIANT_MAILBOX" ]]; then
|
||||||
create_restore_script
|
|
||||||
backup_to_friends_servers
|
backup_to_friends_servers
|
||||||
intrusion_detection
|
intrusion_detection
|
||||||
split_gpg_key_into_fragments
|
split_gpg_key_into_fragments
|
||||||
|
@ -8016,7 +7150,6 @@ function import_email {
|
||||||
fi
|
fi
|
||||||
echo 'import_email' >> $COMPLETION_FILE
|
echo 'import_email' >> $COMPLETION_FILE
|
||||||
if [[ $SYSTEM_TYPE == "$VARIANT_MAILBOX" ]]; then
|
if [[ $SYSTEM_TYPE == "$VARIANT_MAILBOX" ]]; then
|
||||||
create_restore_script
|
|
||||||
backup_to_friends_servers
|
backup_to_friends_servers
|
||||||
intrusion_detection
|
intrusion_detection
|
||||||
split_gpg_key_into_fragments
|
split_gpg_key_into_fragments
|
||||||
|
@ -8445,7 +7578,6 @@ function install_owncloud {
|
||||||
if grep -Fxq "install_owncloud" $COMPLETION_FILE; then
|
if grep -Fxq "install_owncloud" $COMPLETION_FILE; then
|
||||||
if [[ $SYSTEM_TYPE == "$VARIANT_CLOUD" ]]; then
|
if [[ $SYSTEM_TYPE == "$VARIANT_CLOUD" ]]; then
|
||||||
install_owncloud_music_app
|
install_owncloud_music_app
|
||||||
create_restore_script
|
|
||||||
backup_to_friends_servers
|
backup_to_friends_servers
|
||||||
intrusion_detection
|
intrusion_detection
|
||||||
split_gpg_key_into_fragments
|
split_gpg_key_into_fragments
|
||||||
|
@ -8676,11 +7808,11 @@ quit" > $INSTALL_DIR/batch.sql
|
||||||
CURRENT_DDNS_DOMAIN=$OWNCLOUD_DOMAIN_NAME
|
CURRENT_DDNS_DOMAIN=$OWNCLOUD_DOMAIN_NAME
|
||||||
add_ddns_domain
|
add_ddns_domain
|
||||||
|
|
||||||
|
echo "Owncloud domain:$$OWNCLOUD_DOMAIN_NAME" >> $COMPLETION_FILE
|
||||||
echo 'install_owncloud' >> $COMPLETION_FILE
|
echo 'install_owncloud' >> $COMPLETION_FILE
|
||||||
|
|
||||||
if [[ $SYSTEM_TYPE == "$VARIANT_CLOUD" ]]; then
|
if [[ $SYSTEM_TYPE == "$VARIANT_CLOUD" ]]; then
|
||||||
install_owncloud_music_app
|
install_owncloud_music_app
|
||||||
create_restore_script
|
|
||||||
backup_to_friends_servers
|
backup_to_friends_servers
|
||||||
intrusion_detection
|
intrusion_detection
|
||||||
split_gpg_key_into_fragments
|
split_gpg_key_into_fragments
|
||||||
|
@ -8930,6 +8062,7 @@ quit" > $INSTALL_DIR/batch.sql
|
||||||
CURRENT_DDNS_DOMAIN=$GIT_DOMAIN_NAME
|
CURRENT_DDNS_DOMAIN=$GIT_DOMAIN_NAME
|
||||||
add_ddns_domain
|
add_ddns_domain
|
||||||
|
|
||||||
|
echo "Gogs domain:$GIT_DOMAIN_NAME" >> $COMPLETION_FILE
|
||||||
echo 'install_gogs' >> $COMPLETION_FILE
|
echo 'install_gogs' >> $COMPLETION_FILE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9707,6 +8840,7 @@ function install_wiki {
|
||||||
chmod 600 /home/$MY_USERNAME/README
|
chmod 600 /home/$MY_USERNAME/README
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Wiki domain:$WIKI_DOMAIN_NAME" >> $COMPLETION_FILE
|
||||||
echo 'install_wiki' >> $COMPLETION_FILE
|
echo 'install_wiki' >> $COMPLETION_FILE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11640,7 +10774,6 @@ configure_firewall_for_dlna
|
||||||
install_mediagoblin
|
install_mediagoblin
|
||||||
#install_ipfs
|
#install_ipfs
|
||||||
repair_databases_script
|
repair_databases_script
|
||||||
create_restore_script
|
|
||||||
create_restore_hubzilla_script
|
create_restore_hubzilla_script
|
||||||
backup_to_friends_servers
|
backup_to_friends_servers
|
||||||
restore_from_friend
|
restore_from_friend
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
PROJECT_NAME='freedombone'
|
PROJECT_NAME='freedombone'
|
||||||
COMPLETION_FILE=$HOME/freedombone-completed.txt
|
COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
|
||||||
|
|
||||||
export TEXTDOMAIN=${PROJECT_NAME}-backup-local
|
export TEXTDOMAIN=${PROJECT_NAME}-backup-local
|
||||||
export TEXTDOMAINDIR="/usr/share/locale"
|
export TEXTDOMAINDIR="/usr/share/locale"
|
||||||
|
|
|
@ -0,0 +1,735 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# .---. . .
|
||||||
|
# | | |
|
||||||
|
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
||||||
|
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
||||||
|
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
||||||
|
#
|
||||||
|
# Freedom in the Cloud
|
||||||
|
#
|
||||||
|
# Backup to local storage - typically a USB drive
|
||||||
|
|
||||||
|
# License
|
||||||
|
# =======
|
||||||
|
#
|
||||||
|
# Copyright (C) 2015 Bob Mottram <bob@robotics.uk.to>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
PROJECT_NAME='freedombone'
|
||||||
|
COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
|
||||||
|
|
||||||
|
export TEXTDOMAIN=${PROJECT_NAME}-restore-local
|
||||||
|
export TEXTDOMAINDIR="/usr/share/locale"
|
||||||
|
|
||||||
|
USB_DRIVE=/dev/sdb1
|
||||||
|
if [ $1 ]; then
|
||||||
|
USB_DRIVE=/dev/${1}1
|
||||||
|
fi
|
||||||
|
USB_MOUNT=/mnt/usb
|
||||||
|
|
||||||
|
# Get the admin username
|
||||||
|
ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
|
||||||
|
if [ $2 ]; then
|
||||||
|
ADMIN_USERNAME=$2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -b $USB_DRIVE ]; then
|
||||||
|
echo $"Please attach a USB drive"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d $USB_MOUNT ]; then
|
||||||
|
mkdir $USB_MOUNT
|
||||||
|
if [ -f /dev/mapper/encrypted_usb ]; then
|
||||||
|
rm -rf /dev/mapper/encrypted_usb
|
||||||
|
fi
|
||||||
|
cryptsetup luksClose encrypted_usb
|
||||||
|
cryptsetup luksOpen $USB_DRIVE encrypted_usb
|
||||||
|
if [ "$?" = "0" ]; then
|
||||||
|
USB_DRIVE=/dev/mapper/encrypted_usb
|
||||||
|
fi
|
||||||
|
mount $USB_DRIVE $USB_MOUNT
|
||||||
|
fi
|
||||||
|
if [ ! -d $USB_MOUNT/backup ]; then
|
||||||
|
echo $"No backup directory found on the USB drive."
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $"Checking that admin user exists"
|
||||||
|
if [ ! -d /home/$ADMIN_USERNAME ]; then
|
||||||
|
echo $"Username $ADMIN_USERNAME not found. Reinstall ${PROJECT_NAME} with this username."
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 295
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $"Copying GPG keys to root"
|
||||||
|
cp -r /home/$ADMIN_USERNAME/.gnupg /root
|
||||||
|
|
||||||
|
# MariaDB password
|
||||||
|
DATABASE_PASSWORD=$(cat /root/dbpass)
|
||||||
|
|
||||||
|
function restore_directory_from_usb {
|
||||||
|
BACKUP_CERTIFICATE=/etc/ssl/private/backup.key
|
||||||
|
if [ ! -d ${1} ]; then
|
||||||
|
mkdir ${1}
|
||||||
|
fi
|
||||||
|
obnam restore -r $USB_MOUNT/backup/${2} --to ${1}
|
||||||
|
}
|
||||||
|
|
||||||
|
function restore_database {
|
||||||
|
RESTORE_SUBDIR="root"
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/${1} ]; then
|
||||||
|
echo $"Restoring ${1} database"
|
||||||
|
restore_directory_from_usb "/root/temp${1}data" "${1}data"
|
||||||
|
if [ ! -f /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/${1}.sql ]; then
|
||||||
|
echo $"Unable to restore ${1} database"
|
||||||
|
rm -rf /root/temp${1}data
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 503
|
||||||
|
fi
|
||||||
|
mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD ${1} -o < /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/${1}.sql)
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
echo "$mysqlsuccess"
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 964
|
||||||
|
fi
|
||||||
|
shred -zu /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/*
|
||||||
|
rm -rf /root/temp${1}data
|
||||||
|
echo $"Restoring ${1} installation"
|
||||||
|
if [ ! -d /root/temp${1} ]; then
|
||||||
|
mkdir /root/temp${1}
|
||||||
|
fi
|
||||||
|
restore_directory_from_usb "/root/temp${1}" "${1}"
|
||||||
|
RESTORE_SUBDIR="var"
|
||||||
|
if [ ${2} ]; then
|
||||||
|
if [ -d /var/www/${2}/htdocs ]; then
|
||||||
|
if [ -d /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs ]; then
|
||||||
|
rm -rf /var/www/${2}/htdocs
|
||||||
|
mv /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs /var/www/${2}/
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 683
|
||||||
|
fi
|
||||||
|
if [ -d /etc/letsencrypt/live/${2} ]; then
|
||||||
|
ln -s /etc/letsencrypt/live/${2}/privkey.pem /etc/ssl/private/${2}.key
|
||||||
|
ln -s /etc/letsencrypt/live/${2}/fullchain.pem /etc/ssl/certs/${2}.pem
|
||||||
|
else
|
||||||
|
# Ensure that the bundled SSL cert is being used
|
||||||
|
if [ -f /etc/ssl/certs/${2}.bundle.crt ]; then
|
||||||
|
sed -i "s|${2}.crt|${2}.bundle.crt|g" /etc/nginx/sites-available/${2}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Make a backup of the original README file
|
||||||
|
# incase old passwords need to be used
|
||||||
|
if [ -f /home/$ADMIN_USERNAME/README ]; then
|
||||||
|
if [ ! -f /home/$ADMIN_USERNAME/README_original ]; then
|
||||||
|
cp /home/$ADMIN_USERNAME/README /home/$ADMIN_USERNAME/README_original
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/mariadb ]; then
|
||||||
|
echo $"Restoring mysql settings"
|
||||||
|
restore_directory_from_usb /root/tempmariadb mariadb
|
||||||
|
echo $"Get the MariaDB password from the backup"
|
||||||
|
if [ ! -f /root/tempmariadb/root/tempmariadb/db ]; then
|
||||||
|
echo $"MariaDB password file not found"
|
||||||
|
exit 495
|
||||||
|
fi
|
||||||
|
BACKUP_MARIADB_PASSWORD=$(cat /root/tempmariadb/root/tempmariadb/db)
|
||||||
|
if [[ $BACKUP_MARIADB_PASSWORD != $DATABASE_PASSWORD ]]; then
|
||||||
|
echo $"Restore the MariaDB user table"
|
||||||
|
mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD mysql -o < /root/tempmariadb/root/tempmariadb/mysql.sql)
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
echo $"Try again using the password obtained from backup"
|
||||||
|
mysqlsuccess=$(mysql -u root --password=$BACKUP_MARIADB_PASSWORD mysql -o < /root/tempmariadb/root/tempmariadb/mysql.sql)
|
||||||
|
fi
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
echo "$mysqlsuccess"
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 962
|
||||||
|
fi
|
||||||
|
echo $"Restarting database"
|
||||||
|
service mysql restart
|
||||||
|
echo $"Change the MariaDB password to the backup version"
|
||||||
|
DATABASE_PASSWORD=$BACKUP_MARIADB_PASSWORD
|
||||||
|
fi
|
||||||
|
shred -zu /root/tempmariadb/root/tempmariadb/db
|
||||||
|
rm -rf /root/tempmariadb
|
||||||
|
|
||||||
|
# Change database password file
|
||||||
|
echo "$DATABASE_PASSWORD" > /root/dbpass
|
||||||
|
chmod 600 /root/dbpass
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/letsencrypt ]; then
|
||||||
|
echo $"Restoring Lets Encrypt settings"
|
||||||
|
restore_directory_from_usb / letsencrypt
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/mutt ]; then
|
||||||
|
for d in $USB_MOUNT/backup/mutt/*/ ; do
|
||||||
|
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||||
|
if [[ $USERNAME != "git" ]]; then
|
||||||
|
if [ ! -d /home/$USERNAME ]; then
|
||||||
|
${PROJECT_NAME}-adduser $USERNAME
|
||||||
|
fi
|
||||||
|
echo $"Restoring Mutt settings for $USERNAME"
|
||||||
|
restore_directory_from_usb /root/tempmutt mutt/$USERNAME
|
||||||
|
if [ -f /root/tempmutt/home/$USERNAME/tempbackup/.muttrc ]; then
|
||||||
|
cp -f /root/tempmutt/home/$USERNAME/tempbackup/.muttrc /home/$USERNAME/.muttrc
|
||||||
|
fi
|
||||||
|
if [ -f /root/tempmutt/home/$USERNAME/tempbackup/Muttrc ]; then
|
||||||
|
cp -f /root/tempmutt/home/$USERNAME/tempbackup/Muttrc /etc/Muttrc
|
||||||
|
fi
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
rm -rf /root/tempmutt
|
||||||
|
exit 276
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempmutt
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/gnupg ]; then
|
||||||
|
for d in $USB_MOUNT/backup/gnupg/*/ ; do
|
||||||
|
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||||
|
if [[ $USERNAME != "git" ]]; then
|
||||||
|
if [ ! -d /home/$USERNAME ]; then
|
||||||
|
${PROJECT_NAME}-adduser $USERNAME
|
||||||
|
fi
|
||||||
|
echo $"Restoring gnupg settings for $USERNAME"
|
||||||
|
restore_directory_from_usb /root/tempgnupg gnupg/$USERNAME
|
||||||
|
cp -r /root/tempgnupg/home/$USERNAME/.gnupg /home/$USERNAME/
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
rm -rf /root/tempgnupg
|
||||||
|
exit 276
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempgnupg
|
||||||
|
if [[ "$USERNAME" == "$ADMIN_USERNAME" ]]; then
|
||||||
|
cp -r /home/$USERNAME/.gnupg /root
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 283
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/procmail ]; then
|
||||||
|
for d in $USB_MOUNT/backup/procmail/*/ ; do
|
||||||
|
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||||
|
if [[ $USERNAME != "git" ]]; then
|
||||||
|
if [ ! -d /home/$USERNAME ]; then
|
||||||
|
${PROJECT_NAME}-adduser $USERNAME
|
||||||
|
fi
|
||||||
|
echo $"Restoring procmail settings for $USERNAME"
|
||||||
|
restore_directory_from_usb /root/tempprocmail procmail/$USERNAME
|
||||||
|
cp -f /root/tempprocmail/home/$USERNAME/tempbackup/.procmailrc /home/$USERNAME/
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
rm -rf /root/tempprocmail
|
||||||
|
exit 276
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempprocmail
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/spamassassin ]; then
|
||||||
|
for d in $USB_MOUNT/backup/spamassassin/*/ ; do
|
||||||
|
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||||
|
if [[ $USERNAME != "git" ]]; then
|
||||||
|
if [ -d $USB_MOUNT/backup/spamassassin/$USERNAME ]; then
|
||||||
|
if [ ! -d /home/$USERNAME ]; then
|
||||||
|
${PROJECT_NAME}-adduser $USERNAME
|
||||||
|
fi
|
||||||
|
echo $"Restoring spamassassin settings for $USERNAME"
|
||||||
|
restore_directory_from_usb /root/tempspamassassin spamassassin/$USERNAME
|
||||||
|
cp -rf /root/tempspamassassin/home/$USERNAME/.spamassassin /home/$USERNAME/
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
rm -rf /root/tempspamassassin
|
||||||
|
exit 276
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempspamassassin
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/readme ]; then
|
||||||
|
echo $"Restoring admin user README"
|
||||||
|
restore_directory_from_usb /root/tempreadme readme
|
||||||
|
cp -f /root/tempreadme/home/$ADMIN_USERNAME/tempbackup/README /home/$ADMIN_USERNAME/
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
rm -rf /root/tempreadme
|
||||||
|
exit 276
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempreadme
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/ipfs ]; then
|
||||||
|
echo $"Restoring IPFS"
|
||||||
|
restore_directory_from_usb /root/tempipfs ipfs
|
||||||
|
cp -rf /root/tempipfs/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
rm -rf /root/tempipfs
|
||||||
|
exit 276
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempipfs
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/ssh ]; then
|
||||||
|
for d in $USB_MOUNT/backup/ssh/*/ ; do
|
||||||
|
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||||
|
if [[ $USERNAME != "git" ]]; then
|
||||||
|
if [ ! -d /home/$USERNAME ]; then
|
||||||
|
${PROJECT_NAME}-adduser $USERNAME
|
||||||
|
fi
|
||||||
|
echo $"Restoring ssh keys for $USERNAME"
|
||||||
|
restore_directory_from_usb /root/tempssh ssh/$USERNAME
|
||||||
|
cp -r /root/tempssh/home/$USERNAME/.ssh /home/$USERNAME/
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
rm -rf /root/tempssh
|
||||||
|
exit 664
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempssh
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/config ]; then
|
||||||
|
for d in $USB_MOUNT/backup/config/*/ ; do
|
||||||
|
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||||
|
if [[ $USERNAME != "git" ]]; then
|
||||||
|
if [ ! -d /home/$USERNAME ]; then
|
||||||
|
${PROJECT_NAME}-adduser $USERNAME
|
||||||
|
fi
|
||||||
|
echo $"Restoring config files for $USERNAME"
|
||||||
|
restore_directory_from_usb /root/tempconfig config/$USERNAME
|
||||||
|
cp -r /root/tempconfig/home/$USERNAME/.config /home/$USERNAME/
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
rm -rf /root/tempconfig
|
||||||
|
exit 664
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempconfig
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/ssl ]; then
|
||||||
|
echo $"Restoring certificates"
|
||||||
|
mkdir /root/tempssl
|
||||||
|
restore_directory_from_usb /root/tempssl ssl
|
||||||
|
cp -r /root/tempssl/etc/ssl/* /etc/ssl
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 276
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempssl
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/projects ]; then
|
||||||
|
for d in $USB_MOUNT/backup/projects/*/ ; do
|
||||||
|
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||||
|
if [[ $USERNAME != "git" ]]; then
|
||||||
|
if [ ! -d /home/$USERNAME ]; then
|
||||||
|
${PROJECT_NAME}-adduser $USERNAME
|
||||||
|
fi
|
||||||
|
echo $"Restoring projects for $USERNAME"
|
||||||
|
restore_directory_from_usb /root/tempprojects projects/$USERNAME
|
||||||
|
if [ -d /home/$USERNAME/projects ]; then
|
||||||
|
rm -rf /home/$USERNAME/projects
|
||||||
|
fi
|
||||||
|
mv /root/tempprojects/home/$USERNAME/projects /home/$USERNAME
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 166
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempprojects
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/personal ]; then
|
||||||
|
for d in $USB_MOUNT/backup/personal/*/ ; do
|
||||||
|
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||||
|
if [[ $USERNAME != "git" ]]; then
|
||||||
|
if [ -d $USB_MOUNT/backup/personal/$USERNAME ]; then
|
||||||
|
if [ ! -d /home/$USERNAME ]; then
|
||||||
|
${PROJECT_NAME}-adduser $USERNAME
|
||||||
|
fi
|
||||||
|
echo $"Restoring personal settings for $USERNAME"
|
||||||
|
restore_directory_from_usb /root/temppersonal personal/$USERNAME
|
||||||
|
if [ -d /home/$USERNAME/personal ]; then
|
||||||
|
rm -rf /home/$USERNAME/personal
|
||||||
|
fi
|
||||||
|
mv /root/temppersonal/home/$USERNAME/personal /home/$USERNAME
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 184
|
||||||
|
fi
|
||||||
|
rm -rf /root/temppersonal
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d /var/spool/mlmmj ]; then
|
||||||
|
echo $"Restoring public mailing list"
|
||||||
|
restore_directory_from_usb /root/tempmailinglist mailinglist
|
||||||
|
cp -r /root/tempmailinglist/root/spool/mlmmj/* /var/spool/mlmmj
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 526
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempmailinglist
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d /var/lib/prosody ]; then
|
||||||
|
echo $"Restoring XMPP settings"
|
||||||
|
restore_directory_from_usb /root/tempxmpp xmpp
|
||||||
|
cp -r /root/tempxmpp/var/lib/prosody/* /var/lib/prosody
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 725
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempxmpp
|
||||||
|
service prosody restart
|
||||||
|
chown -R prosody:prosody /var/lib/prosody/*
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Restoring GNU Social
|
||||||
|
if grep -q "GNU Social domain" $COMPLETION_FILE; then
|
||||||
|
MICROBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "GNU Social domain" | awk -F ':' '{print $2}')
|
||||||
|
restore_database gnusocial ${MICROBLOG_DOMAIN_NAME}
|
||||||
|
if [ -d /root/tempgnusocial ]; then
|
||||||
|
rm -rf /root/tempgnusocial
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Restoring hubzilla
|
||||||
|
if grep -q "Hubzilla domain" $COMPLETION_FILE; then
|
||||||
|
HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
|
||||||
|
restore_database hubzilla ${HUBZILLA_DOMAIN_NAME}
|
||||||
|
if [ -d $USB_MOUNT/backup/hubzilla ]; then
|
||||||
|
if [ ! -d /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3 ]; then
|
||||||
|
mkdir -p /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3
|
||||||
|
fi
|
||||||
|
chmod 777 /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3
|
||||||
|
chown -R www-data:www-data /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/*
|
||||||
|
if [ -d /root/temphubzilla ]; then
|
||||||
|
rm -rf /root/temphubzilla
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep -q "Owncloud domain" $COMPLETION_FILE; then
|
||||||
|
OWNCLOUD_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Owncloud domain" | awk -F ':' '{print $2}')
|
||||||
|
restore_database owncloud $OWNCLOUD_DOMAIN_NAME
|
||||||
|
if [ -d $USB_MOUNT/backup/owncloud2 ]; then
|
||||||
|
restore_directory_from_usb /root/tempowncloud2 owncloud2
|
||||||
|
cp -r /root/tempowncloud2/etc/owncloud/* /etc/owncloud/
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 982
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempowncloud
|
||||||
|
rm -rf /root/tempowncloud2
|
||||||
|
chown -R www-data:www-data /var/lib/owncloud/data
|
||||||
|
chown -R www-data:www-data /var/lib/owncloud/backup
|
||||||
|
chown -R www-data:www-data /var/lib/owncloud/assets
|
||||||
|
for d in /home/*/ ; do
|
||||||
|
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||||
|
if [[ $USERNAME != "git" ]]; then
|
||||||
|
occ files:scan $USERNAME
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
ln -s /usr/share/owncloud /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep -q "Gogs domain" $COMPLETION_FILE; then
|
||||||
|
GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}')
|
||||||
|
restore_database gogs ${GIT_DOMAIN_NAME}
|
||||||
|
if [ -d $USB_MOUNT/backup/gogs ]; then
|
||||||
|
echo $"Restoring Gogs settings"
|
||||||
|
if [ ! -d /home/git/go/src/github.com/gogits/gogs/custom ]; then
|
||||||
|
mkdir -p /home/git/go/src/github.com/gogits/gogs/custom
|
||||||
|
fi
|
||||||
|
cp -r /root/tempgogs/home/git/go/src/github.com/gogits/gogs/custom/* /home/git/go/src/github.com/gogits/gogs/custom
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 981
|
||||||
|
fi
|
||||||
|
echo $"Restoring Gogs repos"
|
||||||
|
restore_directory_from_usb /root/tempgogsrepos gogsrepos
|
||||||
|
cp -r /root/tempgogsrepos/home/git/gogs-repositories/* /home/git/gogs-repositories/
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 67574
|
||||||
|
fi
|
||||||
|
echo $"Restoring Gogs authorized_keys"
|
||||||
|
restore_directory_from_usb /root/tempgogsssh gogsssh
|
||||||
|
if [ ! -d /home/git/.ssh ]; then
|
||||||
|
mkdir /home/git/.ssh
|
||||||
|
fi
|
||||||
|
cp -r /root/tempgogsssh/home/git/.ssh/* /home/git/.ssh/
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 8463
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempgogs
|
||||||
|
rm -rf /root/tempgogsrepos
|
||||||
|
rm -rf /root/tempgogsssh
|
||||||
|
chown -R git:git /home/git
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/wiki ]; then
|
||||||
|
WIKI_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Wiki domain" | awk -F ':' '{print $2}')
|
||||||
|
echo $"Restoring Wiki installation ${WIKI_DOMAIN_NAME}"
|
||||||
|
restore_directory_from_usb /root/tempwiki wiki
|
||||||
|
cp -r /root/tempwiki/var/lib/dokuwiki/* /var/lib/dokuwiki/
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 868
|
||||||
|
fi
|
||||||
|
restore_directory_from_usb /root/tempwiki2 wiki2
|
||||||
|
cp -r /root/tempwiki2/etc/dokuwiki/* /etc/dokuwiki/
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 869
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempwiki
|
||||||
|
rm -rf /root/tempwiki2
|
||||||
|
chown -R www-data:www-data /var/lib/dokuwiki/*
|
||||||
|
# Ensure that the bundled SSL cert is being used
|
||||||
|
if [ -f /etc/ssl/certs/${WIKI_DOMAIN_NAME}.bundle.crt ]; then
|
||||||
|
sed -i "s|${WIKI_DOMAIN_NAME}.crt|${WIKI_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${WIKI_DOMAIN_NAME}
|
||||||
|
fi
|
||||||
|
if [ -d /etc/letsencrypt/live/${WIKI_DOMAIN_NAME} ]; then
|
||||||
|
ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${WIKI_DOMAIN_NAME}.key
|
||||||
|
ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${WIKI_DOMAIN_NAME}.pem
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/blog ]; then
|
||||||
|
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
||||||
|
echo $"Restoring blog installation"
|
||||||
|
restore_directory_from_usb /root/tempblog blog
|
||||||
|
rm -rf /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
||||||
|
cp -r /root/tempblog/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs /var/www/${FULLBLOG_DOMAIN_NAME}/
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 593
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempblog
|
||||||
|
if [ ! -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content ]; then
|
||||||
|
echo $"No content directory found after restoring blog"
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 287
|
||||||
|
fi
|
||||||
|
chown -R www-data:www-data /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
||||||
|
# Ensure that the bundled SSL cert is being used
|
||||||
|
if [ -f /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.bundle.crt ]; then
|
||||||
|
sed -i "s|${FULLBLOG_DOMAIN_NAME}.crt|${FULLBLOG_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${FULLBLOG_DOMAIN_NAME}
|
||||||
|
fi
|
||||||
|
for d in /home/*/ ; do
|
||||||
|
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||||
|
if [[ $USERNAME != "git" ]]; then
|
||||||
|
if [ -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post ]; then
|
||||||
|
mv /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/*.md /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ -d /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME} ]; then
|
||||||
|
ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${FULLBLOG_DOMAIN_NAME}.key
|
||||||
|
ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.pem
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/cjdns ]; then
|
||||||
|
echo $"Restoring cjdns installation"
|
||||||
|
restore_directory_from_usb /root/tempcjdns cjdns
|
||||||
|
rm -rf /etc/cjdns
|
||||||
|
cp -r /root/tempcjdns/etc/cjdns /etc/
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 8472
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempcjdns
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/mail ]; then
|
||||||
|
for d in $USB_MOUNT/backup/mail/*/ ; do
|
||||||
|
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
||||||
|
if [[ $USERNAME != "git" ]]; then
|
||||||
|
if [ ! -d /home/$USERNAME ]; then
|
||||||
|
${PROJECT_NAME}-adduser $USERNAME
|
||||||
|
fi
|
||||||
|
echo $"Restoring emails for $USERNAME"
|
||||||
|
restore_directory_from_usb /root/tempmail mail/$USERNAME
|
||||||
|
if [ ! -d /home/$USERNAME/Maildir ]; then
|
||||||
|
mkdir /home/$USERNAME/Maildir
|
||||||
|
fi
|
||||||
|
tar -xzvf /root/tempmail/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 927
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempmail
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d /var/cache/minidlna ]; then
|
||||||
|
if [ -d $USB_MOUNT/backup/dlna ]; then
|
||||||
|
echo $"Restoring DLNA cache"
|
||||||
|
restore_directory_from_usb /root/tempdlna dlna
|
||||||
|
cp -r /root/tempdlna/var/cache/minidlna/* /var/cache/minidlna/
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 982
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempdlna
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/voip ]; then
|
||||||
|
echo $"Restoring VoIP settings"
|
||||||
|
restore_directory_from_usb /root/tempvoip voip
|
||||||
|
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
rm -rf /root/tempvoip
|
||||||
|
exit 3679
|
||||||
|
fi
|
||||||
|
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
rm -rf /root/tempvoip
|
||||||
|
exit 3679
|
||||||
|
fi
|
||||||
|
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
rm -rf /root/tempvoip
|
||||||
|
exit 276
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempvoip
|
||||||
|
cp /etc/ssl/certs/mumble* /var/lib/mumble-server
|
||||||
|
cp /etc/ssl/private/mumble* /var/lib/mumble-server
|
||||||
|
chown -R mumble-server:mumble-server /var/lib/mumble-server
|
||||||
|
service sipwitch restart
|
||||||
|
service mumble-server restart
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $USB_MOUNT/backup/tox ]; then
|
||||||
|
echo $"Restoring Tox node settings"
|
||||||
|
restore_directory_from_usb / tox
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 6393
|
||||||
|
fi
|
||||||
|
cp /var/lib/tox-bootstrapd/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
|
||||||
|
systemctl restart tox-bootstrapd.service
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
systemctl status tox-bootstrapd.service
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 59369
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
sync
|
||||||
|
|
||||||
|
# Unmount the USB drive
|
||||||
|
umount $USB_MOUNT
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
|
||||||
|
# Restart the web server
|
||||||
|
systemctl restart nginx
|
||||||
|
systemctl restart php5-fpm
|
||||||
|
|
||||||
|
echo $"Setting permissions"
|
||||||
|
for d in /home/*/ ; do
|
||||||
|
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||||
|
if [[ $USERNAME != "git" ]]; then
|
||||||
|
chown -R $USERNAME:$USERNAME /home/$USERNAME
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ $USB_DRIVE == /dev/mapper/encrypted_usb ]]; then
|
||||||
|
echo $"Unmount encrypted USB"
|
||||||
|
cryptsetup luksClose encrypted_usb
|
||||||
|
fi
|
||||||
|
if [ -f /dev/mapper/encrypted_usb ]; then
|
||||||
|
rm -rf /dev/mapper/encrypted_usb
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $"Restore from USB drive is complete. You can now remove it."
|
||||||
|
exit 0
|
Loading…
Reference in New Issue