| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #!/bin/sh
- # Templated paths
- MAPPER="/dev/mapper"
- CRYPT_NAME="{{ luks_crypt_name }}"
- CRYPT_PATH="${MAPPER}/${CRYPT_NAME}"
- VG_NAME="{{ luks_vg_name }}"
- DEV="{{ luks_dev }}"
- # Sanity checks
- if [ ! -b "${DEV}" ]; then
- echo "Unable to find a suitable device" 1>&2
- exit 2
- fi
- # Determine if we need to format or just open
- FORMAT=0
- if basename "${0}" | grep -qi format; then
- FORMAT=1
- fi
- # Initial encryption
- if [ $FORMAT -gt 0 ]; then
- cryptsetup --type luks2 \
- --cipher aes-xts-plain64 \
- --hash sha512 \
- --key-size 512 \
- --sector-size 4096 \
- luksFormat "${DEV}"
- fi
- # Unlock
- cryptsetup luksOpen "${DEV}" "${CRYPT_NAME}"
- # Initial filesystem - note the big inodes for gluster
- if [ $FORMAT -gt 0 ]; then
- pvcreate "${CRYPT_PATH}"
- if [ $? != 0 ]; then
- echo "Unable to create LVM PV: ${CRYPT_PATH}" 1>&2
- exit 3
- fi
- vgcreate "${VG_NAME}" "${CRYPT_PATH}"
- if [ $? != 0 ]; then
- echo "Unable to create LVM VG: ${VG_NAME}" 1>&2
- exit 3
- fi
- fi
|