Usage of HashDeep (apt install hashdeep)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Files changed or deleted since checksum creation are noted. | |
# New files are not noted. | |
if [ -z "$1" ]; then | |
DIR=`pwd` | |
else | |
DIR=`realpath $1` | |
fi | |
cd $DIR | |
FILE=checksums.sha1 | |
if [ -f $FILE ]; then | |
echo "Checking files in directory" $DIR "against checksums in file" $FILE | |
sha1sum --check --quiet --strict $FILE | |
if [ $? -eq 0 ]; then echo "OK"; fi | |
else | |
echo "Creating checksums file" | |
# find . -type f ! -name "*.sha1" -print0|xargs -0 sha1sum >$FILE | |
find . -type f ! -name "*.sha1" -exec sha1sum "{}" \; >>$FILE | |
echo $FILE "has been created in" $DIR | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This is a generic script which can be copied into any level of any | |
# directory tree which should be manually audited for file changes. | |
DIR=$(dirname `realpath $0`) | |
FILE=".checksums" | |
echo Scanning $DIR | |
cd $DIR | |
if [ -f $FILE ]; then | |
hashdeep -l -r -o f -k $FILE -a -vv * | |
else | |
hashdeep -l -r -o f * >$FILE | |
echo $FILE "has been generated in" $DIR | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment