Created
January 11, 2012 15:42
-
-
Save weavenet/1595238 to your computer and use it in GitHub Desktop.
Script To Remove Non Whitelists RPMs
This file contains 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
#!/bin/bash | |
whitelist=ami_rpm_whitelist.txt | |
# List rpms to installed rpmts | |
rpm -q -a > /tmp/installed_rpms | |
# create white list file of rpms installed on the given whitelist | |
for i in `cat $whitelist |tr -d '\r'`; do | |
egrep ^$i /tmp/installed_rpms | |
done |uniq > /tmp/whitelist_installed_rpms | |
# If a given install rpm is not in the whitelisted rpms, remove it | |
for i in `cat /tmp/installed_rpms | tr '++' '..'`; do | |
egrep $i /tmp/whitelist_installed_rpms > /dev/null | |
if [ $? -ne 0 ]; then | |
yum -y erase $i | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment