You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
807 B

#!/bin/bash
blargityblargblarg &> /dev/null
while [ ${?} != 0 ]; do
sudo echo 'test' > /dev/null
done
COUNT=$(sudo grep -c "${1}" /etc/crypttab)
[[ ${COUNT} -eq 0 ]] && echo "Identifier '${1}' not found." && exit 1
[[ ${COUNT} -gt 1 ]] && echo "Identifier '${1}' is not unique." && exit 1
CTLINE=$(sudo grep "${1}" /etc/crypttab)
echo "Identifier '${1}' found in the following line:"
echo "${CTLINE}"
MPNAME=$(sudo grep "${1}" /etc/crypttab | sed 's/#//g;s/ */ /g;s/ /\t/g' | awk '{ print $1 }')
DEVICE=$(sudo grep "${1}" /etc/crypttab | sed 's/#//g;s/ */ /g;s/ /\t/g;s/UUID=/\/dev\/disk\/by-uuid\//g' | awk '{ print $2 }')
KEYFIL=$(sudo grep "${1}" /etc/crypttab | sed 's/#//g;s/ */ /g;s/ /\t/g' | awk '{ print $3 }')
set -x
sudo cryptsetup open "${DEVICE}" "${MPNAME}" --key-file "${KEYFIL}"