Created
August 10, 2016 08:15
-
-
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
This file contains hidden or 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-serverpackage, and use the/sbin/dhclientthen you'll find that dpkg picks upisc-dhcp-server-ddnsinstead. Which is not supposed to happened, but it does... anyway.