#!/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