#!/bin/sh if [ $(id -u) -ne 0 ]; then echo "This must be run as root." 1>&2 exit 1 fi if [ "$1" = "" ]; then echo "Must provide a disk as the first parameter." 1>&2 exit 1 fi if [ "$2" = "" ]; then echo "Must provide key file as a second parameter." 1>&2 exit 1 fi if [ \! -b $1 ]; then echo "The first parameter must be a block device representing an empty disk." 1>&2 exit 1 fi if [ "$(partx -l $1)" != "" ]; then partx -l $1 1>&2 echo "The disk must not have a partition table." 1>&2 exit 1 fi disk=$1 keyfile=$2 # Create key file, if necessary. if [ \! -e $2 ]; then oldumask=$(umask) umask 077 dd if=/dev/random of=$2 bs=1 count=256 chmod 0500 $2 umask $oldumask fi # Check and randomize disk. badblocks -b 512 -s -w -t random -v $disk || exit 2 /backups/1/postgresql/dump' postgres mysqldump -v --all-databases >/backups/1/mysql/dump echo -n "Hit enter when rivana is backed up. " read foo # Deactivate the encrypted volume. umount /backups cryptsetup luksClose backups # Add user password. cryptsetup --key-file $keyfile --verify-passphrase luksAddKey ${disk}1 # Display the partition's UUID. echo -n 'UUID: ' cryptsetup luksUUID ${disk}1