#!/bin/bash

echo YES|cryptsetup -v luksFormat  -c aes-cbc-plain  --key-file  /opt/ucas-key /dev/sda1
echo YES|cryptsetup -v luksFormat  -c aes-cbc-plain  --key-file  /opt/ucas-key /dev/sdb1
echo YES|cryptsetup -v luksFormat  -c aes-cbc-plain  --key-file  /opt/ucas-key /dev/sdc1
echo YES|cryptsetup -v luksFormat  -c aes-cbc-plain  --key-file  /opt/ucas-key /dev/sdd1

sleep 1

cryptsetup luksOpen --key-file  /opt/ucas-key /dev/sda1 cda1
cryptsetup luksOpen --key-file  /opt/ucas-key /dev/sdb1 cdb1
cryptsetup luksOpen --key-file  /opt/ucas-key /dev/sdc1 cdc1
cryptsetup luksOpen --key-file  /opt/ucas-key /dev/sdd1 cdd1

sleep 1

mkfs.ext4  /dev/mapper/cda1
mkfs.ext4  /dev/mapper/cdb1
mkfs.ext4  /dev/mapper/cdc1
mkfs.ext4  /dev/mapper/cdd1

sleep 1

mount /dev/mapper/cda1 /opt/storage/data1
mount /dev/mapper/cdb1 /opt/storage/data2
mount /dev/mapper/cdc1 /opt/storage/data3
mount /dev/mapper/cdd1 /opt/storage/data4
