#!/bin/sh
if [ "$#" -ne 1 ]; then
    exit 2
fi

PART_UUID=$1

IFS=','

while read -r uuid name algorithm
do
    if [ "$uuid" = "$PART_UUID" ]; then
        if [ ! -e "/dev/mapper/$name" ]; then
            integritysetup open "/dev/disk/by-partuuid/$PART_UUID" "$name" -I "$algorithm"
            exit $?
        else
            exit 0
        fi
    fi
done < /etc/integritytab

exit 1
