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
Athmane Madjoudj e20bf0
# stop some services
Athmane Madjoudj e20bf0
service httpd stop
Athmane Madjoudj e20bf0
service libvirtd stop
Athmane Madjoudj e20bf0
service mailman stop
Athmane Madjoudj e20bf0
service mysqld stop
Athmane Madjoudj e20bf0
service named stop
Athmane Madjoudj e20bf0
service nfs stop
Athmane Madjoudj e20bf0
service portmap stop
Athmane Madjoudj e20bf0
service postfix stop
Athmane Madjoudj e20bf0
service postgresql stop
Athmane Madjoudj e20bf0
service radiusd stop
Athmane Madjoudj e20bf0
service rpcbind stop
Athmane Madjoudj e20bf0
service sendmail stop
Athmane Madjoudj e20bf0
service smb stop
Athmane Madjoudj e20bf0
service snmpd stop
Athmane Madjoudj e20bf0
service squid stop
Athmane Madjoudj e20bf0
service vsftpd stop
Athmane Madjoudj e20bf0
service xinetd stop
Athmane Madjoudj e20bf0
Athmane Madjoudj e20bf0
# packages cleanup
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 d27cc2
/bin/rm -rf /var/lib/pgsql/
Athmane Madjoudj b9fbb5
Athmane Madjoudj 25f09a
# Clean tmp
Athmane Madjoudj 25f09a
rm -rf /tmp/*
Athmane Madjoudj 25f09a
rm -rf /var/tmp/*
Athmane Madjoudj 25f09a
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