Emacs placeholders

This commit is contained in:
Bob Mottram 2016-07-07 10:59:39 +01:00
parent 6beae8d5f3
commit 6b287ba099
No known key found for this signature in database
GPG Key ID: BA68F26108DC9F87
3 changed files with 72 additions and 66 deletions

View File

@ -31,15 +31,15 @@
VARIANTS='all' VARIANTS='all'
function upgrade_emacs { function upgrade_emacs {
echo '' echo -n ''
} }
function backup_local_emacs { function backup_local_emacs {
echo '' echo -n ''
} }
function backup_remote_emacs { function backup_remote_emacs {
echo '' echo -n ''
} }
function remove_emacs { function remove_emacs {

View File

@ -97,66 +97,6 @@ function update_domains {
fi fi
} }
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
rm -rf /dev/mapper/encrypted_usb
fi
cryptsetup luksClose encrypted_usb
# mount the encrypted backup drive
cryptsetup luksOpen $USB_DRIVE encrypted_usb
if [ "$?" = "0" ]; then
USB_DRIVE=/dev/mapper/encrypted_usb
fi
mount $USB_DRIVE $USB_MOUNT
if [ ! "$?" = "0" ]; then
echo $"There was a problem mounting the USB drive to $USB_MOUNT"
rm -rf $USB_MOUNT
exit 2
fi
}
function unmount_drive {
sync
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
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 $"Backup to USB drive is complete. You can now unplug it."
}
function backup_database { function backup_database {
if [ ${#DATABASE_PASSWORD} -lt 2 ]; then if [ ${#DATABASE_PASSWORD} -lt 2 ]; then
echo $"No MariaDB password was given" echo $"No MariaDB password was given"
@ -452,7 +392,7 @@ function remove_backup_directory {
if [ -d $USB_MOUNT/backup ]; then if [ -d $USB_MOUNT/backup ]; then
rm -rf $USB_MOUNT/backup rm -rf $USB_MOUNT/backup
echo $'Existing backup directory removed' echo $'Existing backup directory removed'
unmount_drive backup_unmount_drive
exit 0 exit 0
fi fi
fi fi
@ -603,7 +543,7 @@ if [[ $1 == "remove" ]]; then
remove_option=$1 remove_option=$1
fi fi
mount_drive $1 $2 backup_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
@ -616,6 +556,6 @@ backup_admin_readme
backup_voip backup_voip
backup_mariadb backup_mariadb
backup_extra_directories backup_extra_directories
unmount_drive backup_unmount_drive $USB_DRIVE $USB_MOUNT
exit 0 exit 0

View File

@ -96,4 +96,70 @@ function backup_to_friends_servers {
chmod +x /etc/cron.daily/backuptofriends chmod +x /etc/cron.daily/backuptofriends
} }
function backup_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
rm -rf /dev/mapper/encrypted_usb
fi
cryptsetup luksClose encrypted_usb
# mount the encrypted backup drive
cryptsetup luksOpen $USB_DRIVE encrypted_usb
if [ "$?" = "0" ]; then
USB_DRIVE=/dev/mapper/encrypted_usb
fi
mount $USB_DRIVE $USB_MOUNT
if [ ! "$?" = "0" ]; then
echo $"There was a problem mounting the USB drive to $USB_MOUNT"
rm -rf $USB_MOUNT
exit 783452
fi
}
function backup_unmount_drive {
if [ $1 ]; then
USB_DRIVE=${1}
if [ $2 ]; then
USB_MOUNT=${2}
fi
fi
sync
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
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 $"Backup to USB drive is complete. You can now unplug it."
}
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0