Tidying of restore command
This commit is contained in:
parent
3d1d6ef345
commit
68442896af
|
@ -53,18 +53,21 @@ if [ -f /root/dbpass ]; then
|
||||||
DATABASE_PASSWORD=$(cat /root/dbpass)
|
DATABASE_PASSWORD=$(cat /root/dbpass)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MICROBLOG_DOMAIN_NAME='microblog'
|
|
||||||
if grep -q "GNU Social domain" $COMPLETION_FILE; then
|
function update_domains {
|
||||||
MICROBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "GNU Social domain" | awk -F ':' '{print $2}')
|
MICROBLOG_DOMAIN_NAME='microblog'
|
||||||
fi
|
if grep -q "GNU Social domain" $COMPLETION_FILE; then
|
||||||
HUBZILLA_DOMAIN_NAME='hubzilla'
|
MICROBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "GNU Social domain" | awk -F ':' '{print $2}')
|
||||||
if grep -q "Hubzilla domain" $COMPLETION_FILE; then
|
fi
|
||||||
HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
|
HUBZILLA_DOMAIN_NAME='hubzilla'
|
||||||
fi
|
if grep -q "Hubzilla domain" $COMPLETION_FILE; then
|
||||||
FULLBLOG_DOMAIN_NAME='blog'
|
HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
|
||||||
if grep -q "Blog domain" $COMPLETION_FILE; then
|
fi
|
||||||
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
FULLBLOG_DOMAIN_NAME='blog'
|
||||||
fi
|
if grep -q "Blog domain" $COMPLETION_FILE; then
|
||||||
|
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function mount_drive {
|
function mount_drive {
|
||||||
if [ $1 ]; then
|
if [ $1 ]; then
|
||||||
|
@ -354,6 +357,7 @@ mount_drive $1 $2
|
||||||
remove_backup_directory $remove_option
|
remove_backup_directory $remove_option
|
||||||
make_backup_directory
|
make_backup_directory
|
||||||
check_storage_space_remaining
|
check_storage_space_remaining
|
||||||
|
update_domains
|
||||||
backup_users
|
backup_users
|
||||||
|
|
||||||
if [ -d /home/git/go/src/github.com/gogits ]; then
|
if [ -d /home/git/go/src/github.com/gogits ]; then
|
||||||
|
@ -368,6 +372,15 @@ fi
|
||||||
|
|
||||||
backup_directories
|
backup_directories
|
||||||
|
|
||||||
|
# configuration files
|
||||||
|
echo $"Backing up ${PROJECT_NAME} configuration files"
|
||||||
|
if [ ! -d /root/tempbackupconfig ]; then
|
||||||
|
mkdir -p /root/tempbackupconfig
|
||||||
|
fi
|
||||||
|
cp -f $CONFIG_FILE /root/tempbackupconfig
|
||||||
|
cp -f $COMPLETION_FILE /root/tempbackupconfig
|
||||||
|
backup_directory_to_usb /root/tempbackupconfig config
|
||||||
|
|
||||||
# Backup admin user README file
|
# Backup admin user README file
|
||||||
if [ -f /home/$ADMIN_USERNAME/README ]; then
|
if [ -f /home/$ADMIN_USERNAME/README ]; then
|
||||||
echo $"Backing up README"
|
echo $"Backing up README"
|
||||||
|
|
|
@ -35,9 +35,6 @@ export TEXTDOMAIN=${PROJECT_NAME}-restore-local
|
||||||
export TEXTDOMAINDIR="/usr/share/locale"
|
export TEXTDOMAINDIR="/usr/share/locale"
|
||||||
|
|
||||||
USB_DRIVE=/dev/sdb1
|
USB_DRIVE=/dev/sdb1
|
||||||
if [ $1 ]; then
|
|
||||||
USB_DRIVE=/dev/${1}1
|
|
||||||
fi
|
|
||||||
USB_MOUNT=/mnt/usb
|
USB_MOUNT=/mnt/usb
|
||||||
|
|
||||||
# get default USB from config file
|
# get default USB from config file
|
||||||
|
@ -48,52 +45,110 @@ if [ -f $CONFIG_FILE ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get the admin username
|
ADMIN_USERNAME=
|
||||||
ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
|
ADMIN_NAME=
|
||||||
if [ $2 ]; then
|
|
||||||
ADMIN_USERNAME=$2
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -b $USB_DRIVE ]; then
|
# MariaDB password
|
||||||
echo $"Please attach a USB drive"
|
DATABASE_PASSWORD=$(cat /root/dbpass)
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d $USB_MOUNT ]; then
|
MICROBLOG_DOMAIN_NAME=
|
||||||
mkdir $USB_MOUNT
|
HUBZILLA_DOMAIN_NAME=
|
||||||
|
OWNCLOUD_DOMAIN_NAME=
|
||||||
|
GIT_DOMAIN_NAME=
|
||||||
|
WIKI_DOMAIN_NAME=
|
||||||
|
FULLBLOG_DOMAIN_NAME=
|
||||||
|
|
||||||
|
function mount_drive {
|
||||||
|
if [ $1 ]; then
|
||||||
|
USB_DRIVE=/dev/${1}1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# get the admin user
|
||||||
|
ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
|
||||||
|
if [ $2 ]; then
|
||||||
|
ADMIN_USERNAME=$2
|
||||||
|
fi
|
||||||
|
ADMIN_NAME=$(getent passwd $ADMIN_USERNAME | cut -d: -f5 | cut -d, -f1)
|
||||||
|
|
||||||
|
# check that the backup destination is available
|
||||||
|
if [ ! -b $USB_DRIVE ]; then
|
||||||
|
echo $"Please attach a USB drive"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# unmount if already mounted
|
||||||
|
umount -f $USB_MOUNT
|
||||||
|
if [ ! -d $USB_MOUNT ]; then
|
||||||
|
mkdir $USB_MOUNT
|
||||||
|
fi
|
||||||
if [ -f /dev/mapper/encrypted_usb ]; then
|
if [ -f /dev/mapper/encrypted_usb ]; then
|
||||||
rm -rf /dev/mapper/encrypted_usb
|
rm -rf /dev/mapper/encrypted_usb
|
||||||
fi
|
fi
|
||||||
cryptsetup luksClose encrypted_usb
|
cryptsetup luksClose encrypted_usb
|
||||||
|
|
||||||
|
# mount the encrypted backup drive
|
||||||
cryptsetup luksOpen $USB_DRIVE encrypted_usb
|
cryptsetup luksOpen $USB_DRIVE encrypted_usb
|
||||||
if [ "$?" = "0" ]; then
|
if [ "$?" = "0" ]; then
|
||||||
USB_DRIVE=/dev/mapper/encrypted_usb
|
USB_DRIVE=/dev/mapper/encrypted_usb
|
||||||
fi
|
fi
|
||||||
mount $USB_DRIVE $USB_MOUNT
|
mount $USB_DRIVE $USB_MOUNT
|
||||||
fi
|
if [ ! "$?" = "0" ]; then
|
||||||
if [ ! -d $USB_MOUNT/backup ]; then
|
echo $"There was a problem mounting the USB drive to $USB_MOUNT"
|
||||||
echo $"No backup directory found on the USB drive."
|
rm -rf $USB_MOUNT
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function unmount_drive {
|
||||||
|
sync
|
||||||
umount $USB_MOUNT
|
umount $USB_MOUNT
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
echo $"Unable to unmount the drive. This means that the backup did not work"
|
||||||
|
rm -rf $USB_MOUNT
|
||||||
|
exit 9
|
||||||
|
fi
|
||||||
rm -rf $USB_MOUNT
|
rm -rf $USB_MOUNT
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo $"Checking that admin user exists"
|
echo $"Setting permissions"
|
||||||
if [ ! -d /home/$ADMIN_USERNAME ]; then
|
for d in /home/*/ ; do
|
||||||
echo $"Username $ADMIN_USERNAME not found. Reinstall ${PROJECT_NAME} with this username."
|
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||||
umount $USB_MOUNT
|
if [[ $USERNAME != "git" ]]; then
|
||||||
rm -rf $USB_MOUNT
|
chown -R $USERNAME:$USERNAME /home/$USERNAME
|
||||||
exit 295
|
fi
|
||||||
fi
|
done
|
||||||
|
|
||||||
echo $"Copying GPG keys to root"
|
if [[ $USB_DRIVE == /dev/mapper/encrypted_usb ]]; then
|
||||||
cp -r /home/$ADMIN_USERNAME/.gnupg /root
|
echo $"Unmount encrypted USB"
|
||||||
|
cryptsetup luksClose encrypted_usb
|
||||||
|
fi
|
||||||
|
if [ -f /dev/mapper/encrypted_usb ]; then
|
||||||
|
rm -rf /dev/mapper/encrypted_usb
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# MariaDB password
|
function check_backup_exists {
|
||||||
DATABASE_PASSWORD=$(cat /root/dbpass)
|
if [ ! -d $USB_MOUNT/backup ]; then
|
||||||
|
echo $"No backup directory found on the USB drive."
|
||||||
|
unmount_drive
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_admin_user {
|
||||||
|
echo $"Checking that admin user exists"
|
||||||
|
if [ ! -d /home/$ADMIN_USERNAME ]; then
|
||||||
|
echo $"Username $ADMIN_USERNAME not found. Reinstall ${PROJECT_NAME} with this username."
|
||||||
|
unmount_drive
|
||||||
|
exit 295
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function copy_gpg_keys {
|
||||||
|
echo $"Copying GPG keys from admin user to root"
|
||||||
|
cp -r /home/$ADMIN_USERNAME/.gnupg /root
|
||||||
|
}
|
||||||
|
|
||||||
function restore_directory_from_usb {
|
function restore_directory_from_usb {
|
||||||
BACKUP_CERTIFICATE=/etc/ssl/private/backup.key
|
|
||||||
if [ ! -d ${1} ]; then
|
if [ ! -d ${1} ]; then
|
||||||
mkdir ${1}
|
mkdir ${1}
|
||||||
fi
|
fi
|
||||||
|
@ -109,15 +164,13 @@ function restore_database {
|
||||||
if [ ! -f /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/${1}.sql ]; then
|
if [ ! -f /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/${1}.sql ]; then
|
||||||
echo $"Unable to restore ${1} database"
|
echo $"Unable to restore ${1} database"
|
||||||
rm -rf /root/temp${1}data
|
rm -rf /root/temp${1}data
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 503
|
exit 503
|
||||||
fi
|
fi
|
||||||
mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD ${1} -o < /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/${1}.sql)
|
mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD ${1} -o < /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/${1}.sql)
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
echo "$mysqlsuccess"
|
echo "$mysqlsuccess"
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 964
|
exit 964
|
||||||
fi
|
fi
|
||||||
shred -zu /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/*
|
shred -zu /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/*
|
||||||
|
@ -134,8 +187,7 @@ function restore_database {
|
||||||
rm -rf /var/www/${2}/htdocs
|
rm -rf /var/www/${2}/htdocs
|
||||||
mv /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs /var/www/${2}/
|
mv /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs /var/www/${2}/
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 683
|
exit 683
|
||||||
fi
|
fi
|
||||||
if [ -d /etc/letsencrypt/live/${2} ]; then
|
if [ -d /etc/letsencrypt/live/${2} ]; then
|
||||||
|
@ -153,6 +205,65 @@ function restore_database {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function update_domains {
|
||||||
|
if grep -q "GNU Social domain" $COMPLETION_FILE; then
|
||||||
|
MICROBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "GNU Social domain" | awk -F ':' '{print $2}')
|
||||||
|
fi
|
||||||
|
if grep -q "Hubzilla domain" $COMPLETION_FILE; then
|
||||||
|
HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
|
||||||
|
fi
|
||||||
|
if grep -q "Owncloud domain" $COMPLETION_FILE; then
|
||||||
|
OWNCLOUD_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Owncloud domain" | awk -F ':' '{print $2}')
|
||||||
|
fi
|
||||||
|
if grep -q "Gogs domain" $COMPLETION_FILE; then
|
||||||
|
GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}')
|
||||||
|
fi
|
||||||
|
if [ -d $USB_MOUNT/backup/wiki ]; then
|
||||||
|
WIKI_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Wiki domain" | awk -F ':' '{print $2}')
|
||||||
|
fi
|
||||||
|
if [ -d $USB_MOUNT/backup/blog ]; then
|
||||||
|
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function restore_configuration {
|
||||||
|
# this restores *.cfg and COMPLETION_FILE
|
||||||
|
if [ -d $USB_MOUNT/backup/config ]; then
|
||||||
|
echo $"Restoring configuration files"
|
||||||
|
restore_directory_from_usb /root/tempconfig config
|
||||||
|
cp -f /root/tempconfig/root/${PROJECT_NAME}.cfg /homeroot/${PROJECT_NAME}.cfg
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
unmount_drive
|
||||||
|
rm -rf /root/tempconfig
|
||||||
|
exit 5294
|
||||||
|
fi
|
||||||
|
cp -f /root/tempconfig/root/${PROJECT_NAME}-completed.txt /root/${PROJECT_NAME}-completed.txt
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
unmount_drive
|
||||||
|
rm -rf /root/tempconfig
|
||||||
|
exit 6382
|
||||||
|
fi
|
||||||
|
rm -rf /root/tempconfig
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function same_admin_user {
|
||||||
|
PREV_ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
|
||||||
|
if [[ "$PREV_ADMIN_USERNAME" != "$ADMIN_USERNAME" ]]; then
|
||||||
|
echo $"The admin username has changed from $PREV_ADMIN_USERNAME to $ADMIN_USERNAME. To restore you will first need to install a new ${PROJECT_NAME} system with an initial admin user named $PREV_ADMIN_USERNAME"
|
||||||
|
unmount_drive
|
||||||
|
exit 73265
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
mount_drive $1 $2
|
||||||
|
check_backup_exists
|
||||||
|
check_admin_user
|
||||||
|
copy_gpg_keys
|
||||||
|
restore_configuration
|
||||||
|
same_admin_user
|
||||||
|
update_domains
|
||||||
|
|
||||||
# Make a backup of the original README file
|
# Make a backup of the original README file
|
||||||
# incase old passwords need to be used
|
# incase old passwords need to be used
|
||||||
if [ -f /home/$ADMIN_USERNAME/README ]; then
|
if [ -f /home/$ADMIN_USERNAME/README ]; then
|
||||||
|
@ -179,8 +290,7 @@ if [ -d $USB_MOUNT/backup/mariadb ]; then
|
||||||
fi
|
fi
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
echo "$mysqlsuccess"
|
echo "$mysqlsuccess"
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 962
|
exit 962
|
||||||
fi
|
fi
|
||||||
echo $"Restarting database"
|
echo $"Restarting database"
|
||||||
|
@ -217,9 +327,8 @@ if [ -d $USB_MOUNT/backup/mutt ]; then
|
||||||
cp -f /root/tempmutt/home/$USERNAME/tempbackup/Muttrc /etc/Muttrc
|
cp -f /root/tempmutt/home/$USERNAME/tempbackup/Muttrc /etc/Muttrc
|
||||||
fi
|
fi
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
rm -rf /root/tempmutt
|
rm -rf /root/tempmutt
|
||||||
|
unmount_drive
|
||||||
exit 276
|
exit 276
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempmutt
|
rm -rf /root/tempmutt
|
||||||
|
@ -238,17 +347,15 @@ if [ -d $USB_MOUNT/backup/gnupg ]; then
|
||||||
restore_directory_from_usb /root/tempgnupg gnupg/$USERNAME
|
restore_directory_from_usb /root/tempgnupg gnupg/$USERNAME
|
||||||
cp -r /root/tempgnupg/home/$USERNAME/.gnupg /home/$USERNAME/
|
cp -r /root/tempgnupg/home/$USERNAME/.gnupg /home/$USERNAME/
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
rm -rf /root/tempgnupg
|
rm -rf /root/tempgnupg
|
||||||
|
unmount_drive
|
||||||
exit 276
|
exit 276
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempgnupg
|
rm -rf /root/tempgnupg
|
||||||
if [[ "$USERNAME" == "$ADMIN_USERNAME" ]]; then
|
if [[ "$USERNAME" == "$ADMIN_USERNAME" ]]; then
|
||||||
cp -r /home/$USERNAME/.gnupg /root
|
cp -r /home/$USERNAME/.gnupg /root
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 283
|
exit 283
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -267,9 +374,8 @@ if [ -d $USB_MOUNT/backup/procmail ]; then
|
||||||
restore_directory_from_usb /root/tempprocmail procmail/$USERNAME
|
restore_directory_from_usb /root/tempprocmail procmail/$USERNAME
|
||||||
cp -f /root/tempprocmail/home/$USERNAME/tempbackup/.procmailrc /home/$USERNAME/
|
cp -f /root/tempprocmail/home/$USERNAME/tempbackup/.procmailrc /home/$USERNAME/
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
rm -rf /root/tempprocmail
|
rm -rf /root/tempprocmail
|
||||||
|
unmount_drive
|
||||||
exit 276
|
exit 276
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempprocmail
|
rm -rf /root/tempprocmail
|
||||||
|
@ -289,9 +395,8 @@ if [ -d $USB_MOUNT/backup/spamassassin ]; then
|
||||||
restore_directory_from_usb /root/tempspamassassin spamassassin/$USERNAME
|
restore_directory_from_usb /root/tempspamassassin spamassassin/$USERNAME
|
||||||
cp -rf /root/tempspamassassin/home/$USERNAME/.spamassassin /home/$USERNAME/
|
cp -rf /root/tempspamassassin/home/$USERNAME/.spamassassin /home/$USERNAME/
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
rm -rf /root/tempspamassassin
|
rm -rf /root/tempspamassassin
|
||||||
|
unmount_drive
|
||||||
exit 276
|
exit 276
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempspamassassin
|
rm -rf /root/tempspamassassin
|
||||||
|
@ -305,9 +410,8 @@ if [ -d $USB_MOUNT/backup/readme ]; then
|
||||||
restore_directory_from_usb /root/tempreadme readme
|
restore_directory_from_usb /root/tempreadme readme
|
||||||
cp -f /root/tempreadme/home/$ADMIN_USERNAME/tempbackup/README /home/$ADMIN_USERNAME/
|
cp -f /root/tempreadme/home/$ADMIN_USERNAME/tempbackup/README /home/$ADMIN_USERNAME/
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
rm -rf /root/tempreadme
|
rm -rf /root/tempreadme
|
||||||
|
unmount_drive
|
||||||
exit 276
|
exit 276
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempreadme
|
rm -rf /root/tempreadme
|
||||||
|
@ -318,9 +422,8 @@ if [ -d $USB_MOUNT/backup/ipfs ]; then
|
||||||
restore_directory_from_usb /root/tempipfs ipfs
|
restore_directory_from_usb /root/tempipfs ipfs
|
||||||
cp -rf /root/tempipfs/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs
|
cp -rf /root/tempipfs/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
rm -rf /root/tempipfs
|
rm -rf /root/tempipfs
|
||||||
|
unmount_drive
|
||||||
exit 276
|
exit 276
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempipfs
|
rm -rf /root/tempipfs
|
||||||
|
@ -337,9 +440,8 @@ if [ -d $USB_MOUNT/backup/ssh ]; then
|
||||||
restore_directory_from_usb /root/tempssh ssh/$USERNAME
|
restore_directory_from_usb /root/tempssh ssh/$USERNAME
|
||||||
cp -r /root/tempssh/home/$USERNAME/.ssh /home/$USERNAME/
|
cp -r /root/tempssh/home/$USERNAME/.ssh /home/$USERNAME/
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
rm -rf /root/tempssh
|
rm -rf /root/tempssh
|
||||||
|
unmount_drive
|
||||||
exit 664
|
exit 664
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempssh
|
rm -rf /root/tempssh
|
||||||
|
@ -358,9 +460,8 @@ if [ -d $USB_MOUNT/backup/config ]; then
|
||||||
restore_directory_from_usb /root/tempconfig config/$USERNAME
|
restore_directory_from_usb /root/tempconfig config/$USERNAME
|
||||||
cp -r /root/tempconfig/home/$USERNAME/.config /home/$USERNAME/
|
cp -r /root/tempconfig/home/$USERNAME/.config /home/$USERNAME/
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
rm -rf /root/tempconfig
|
rm -rf /root/tempconfig
|
||||||
|
unmount_drive
|
||||||
exit 664
|
exit 664
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempconfig
|
rm -rf /root/tempconfig
|
||||||
|
@ -374,8 +475,7 @@ if [ -d $USB_MOUNT/backup/ssl ]; then
|
||||||
restore_directory_from_usb /root/tempssl ssl
|
restore_directory_from_usb /root/tempssl ssl
|
||||||
cp -r /root/tempssl/etc/ssl/* /etc/ssl
|
cp -r /root/tempssl/etc/ssl/* /etc/ssl
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 276
|
exit 276
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempssl
|
rm -rf /root/tempssl
|
||||||
|
@ -395,8 +495,7 @@ if [ -d $USB_MOUNT/backup/projects ]; then
|
||||||
fi
|
fi
|
||||||
mv /root/tempprojects/home/$USERNAME/projects /home/$USERNAME
|
mv /root/tempprojects/home/$USERNAME/projects /home/$USERNAME
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 166
|
exit 166
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempprojects
|
rm -rf /root/tempprojects
|
||||||
|
@ -419,8 +518,7 @@ if [ -d $USB_MOUNT/backup/personal ]; then
|
||||||
fi
|
fi
|
||||||
mv /root/temppersonal/home/$USERNAME/personal /home/$USERNAME
|
mv /root/temppersonal/home/$USERNAME/personal /home/$USERNAME
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 184
|
exit 184
|
||||||
fi
|
fi
|
||||||
rm -rf /root/temppersonal
|
rm -rf /root/temppersonal
|
||||||
|
@ -434,8 +532,7 @@ if [ -d /var/spool/mlmmj ]; then
|
||||||
restore_directory_from_usb /root/tempmailinglist mailinglist
|
restore_directory_from_usb /root/tempmailinglist mailinglist
|
||||||
cp -r /root/tempmailinglist/root/spool/mlmmj/* /var/spool/mlmmj
|
cp -r /root/tempmailinglist/root/spool/mlmmj/* /var/spool/mlmmj
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 526
|
exit 526
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempmailinglist
|
rm -rf /root/tempmailinglist
|
||||||
|
@ -446,8 +543,7 @@ if [ -d /var/lib/prosody ]; then
|
||||||
restore_directory_from_usb /root/tempxmpp xmpp
|
restore_directory_from_usb /root/tempxmpp xmpp
|
||||||
cp -r /root/tempxmpp/var/lib/prosody/* /var/lib/prosody
|
cp -r /root/tempxmpp/var/lib/prosody/* /var/lib/prosody
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 725
|
exit 725
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempxmpp
|
rm -rf /root/tempxmpp
|
||||||
|
@ -456,8 +552,7 @@ if [ -d /var/lib/prosody ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restoring GNU Social
|
# Restoring GNU Social
|
||||||
if grep -q "GNU Social domain" $COMPLETION_FILE; then
|
if [ $MICROBLOG_DOMAIN_NAME ]; then
|
||||||
MICROBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "GNU Social domain" | awk -F ':' '{print $2}')
|
|
||||||
restore_database gnusocial ${MICROBLOG_DOMAIN_NAME}
|
restore_database gnusocial ${MICROBLOG_DOMAIN_NAME}
|
||||||
if [ -d /root/tempgnusocial ]; then
|
if [ -d /root/tempgnusocial ]; then
|
||||||
rm -rf /root/tempgnusocial
|
rm -rf /root/tempgnusocial
|
||||||
|
@ -465,8 +560,7 @@ if grep -q "GNU Social domain" $COMPLETION_FILE; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restoring hubzilla
|
# Restoring hubzilla
|
||||||
if grep -q "Hubzilla domain" $COMPLETION_FILE; then
|
if [ $HUBZILLA_DOMAIN_NAME ]; then
|
||||||
HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
|
|
||||||
restore_database hubzilla ${HUBZILLA_DOMAIN_NAME}
|
restore_database hubzilla ${HUBZILLA_DOMAIN_NAME}
|
||||||
if [ -d $USB_MOUNT/backup/hubzilla ]; then
|
if [ -d $USB_MOUNT/backup/hubzilla ]; then
|
||||||
if [ ! -d /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3 ]; then
|
if [ ! -d /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3 ]; then
|
||||||
|
@ -480,15 +574,13 @@ if grep -q "Hubzilla domain" $COMPLETION_FILE; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if grep -q "Owncloud domain" $COMPLETION_FILE; then
|
if [ $OWNCLOUD_DOMAIN_NAME ]; then
|
||||||
OWNCLOUD_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Owncloud domain" | awk -F ':' '{print $2}')
|
|
||||||
restore_database owncloud $OWNCLOUD_DOMAIN_NAME
|
restore_database owncloud $OWNCLOUD_DOMAIN_NAME
|
||||||
if [ -d $USB_MOUNT/backup/owncloud2 ]; then
|
if [ -d $USB_MOUNT/backup/owncloud2 ]; then
|
||||||
restore_directory_from_usb /root/tempowncloud2 owncloud2
|
restore_directory_from_usb /root/tempowncloud2 owncloud2
|
||||||
cp -r /root/tempowncloud2/etc/owncloud/* /etc/owncloud/
|
cp -r /root/tempowncloud2/etc/owncloud/* /etc/owncloud/
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 982
|
exit 982
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempowncloud
|
rm -rf /root/tempowncloud
|
||||||
|
@ -506,8 +598,7 @@ if grep -q "Owncloud domain" $COMPLETION_FILE; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if grep -q "Gogs domain" $COMPLETION_FILE; then
|
if [ $GIT_DOMAIN_NAME ]; then
|
||||||
GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}')
|
|
||||||
restore_database gogs ${GIT_DOMAIN_NAME}
|
restore_database gogs ${GIT_DOMAIN_NAME}
|
||||||
if [ -d $USB_MOUNT/backup/gogs ]; then
|
if [ -d $USB_MOUNT/backup/gogs ]; then
|
||||||
echo $"Restoring Gogs settings"
|
echo $"Restoring Gogs settings"
|
||||||
|
@ -516,16 +607,14 @@ if grep -q "Gogs domain" $COMPLETION_FILE; then
|
||||||
fi
|
fi
|
||||||
cp -r /root/tempgogs/home/git/go/src/github.com/gogits/gogs/custom/* /home/git/go/src/github.com/gogits/gogs/custom
|
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
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 981
|
exit 981
|
||||||
fi
|
fi
|
||||||
echo $"Restoring Gogs repos"
|
echo $"Restoring Gogs repos"
|
||||||
restore_directory_from_usb /root/tempgogsrepos gogsrepos
|
restore_directory_from_usb /root/tempgogsrepos gogsrepos
|
||||||
cp -r /root/tempgogsrepos/home/git/gogs-repositories/* /home/git/gogs-repositories/
|
cp -r /root/tempgogsrepos/home/git/gogs-repositories/* /home/git/gogs-repositories/
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 67574
|
exit 67574
|
||||||
fi
|
fi
|
||||||
echo $"Restoring Gogs authorized_keys"
|
echo $"Restoring Gogs authorized_keys"
|
||||||
|
@ -535,8 +624,7 @@ if grep -q "Gogs domain" $COMPLETION_FILE; then
|
||||||
fi
|
fi
|
||||||
cp -r /root/tempgogsssh/home/git/.ssh/* /home/git/.ssh/
|
cp -r /root/tempgogsssh/home/git/.ssh/* /home/git/.ssh/
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 8463
|
exit 8463
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempgogs
|
rm -rf /root/tempgogs
|
||||||
|
@ -546,21 +634,18 @@ if grep -q "Gogs domain" $COMPLETION_FILE; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d $USB_MOUNT/backup/wiki ]; then
|
if [ $WIKI_DOMAIN_NAME ]; then
|
||||||
WIKI_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Wiki domain" | awk -F ':' '{print $2}')
|
|
||||||
echo $"Restoring Wiki installation ${WIKI_DOMAIN_NAME}"
|
echo $"Restoring Wiki installation ${WIKI_DOMAIN_NAME}"
|
||||||
restore_directory_from_usb /root/tempwiki wiki
|
restore_directory_from_usb /root/tempwiki wiki
|
||||||
cp -r /root/tempwiki/var/lib/dokuwiki/* /var/lib/dokuwiki/
|
cp -r /root/tempwiki/var/lib/dokuwiki/* /var/lib/dokuwiki/
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 868
|
exit 868
|
||||||
fi
|
fi
|
||||||
restore_directory_from_usb /root/tempwiki2 wiki2
|
restore_directory_from_usb /root/tempwiki2 wiki2
|
||||||
cp -r /root/tempwiki2/etc/dokuwiki/* /etc/dokuwiki/
|
cp -r /root/tempwiki2/etc/dokuwiki/* /etc/dokuwiki/
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 869
|
exit 869
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempwiki
|
rm -rf /root/tempwiki
|
||||||
|
@ -576,22 +661,19 @@ if [ -d $USB_MOUNT/backup/wiki ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d $USB_MOUNT/backup/blog ]; then
|
if [ $FULLBLOG_DOMAIN_NAME ]; then
|
||||||
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
|
||||||
echo $"Restoring blog installation"
|
echo $"Restoring blog installation"
|
||||||
restore_directory_from_usb /root/tempblog blog
|
restore_directory_from_usb /root/tempblog blog
|
||||||
rm -rf /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
rm -rf /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
||||||
cp -r /root/tempblog/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs /var/www/${FULLBLOG_DOMAIN_NAME}/
|
cp -r /root/tempblog/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs /var/www/${FULLBLOG_DOMAIN_NAME}/
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 593
|
exit 593
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempblog
|
rm -rf /root/tempblog
|
||||||
if [ ! -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content ]; then
|
if [ ! -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content ]; then
|
||||||
echo $"No content directory found after restoring blog"
|
echo $"No content directory found after restoring blog"
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 287
|
exit 287
|
||||||
fi
|
fi
|
||||||
chown -R www-data:www-data /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
chown -R www-data:www-data /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
|
||||||
|
@ -619,8 +701,7 @@ if [ -d $USB_MOUNT/backup/cjdns ]; then
|
||||||
rm -rf /etc/cjdns
|
rm -rf /etc/cjdns
|
||||||
cp -r /root/tempcjdns/etc/cjdns /etc/
|
cp -r /root/tempcjdns/etc/cjdns /etc/
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 8472
|
exit 8472
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempcjdns
|
rm -rf /root/tempcjdns
|
||||||
|
@ -640,8 +721,7 @@ if [ -d $USB_MOUNT/backup/mail ]; then
|
||||||
fi
|
fi
|
||||||
tar -xzvf /root/tempmail/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
|
tar -xzvf /root/tempmail/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 927
|
exit 927
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempmail
|
rm -rf /root/tempmail
|
||||||
|
@ -655,8 +735,8 @@ if [ -d /var/cache/minidlna ]; then
|
||||||
restore_directory_from_usb /root/tempdlna dlna
|
restore_directory_from_usb /root/tempdlna dlna
|
||||||
cp -r /root/tempdlna/var/cache/minidlna/* /var/cache/minidlna/
|
cp -r /root/tempdlna/var/cache/minidlna/* /var/cache/minidlna/
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
rm -rf /root/tempdlna
|
||||||
rm -rf $USB_MOUNT
|
unmount_drive
|
||||||
exit 982
|
exit 982
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempdlna
|
rm -rf /root/tempdlna
|
||||||
|
@ -668,23 +748,20 @@ if [ -d $USB_MOUNT/backup/voip ]; then
|
||||||
restore_directory_from_usb /root/tempvoip voip
|
restore_directory_from_usb /root/tempvoip voip
|
||||||
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
|
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
rm -rf /root/tempvoip
|
rm -rf /root/tempvoip
|
||||||
|
unmount_drive
|
||||||
exit 3679
|
exit 3679
|
||||||
fi
|
fi
|
||||||
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
|
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
rm -rf /root/tempvoip
|
rm -rf /root/tempvoip
|
||||||
|
unmount_drive
|
||||||
exit 3679
|
exit 3679
|
||||||
fi
|
fi
|
||||||
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
|
cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
rm -rf /root/tempvoip
|
rm -rf /root/tempvoip
|
||||||
|
unmount_drive
|
||||||
exit 276
|
exit 276
|
||||||
fi
|
fi
|
||||||
rm -rf /root/tempvoip
|
rm -rf /root/tempvoip
|
||||||
|
@ -699,45 +776,20 @@ if [ -d $USB_MOUNT/backup/tox ]; then
|
||||||
echo $"Restoring Tox node settings"
|
echo $"Restoring Tox node settings"
|
||||||
restore_directory_from_usb / tox
|
restore_directory_from_usb / tox
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 6393
|
exit 6393
|
||||||
fi
|
fi
|
||||||
cp /var/lib/tox-bootstrapd/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
|
cp /var/lib/tox-bootstrapd/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
|
||||||
systemctl restart tox-bootstrapd.service
|
systemctl restart tox-bootstrapd.service
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
systemctl status tox-bootstrapd.service
|
systemctl status tox-bootstrapd.service
|
||||||
umount $USB_MOUNT
|
unmount_drive
|
||||||
rm -rf $USB_MOUNT
|
|
||||||
exit 59369
|
exit 59369
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sync
|
unmount_drive
|
||||||
|
|
||||||
# Unmount the USB drive
|
echo $"Restore from USB drive is complete. You can now unplug it."
|
||||||
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
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue