Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An alias to verify that installed files are unchanged using dpkg package's md5sums
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
}
@egberts

This comment has been minimized.

Copy link

commented Dec 13, 2018

Try it with installed isc-dhcp-server package, and use the /sbin/dhclient then you'll find that dpkg picks up isc-dhcp-server-ddns instead. Which is not supposed to happened, but it does... anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.