Created
August 10, 2016 08:15
An alias to verify that installed files are unchanged using dpkg package's md5sums
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
dpkg-verify() { | |
exitcode=0 | |
for file in $*; do | |
pkg=`dpkg -S "$file" | cut -d: -f 1` | |
hashfile="/var/lib/dpkg/info/$pkg.md5sums" | |
if [ -s "$hashfile" ]; then | |
rfile=`echo "$file" | cut -d/ -f 2-` | |
phash=`grep -E "$rfile\$" "$hashfile" | cut -d\ -f 1` | |
hash=`md5sum "$file" | cut -d\ -f 1` | |
if [ "$hash" = "$phash" ]; then | |
echo "$file: ok" | |
else | |
echo "$file: CHANGED" | |
exitcode=1 | |
fi | |
else | |
echo "$file: UNKNOWN" | |
exitcode=1 | |
fi | |
done | |
return $exitcode | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try it with installed
isc-dhcp-server
package, and use the/sbin/dhclient
then you'll find that dpkg picks upisc-dhcp-server-ddns
instead. Which is not supposed to happened, but it does... anyway.