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
#
88f3cf
if [ "$PRE_UPDATES" == "1" ]; then
88f3cf
  t_Log "skipping $0 for pre update testing"
88f3cf
  exit 0
88f3cf
fi
James Hogarth 62aaba
James Hogarth abe41f
if (t_GetPkgRel basesystem | grep -qE 'el(6|7)')
c3b6d5
  then
c3b6d5
c3b6d5
  t_Log "Running $0 - Stopping and removing httpd if present"
c3b6d5
  if  /sbin/service httpd status 2>&1 | grep 'running...' &> /dev/null
c3b6d5
    then
c3b6d5
    /sbin/service httpd stop &> /dev/null
c3b6d5
  fi
c3b6d5
  if rpm -q httpd &> /dev/null
c3b6d5
    then
c3b6d5
    /usr/bin/yum -y remove httpd &> /dev/null
c3b6d5
   rm -rf /etc/httpd
c3b6d5
  fi
c3b6d5
c3b6d5
  t_Log "Running $0 - Stopping and removing bind if present"
c3b6d5
  if  /sbin/service named status 2>&1 | grep 'running...' &> /dev/null
c3b6d5
    then
c3b6d5
    /sbin/service named stop &> /dev/null
c3b6d5
  fi
c3b6d5
  if rpm -q bind &> /dev/null
c3b6d5
    then
c3b6d5
    /usr/bin/yum -y remove bind &> /dev/null
c3b6d5
    rm -rf /etc/named /var/named
c3b6d5
  fi
c3b6d5
c3b6d5
c3b6d5
  t_Log "Running $0 - Backing up resolv.conf"
c3b6d5
  cp /etc/resolv.conf /tmp/resolv.conf.ipa-tests
c3b6d5
c3b6d5
  t_Log "Running $0 - Backing up nsswitch.conf"
c3b6d5
  cp /etc/nsswitch.conf /tmp/nsswitch.conf.ipa-tests
c3b6d5
c3b6d5
  t_Log "Running $0 - Backing up hosts file"
c3b6d5
  cp /etc/hosts /tmp/hosts.ipa-tests
c3b6d5
c3b6d5
  t_Log "Running $0 - Saving current hostname"
c3b6d5
  echo $(hostname) >/tmp/hostname.ipa-tests
c3b6d5
c3b6d5
  if [[ -f /etc/ntp.conf ]]
c3b6d5
    then
c3b6d5
    t_Log "Running $0 - Backing up ntp.conf file"
c3b6d5
    cp /etc/ntp.conf /tmp/ntp.conf.ipa-tests
c3b6d5
  fi
c3b6d5
c3b6d5
  t_Log "Running $0 - Backing up saving yum history id"
c3b6d5
  /usr/bin/yum history list | awk 'NR == 4 {print $1}' > /tmp/yum-rollback-id.ipa-tests
c3b6d5
c3b6d5
  t_Log "Running $0 - Cleaning up hosts file"
c3b6d5
  sed -i "s/127.0.0.1 $(hostname)//" /etc/hosts
c3b6d5
  
c3b6d5
  t_Log "Running $0 - Cleaning previous tomcat/pki instances if any"
c3b6d5
  yum remove -d0 -y tomcat ipa-server >/dev/null 2>&1
c3b6d5
  /bin/rm -Rf /var/lib/pki/pki-tomcat/ /etc/sysconfig/pki-tomcat /var/log/pki/pki-tomcat /etc/pki/pki-tomcat /etc/sysconfig/pki/tomcat/pki-tomcat
James Hogarth af79cd
d03e0c
  t_Log "Running $0 - Backing up ssh_config"
d03e0c
  cp /etc/ssh/ssh_config /etc/ssh/ssh_config.ipa-tests
d03e0c
James Hogarth 62aaba
else
James Hogarth 62aaba
    echo "Skipped on CentOS 5"
James Hogarth 62aaba
fi
James Hogarth 62aaba