From c3b6d5789dee585ab2c05ed3584c1355c62fdd0f Mon Sep 17 00:00:00 2001 From: Fabian Arrotin Date: May 21 2014 09:27:31 +0000 Subject: Fixed the ipa-server test for el7 --- diff --git a/tests/p_ipa-server/0-preclean.sh b/tests/p_ipa-server/0-preclean.sh index ab0dba3..2bfca66 100755 --- a/tests/p_ipa-server/0-preclean.sh +++ b/tests/p_ipa-server/0-preclean.sh @@ -3,52 +3,58 @@ # if (t_GetPkgRel basesystem | grep -qE 'el(6|7)') -then - -t_Log "Running $0 - Stopping and removing httpd if present" -if /sbin/service httpd status 2>&1 | grep 'running...' &> /dev/null -then -/sbin/service httpd stop &> /dev/null -fi -if rpm -q httpd &> /dev/null -then -/usr/bin/yum -y remove httpd &> /dev/null -rm -rf /etc/httpd -fi - -t_Log "Running $0 - Stopping and removing bind if present" -if /sbin/service named status 2>&1 | grep 'running...' &> /dev/null -then -/sbin/service named stop &> /dev/null -fi -if rpm -q bind &> /dev/null -then -/usr/bin/yum -y remove bind &> /dev/null -rm -rf /etc/named /var/named -fi - - -t_Log "Running $0 - Backing up resolv.conf" -cp /etc/resolv.conf /tmp/resolv.conf.ipa-tests - -t_Log "Running $0 - Backing up nsswitch.conf" -cp /etc/nsswitch.conf /tmp/nsswitch.conf.ipa-tests - -t_Log "Running $0 - Backing up hosts file" -cp /etc/hosts /tmp/hosts.ipa-tests - -if [[ -f /etc/ntp.conf ]] -then -t_Log "Running $0 - Backing up ntp.conf file" -cp /etc/ntp.conf /tmp/ntp.conf.ipa-tests -fi - -t_Log "Running $0 - Backing up saving yum history id" -/usr/bin/yum history list | awk 'NR == 4 {print $1}' > /tmp/yum-rollback-id.ipa-tests - -t_Log "Running $0 - Cleaning up hosts file" -sed -i "s/127.0.0.1 $(hostname)//" /etc/hosts - + then + + t_Log "Running $0 - Stopping and removing httpd if present" + if /sbin/service httpd status 2>&1 | grep 'running...' &> /dev/null + then + /sbin/service httpd stop &> /dev/null + fi + if rpm -q httpd &> /dev/null + then + /usr/bin/yum -y remove httpd &> /dev/null + rm -rf /etc/httpd + fi + + t_Log "Running $0 - Stopping and removing bind if present" + if /sbin/service named status 2>&1 | grep 'running...' &> /dev/null + then + /sbin/service named stop &> /dev/null + fi + if rpm -q bind &> /dev/null + then + /usr/bin/yum -y remove bind &> /dev/null + rm -rf /etc/named /var/named + fi + + + t_Log "Running $0 - Backing up resolv.conf" + cp /etc/resolv.conf /tmp/resolv.conf.ipa-tests + + t_Log "Running $0 - Backing up nsswitch.conf" + cp /etc/nsswitch.conf /tmp/nsswitch.conf.ipa-tests + + t_Log "Running $0 - Backing up hosts file" + cp /etc/hosts /tmp/hosts.ipa-tests + + t_Log "Running $0 - Saving current hostname" + echo $(hostname) >/tmp/hostname.ipa-tests + + if [[ -f /etc/ntp.conf ]] + then + t_Log "Running $0 - Backing up ntp.conf file" + cp /etc/ntp.conf /tmp/ntp.conf.ipa-tests + fi + + t_Log "Running $0 - Backing up saving yum history id" + /usr/bin/yum history list | awk 'NR == 4 {print $1}' > /tmp/yum-rollback-id.ipa-tests + + t_Log "Running $0 - Cleaning up hosts file" + sed -i "s/127.0.0.1 $(hostname)//" /etc/hosts + + t_Log "Running $0 - Cleaning previous tomcat/pki instances if any" + yum remove -d0 -y tomcat ipa-server >/dev/null 2>&1 + /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 else echo "Skipped on CentOS 5" diff --git a/tests/p_ipa-server/1-install_freeipa.sh b/tests/p_ipa-server/1-install_freeipa.sh index 549f597..6749a68 100755 --- a/tests/p_ipa-server/1-install_freeipa.sh +++ b/tests/p_ipa-server/1-install_freeipa.sh @@ -3,11 +3,11 @@ # if (t_GetPkgRel basesystem | grep -qE 'el(6|7)') -then -t_Log "Running $0 - Installing packages, this takes around 2-3 mins" -t_InstallPackage ipa-server bind-dyndb-ldap libsss_sudo + then + t_Log "Running $0 - Installing packages, this takes around 2-3 mins" + t_InstallPackage ipa-server bind-dyndb-ldap libsss_sudo else - echo "Skipped on CentOS 5" + echo "Skipped on CentOS 5" fi diff --git a/tests/p_ipa-server/2-configure_freeipa.sh b/tests/p_ipa-server/2-configure_freeipa.sh index 80a1b4c..f368dc0 100755 --- a/tests/p_ipa-server/2-configure_freeipa.sh +++ b/tests/p_ipa-server/2-configure_freeipa.sh @@ -2,31 +2,38 @@ # Author: James Hogarth # if (t_GetPkgRel basesystem | grep -qE 'el(6|7)') -then + then -t_Log "Running $0 - setting hostname of system" -hostname c6test.c6ipa.local -echo "$(ip a s dev eth0 | awk '$0 ~ /scope global eth0/ {print $2}' | cut -d'/' -f 1) $(hostname)" >> /etc/hosts -hostname | grep "c6test.c6ipa.local" &> /dev/null -t_CheckExitStatus $? + t_Log "Running $0 - setting hostname of system" + eth_int=$(ip addr|grep -B 1 "link/ether"|head -n 1|awk '{print $2}'|tr -d ':') + eth_ip=$(ip -4 addr show dev $eth_int | awk '$0 ~ /scope global/ {print $2}' | cut -d'/' -f 1) + if [ "$centos_ver" = "7" ] ; then + hostnamectl set-hostname c6test.c6ipa.local + else + hostname c6test.c6ipa.local + fi + echo $eth_ip $(hostname) >> /etc/hosts + hostname | grep "c6test.c6ipa.local" &> /dev/null + t_CheckExitStatus $? -t_Log "Running $0 - Configuring IPA server - this can take some time" -ipa-server-install -U --hostname=c6test.c6ipa.local --ip-address=$(ip a s dev eth0 | awk '$0 ~ /scope global eth0/ {print $2}' | cut -d'/' -f 1) -r C6IPA.LOCAL -n c6ipa.local -p p455w0rd -a p455w0rd --ssh-trust-dns --setup-dns --forwarder=$(awk '$0 ~ /nameserver/ {print $2}' /etc/resolv.conf | head -n 1) + t_Log "Running $0 - Configuring IPA server - this can take some time" -t_CheckExitStatus $? + ipa-server-install -U --hostname=c6test.c6ipa.local --ip-address=$eth_ip -r C6IPA.LOCAL -n c6ipa.local -p p455w0rd -a p455w0rd --ssh-trust-dns --setup-dns --forwarder=$(awk '$0 ~ /nameserver/ {print $2}' /etc/resolv.conf | head -n 1) -t_Log "Running $0 - Enabling mkhomedir" -authconfig --enablemkhomedir --enablesssd --update -t_CheckExitStatus $? + t_CheckExitStatus $? -if /sbin/service sssd status | grep 'is stopped' &> /dev/null -then -/sbin/service sssd start &> /dev/null -fi + t_Log "Running $0 - Enabling mkhomedir" + authconfig --enablemkhomedir --enablesssd --update + t_CheckExitStatus $? + + if /sbin/service sssd status | grep 'is stopped' &> /dev/null + then + /sbin/service sssd start &> /dev/null + fi else - echo "Skipped on CentOS 5" + echo "Skipped on CentOS 5" fi diff --git a/tests/p_ipa-server/99-postclean.sh b/tests/p_ipa-server/99-postclean.sh index 07664cc..ce77b3f 100755 --- a/tests/p_ipa-server/99-postclean.sh +++ b/tests/p_ipa-server/99-postclean.sh @@ -3,29 +3,33 @@ # if (t_GetPkgRel basesystem | grep -qE 'el(6|7)') -then + then -t_Log "Running $0 - Restoring up resolv.conf" -cp /tmp/resolv.conf.ipa-tests /etc/resolv.conf + t_Log "Running $0 - Restoring up resolv.conf" + cp /tmp/resolv.conf.ipa-tests /etc/resolv.conf -t_Log "Running $0 - Restoring nsswitch.conf" -cp /tmp/nsswitch.conf.ipa-tests /etc/nsswitch.conf + t_Log "Running $0 - Restoring nsswitch.conf" + cp /tmp/nsswitch.conf.ipa-tests /etc/nsswitch.conf -t_Log "Running $0 - Restoring hosts file" -cp /tmp/hosts.ipa-tests /etc/hosts + t_Log "Running $0 - Restoring hosts file" + cp /tmp/hosts.ipa-tests /etc/hosts -if [[ -f /tmp/ntp.conf.ipa-tests ]] -then -t_Log "Running $0 - Restoring ntp.conf file" -cp /tmp/ntp.conf.ipa-tests /etc/ntp.conf -fi + if [[ -f /tmp/ntp.conf.ipa-tests ]] + then + t_Log "Running $0 - Restoring ntp.conf file" + cp /tmp/ntp.conf.ipa-tests /etc/ntp.conf + fi + + t_Log "Running $0 - Rolling back to yum history id - this will take some time" + /usr/bin/yum -y history rollback $(cat /tmp/yum-rollback-id.ipa-tests) &> /dev/null -t_Log "Running $0 - Rolling back to yum history id - this will take some time" -/usr/bin/yum -y history rollback $(cat /tmp/yum-rollback-id.ipa-tests) &> /dev/null + rm -f /tmp/*.ipa-test /etc/httpd/conf.d/* -rm -f /tmp/*.ipa-test /etc/httpd/conf.d/* -sed -i "s/$(ip a s dev eth0 | awk '$0 ~ /scope global eth0/ {print $2}' | cut -d'/' -f 1) $(hostname)//" /etc/hosts -hostname localhost.localdomain + if [ "$centos_ver" = "7" ] ; then + hostnamectl set-hostname $(cat /tmp/hostname.ipa-tests) + else + hostname $(cat /tmp/hostname.ipa-tests) + fi else echo "Skipped on CentOS 5"