18 lines
607 B
Bash
18 lines
607 B
Bash
#!/bin/bash
|
|
|
|
TEMPLATE_FILE="$(dirname $0)/verify-script.template"
|
|
|
|
# TODO: argument for the message in case you want to apply it to many files.
|
|
read -p "Enter message to sign for the file: " MESSAGE
|
|
MESSAGE="$MESSAGE\n"
|
|
#echo "message: $MESSAGE"
|
|
|
|
FILE_NAME="$(basename $1)"
|
|
#echo "file name: $FILE_NAME"
|
|
FILE_HASH="$(sha256sum $FILE_NAME | awk '{print $1}')"
|
|
#echo "file hash: $FILE_HASH"
|
|
|
|
SUBSTITUTED_TEMPLATE=$(sed -e "s!{message}!$MESSAGE!g" -e "s!{filename}!$FILE_NAME!g" -e "s!{filehash}!$FILE_HASH!g" $TEMPLATE_FILE)
|
|
|
|
#echo "substituted: $SUBSTITUTED_TEMPLATE"
|
|
printf "$SUBSTITUTED_TEMPLATE" > "$1.sh" |