bstinson / centos / t_functional

Forked from centos/t_functional 4 years ago
Clone

Blame tests/p_ipa-server/0-preclean.sh

James Hogarth 62aaba
#!/bin/bash
James Hogarth 62aaba
# Author: James Hogarth <james.hogarth@gmail.com>
James Hogarth 62aaba
#
James Hogarth 62aaba
James Hogarth abe41f
if (t_GetPkgRel basesystem | grep -qE 'el(6|7)')
James Hogarth 62aaba
then
James Hogarth 62aaba
James Hogarth 62aaba
t_Log "Running $0 - Stopping and removing httpd if present"
James Hogarth abe41f
if  /sbin/service httpd status 2>&1 | grep 'running...' &> /dev/null
James Hogarth 62aaba
then
James Hogarth 62aaba
/sbin/service httpd stop &> /dev/null
James Hogarth 62aaba
fi
James Hogarth 62aaba
if rpm -q httpd &> /dev/null
James Hogarth 62aaba
then
James Hogarth 62aaba
/usr/bin/yum -y remove httpd &> /dev/null
James Hogarth 62aaba
rm -rf /etc/httpd
James Hogarth 62aaba
fi
James Hogarth 62aaba
James Hogarth 62aaba
t_Log "Running $0 - Stopping and removing bind if present"
James Hogarth abe41f
if  /sbin/service named status 2>&1 | grep 'running...' &> /dev/null
James Hogarth 62aaba
then
James Hogarth 62aaba
/sbin/service named stop &> /dev/null
James Hogarth 62aaba
fi
James Hogarth 62aaba
if rpm -q bind &> /dev/null
James Hogarth 62aaba
then
James Hogarth 62aaba
/usr/bin/yum -y remove bind &> /dev/null
James Hogarth 62aaba
rm -rf /etc/named /var/named
James Hogarth 62aaba
fi
James Hogarth 62aaba
James Hogarth 62aaba
James Hogarth 62aaba
t_Log "Running $0 - Backing up resolv.conf"
James Hogarth 62aaba
cp /etc/resolv.conf /tmp/resolv.conf.ipa-tests
James Hogarth 62aaba
James Hogarth 62aaba
t_Log "Running $0 - Backing up nsswitch.conf"
James Hogarth 62aaba
cp /etc/nsswitch.conf /tmp/nsswitch.conf.ipa-tests
James Hogarth 62aaba
James Hogarth 62aaba
t_Log "Running $0 - Backing up hosts file"
James Hogarth 62aaba
cp /etc/hosts /tmp/hosts.ipa-tests
James Hogarth 62aaba
James Hogarth abe41f
if [[ -f /etc/ntp.conf ]]
James Hogarth abe41f
then
James Hogarth 1deb36
t_Log "Running $0 - Backing up ntp.conf file"
James Hogarth 1deb36
cp /etc/ntp.conf /tmp/ntp.conf.ipa-tests
James Hogarth abe41f
fi
James Hogarth 1deb36
James Hogarth 62aaba
t_Log "Running $0 - Backing up saving yum history id"
James Hogarth 62aaba
/usr/bin/yum history list | awk 'NR == 4 {print $1}' > /tmp/yum-rollback-id.ipa-tests
James Hogarth 62aaba
James Hogarth af79cd
t_Log "Running $0 - Cleaning up hosts file"
James Hogarth af79cd
sed -i "s/127.0.0.1 $(hostname)//" /etc/hosts
James Hogarth af79cd
James Hogarth af79cd
James Hogarth 62aaba
else
James Hogarth 62aaba
    echo "Skipped on CentOS 5"
James Hogarth 62aaba
fi
James Hogarth 62aaba