Skip to content

Instantly share code, notes, and snippets.

@orrisroot
Last active December 3, 2021 08:33
Show Gist options
  • Save orrisroot/3bcf4a6e4af644faec636bd375962874 to your computer and use it in GitHub Desktop.
Save orrisroot/3bcf4a6e4af644faec636bd375962874 to your computer and use it in GitHub Desktop.
configuration check script after update rpm packages
#!/bin/bash
# VERSION:20211203
_uid=$(id -u)
if test $_uid -ne 0; then
echo "Error : This script have to run as root"
exit 1
fi
_search_path="/boot /etc /var /opt /usr/lib /usr/share"
_exclude_path="/var/named/chroot /var/lib/mock /var/lib/docker /var/lib/containers"
_find_opts="${_search_path}"
for i in ${_exclude_path}; do
_find_opts="${_find_opts} -path ${i} -prune -o"
done
for i in $(find ${_find_opts} -name '*.rpmsave'); do
for j in ${_exclude_path}; do
if test $i = $j; then continue 2; fi
done
ORIG=$(echo $i | sed -e 's+.rpmsave++g')
diff -u $i $ORIG > /dev/null 2>&1
if test $? -eq 0; then
rm -f $i
echo $i is not changed - removed
else
echo $i found.
fi
done
for i in $(find ${_find_opts} -name '*.rpmnew'); do
for j in ${_exclude_path}; do
if test $i = $j; then continue 2; fi
done
ORIG=$(echo $i | sed -e 's+.rpmnew++g')
diff -u $i $ORIG > /dev/null 2>&1
if test $? -eq 0; then
rm -f $i
echo $i is not changed - removed
else
echo $i has been changed.
fi
done
KERNEL_MODULES=$(ls /lib/modules/)
for i in $KERNEL_MODULES; do
j=/lib/modules/$i
if test -d $j; then
FILES=`find $j/ -type f`
if test -z "$FILES"; then
rm -rf $j
echo $j is empty kernel module directory - deleted
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment