bstinson / centos / t_functional

Forked from centos/t_functional 4 years ago
Clone

Blame utils/cleanup_vm.sh

Karanbir Singh 5071b0
#!/bin/sh
Karanbir Singh 5071b0
Karanbir Singh 5071b0
# you will almost never want to run this script.
Karanbir Singh 5071b0
# $1 = file name ( full path ) with rpms to retain
Karanbir Singh 5071b0
Karanbir Singh 5071b0
rm /tmp/yum-cleanup
Karanbir Singh 5071b0
Karanbir Singh 5071b0
for f in `rpm -qa`; do 
Karanbir Singh 5071b0
  pn=$(rpm --qf "|%{name}|" -q $f)
Karanbir Singh 5071b0
  if [ `grep $pn $1 | wc -l ` -lt 1 ] ; then 
Karanbir Singh 5071b0
    echo 'erase ' $f  >> /tmp/yum-cleanup 
Karanbir Singh 5071b0
  fi
Karanbir Singh 5071b0
done
Karanbir Singh 5071b0
cat $1 | sed -e 's/|//g' | sed -e 's/^/install /' >> /tmp/yum-cleanup
Karanbir Singh 5071b0
Karanbir Singh 5071b0
if [ `uname -m` = 'x86_64' ]; then
Karanbir Singh 5071b0
  yum -y erase *.i?86
Karanbir Singh 5071b0
  yum -y --exclude=*.i?86 shell /tmp/yum-cleanup
Karanbir Singh 5071b0
else
Karanbir Singh 5071b0
  yum -y shell /tmp/yum-cleanup
Karanbir Singh 5071b0
fi
Karanbir Singh 5071b0
Karanbir Singh 5071b0
yum -y reinstall \*
Karanbir Singh 5071b0
cd /etc
Athmane Madjoudj 421a79
for x in `find . -maxdepth 2 -type f -name \*.rpmnew`; do
Karanbir Singh 5071b0
  a=$( echo $x | sed -e 's/.rpmnew//' )
Karanbir Singh 5071b0
  rm -f $a
Karanbir Singh 5071b0
  mv $x $a
Karanbir Singh 5071b0
done
Athmane Madjoudj ed3546
Athmane Madjoudj b9fbb5
# Package specific cleanup 
Athmane Madjoudj b9fbb5
# Clean pgsql data dir
Athmane Madjoudj b9fbb5
(rpm -q postgresql | grep -q el6) && /bin/rm -rf /var/lib/pgsql/
Athmane Madjoudj b9fbb5
Athmane Madjoudj 9d4837
# Keep yum cache
Athmane Madjoudj 9d4837
sed -i 's/keepcache=0/keepcache=1/' /etc/yum.conf
Athmane Madjoudj 9d4837
Athmane Madjoudj b9fbb5
## EOF