#!/bin/sh

script_dir="$(dirname "$(realpath "$0")")"

read -p "Provide the path to PGP certificates which will be used for the ceremony: " relative_path

directory_path="$script_dir/$relative_path"

if [ ! -d "$directory_path" ]; then
echo "Directory does not exist. Please enter a valid directory path."
exit 1
fi

for file in "$directory_path"/*; do
if [ -f "$file" ]; then
    echo "Processing file: $file"
    gpg --import --import-options import-show $file
fi
done

read -p "Do the PGP key IDs match what you expect? (y/n): " matches_expectation

if [ $matches_expectation != "y" ]; then
echo "Ceasing ceremony as PGP key IDs don't match"
exit 1
fi

keyfork bottoms-up --threshold 2 --output-cert /media/cert --output-shardfile /media/shardfile --user-id "Distrust Key Ceremony" /media/public-certificates/
