Skip to content

Instantly share code, notes, and snippets.

@Magentron
Created August 10, 2016 08:15
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Magentron/e9a85ffebd07bdf29047218fc68e31f6 to your computer and use it in GitHub Desktop.
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
Copy link

egberts 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