Differences

This shows you the differences between two versions of the page.

Link to this comparison view

genmd5 [2014/10/26 01:52] (current)
Line 1: Line 1:
 +== Generate and Validate MD5 of a folder ==
  
 +  * The following bash script generates MD5 hash for a folder using the Unix find command
 +
 +<code bash>
 +#!/bin/bash
 +# gen.sh
 +CRCFILE=allcrc.md5
 +echo $CRCFILE
 +chmod u+rwx $CRCFILE
 +find /​path/​to/​html -type f -exec /​usr/​bin/​md5sum {} \; > $CRCFILE
 +#find ../html -type f -exec /​usr/​bin/​md5sum {} \; > $CRCFILE
 +chmod go-rwx $CRCFILE
 +chmod u-wx $CRCFILE
 +</​code>​
 +
 +  * The following bash script validates the MD5 hash for the same folder, the intention of this is to be run from cron
 +
 +<code bash>
 +#!/bin/bash
 +# check.sh
 +CRCFILE=allcrc.md5
 +echo $CRCFILE
 +LINES=`/​usr/​bin/​md5sum -c $CRCFILE | grep -v OK`
 +echo $LINES
 +</​code>​
 +
 +If run from cron with a MAILTO option, then whenever it is run, it will email results.
 +
 +<code bash>
 +MAILTO="​user@mydomain.com"​
 +# 1 Daily_CRC_Check
 +50 1 * * * /​path/​to/​check.sh
 +</​code>​
genmd5.txt ยท Last modified: 2014/10/26 01:52 (external edit)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0