Recently I had to struggle to find out a way to verify if a file which belongs to an RPM is modified or not. After searching a bit on google I found that there is a option in "rpm" tool to verify all the files but there is no direct way to find if a particular file is modified. So, I decided to create a function which can help me doing that.
function isFileModified {
Explanation:
rpm -Vf $FILE : Returns list of all the files which got modified in the RPM package.
grep $FILE : Check if the file to be checked is in the list of modified file.
awk -F" " '{print $1}' : Truncates the attributes of the provided file
grep -e ".*5.*" : Check if the md5 digest of the file is changed.
So, the functions returns 0 if the file's md5 digect is changed after it is installed by the RPM. Else it will return 0.
Thanks,
Agry
function isFileModified {
FILE=$1
if rpm -Vf $FILE | grep $FILE >/dev/null 2>&1 && rpm -Vf $FILE | grep $FILE \
| awk -F" " '{print $1}' | grep -e ".*5.*" >/dev/null 2>&1; then
return 0
else
return 1
fi
}
Explanation:
rpm -Vf $FILE : Returns list of all the files which got modified in the RPM package.
grep $FILE : Check if the file to be checked is in the list of modified file.
awk -F" " '{print $1}' : Truncates the attributes of the provided file
grep -e ".*5.*" : Check if the md5 digest of the file is changed.
So, the functions returns 0 if the file's md5 digect is changed after it is installed by the RPM. Else it will return 0.
Thanks,
Agry
No comments:
Post a Comment