X-Git-Url: https://iankelling.org/git/?p=automated-distro-installer;a=blobdiff_plain;f=fsf%2Fcrypt-disks-start;fp=fsf%2Fcrypt-disks-start;h=7e310da296875f1299f47de70f4e019bf7a27377;hp=0000000000000000000000000000000000000000;hb=137ffae7de84a51c4b438ccf2fb50f5571f522a6;hpb=14f283f82afc48d6cec1bb7498ec34ac2b0da77c diff --git a/fsf/crypt-disks-start b/fsf/crypt-disks-start new file mode 100755 index 0000000..7e310da --- /dev/null +++ b/fsf/crypt-disks-start @@ -0,0 +1,30 @@ +#!/bin/bash + +# usage: $0 +# this script is idempotent + +if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi +shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4 +set -eE -o pipefail +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR + +m() { printf "%s\n" "$*"; "$@"; } + + +lvs --noheadings -o vg_name,lv_name | while read -r vg lv; do + if [[ ! $vg || ! $lv ]]; then + continue + fi + if ! integritysetup dump /dev/$vg/$lv &>/dev/null; then + continue + fi + int_name=integrity-$vg-$lv + if integritysetup status $int_name &>/dev/null; then + continue + fi + m integritysetup open --allow-discards /dev/$vg/$lv $int_name +done + +awk '$1 !~ /^ *#/ {print $1}' /etc/crypttab | while read -r c; do + m cryptdisks_start $c +done