Files
create-file-message/verify-script.template
Nathan Christopher McRae e6c331575a Make target file relative to script file
Since we expect them to be in the same directory
2025-11-24 12:07:34 -08:00

29 lines
956 B
Bash

#!/bin/env sh
# This script should have come along with two files:
# * The target file '{filename}'
# * The signature file '{filename}.sh.sig'
# (or this file should have been signed in some other way)
#
# First, you should verify that this file came from the person you expect by
# verifying the signature.
#
# Next, you should run this script which will check that the target file
# matches the hash that was calculated when the message below was written.
# This will confirm that the file you have matches the file the message was
# written about.
#
# Alternatively, if you don't want to run this script, you can verify the
# hash manually.
MESSAGE="{message}"
FILE="{filename}"
FILE_PATH="$(dirname "$0")/$FILE"
EXPECTED_HASH="{filehash}"
if [ "$(sha256sum "$FILE_PATH" | awk '{print $1}')" = "$EXPECTED_HASH" ]; then
printf "File %s validated with message:\\n%s" "$FILE" "$MESSAGE"
exit 0
else
echo "File $FILE is not valid"
exit 1
fi