summaryrefslogtreecommitdiffstats
path: root/tests/dogtag/acceptance/quickinstall/rhds-install.sh
blob: 34ffb1536f7fa89f2a17a5a1aa04b868ba20ba2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#   rhds_install.sh of /CoreOS/dogtag/acceptance/quickinstall
#   Description: CS quickinstall acceptance tests for new install
#                functions.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# The following rhcs will be tested:
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#   Author: Asha Akkiangady <aakkiang@redhat.com>
#   Date  : Feb 18, 2013
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#   Copyright (c) 2013 Red Hat, Inc. All rights reserved.
#
#   This copyrighted material is made available to anyone wishing
#   to use, modify, copy, or redistribute it subject to the terms
#   and conditions of the GNU General Public License version 2.
#
#   This program is distributed in the hope that it will be
#   useful, but WITHOUT ANY WARRANTY; without even the implied
#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
#   PURPOSE. See the GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public
#   License along with this program; if not, write to the Free
#   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
#   Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

. /opt/rhqa_pki/env.sh

rhcs_install_set_ldap_vars() {
	### Set OS/YUM/RPM related variables here
        if [ $(grep Fedora /etc/redhat-release|wc -l) -gt 0 ]; then
                export DISTRO="Fedora"
                export RHDS_SERVER_PACKAGES="389-ds-base policycoreutils-python"
        else
                export DISTRO="RedHat"
                export RHDS_SERVER_PACKAGES="389-ds-base policycoreutils-python"
        fi

	#Copy rhds-install.sh to /opt/rhqa_pki
        rm -f /opt/rhqa_pki/rhds-install.sh
        cp -a ./acceptance/quickinstall/rhds-install.sh /opt/rhqa_pki/.
}

######################################################################
# rhds_install()
# All subsystems and ldap servers on a single host
######################################################################
rhds_install()
{
        local LDAP_PORT="$1"
        local LDAP_INSTANCE_NAME="$2"
        local LDAP_ROOT_DN="$3"
        local LDAP_ROOT_DN_PWD="$4"
        local LDAP_SUFFIX="$5"
	local filename="$6"
	local INSTANCECFG="/tmp/$(eval echo $filename)_instance.inf"
	local INSTANCE_CREATE_OUT="/tmp/$(eval echo $filename)_instance_create.out"

	echo "Base DN: $LDAP_SUFFIX"
	echo "LDAP port: $LDAP_PORT"
	echo "LDAPS port: $LDAPS_PORT"
	echo "Instance configuration file: $INSTANCECFG"
	echo "Password scheme ldif file: $PWDSCHEME"
	echo "LDAP instance: $INSTANCE"


	####################################################
	# turn off firewall
	####################################################
	echo $FLAVOR | grep "Fedora"
	if [ $? -eq 0 ] ; then
		rlRun "systemctl stop firewalld"
	else
		rlRun "service iptables stop"
	fi

	####################################################
	# check for installed RHDS packages
	####################################################
        rhds_install_prep
        for PKG in $RHDS_SERVER_PACKAGES; do
		rlAssertRpm $PKG
        done

	####################################################
	# set up directory server instance
	####################################################

	rlLog "Setting up Directory Server instance ............."
	echo "[General]" > $INSTANCECFG
	echo "FullMachineName= $HOSTNAME" >> $INSTANCECFG
	echo "SuiteSpotUserID= nobody" >> $INSTANCECFG
	echo "SuiteSpotGroup= nobody" >> $INSTANCECFG
	echo "ConfigDirectoryLdapURL= ldap://$HOSTNAME:$LDAP_PORT/o=NetscapeRoot" >> $INSTANCECFG
	echo "ConfigDirectoryAdminID= admin" >> $INSTANCECFG
	echo "ConfigDirectoryAdminPwd= $LDAP_ADMINPW" >> $INSTANCECFG
	echo "AdminDomain= example.com" >> $INSTANCECFG
	echo "" >> $INSTANCECFG
	echo "[slapd]" >> $INSTANCECFG
	echo "ServerIdentifier= $LDAP_INSTANCE_NAME" >> $INSTANCECFG
	echo "ServerPort= $LDAP_PORT" >> $INSTANCECFG
	echo "Suffix= $LDAP_SUFFIX" >> $INSTANCECFG
	echo "RootDN= $LDAP_ROOT_DN"  >> $INSTANCECFG
	echo "RootDNPwd= $LDAP_ROOT_DN_PWD" >> $INSTANCECFG
	echo "" >> $INSTANCECFG
	echo "[admin]" >> $INSTANCECFG
	echo "ServerAdminID= admin" >> $INSTANCECFG
	echo "ServerAdminPwd= $LDAP_ADMINPW" >> $INSTANCECFG
	echo "SysUser= nobody" >> $INSTANCECFG

	cat $INSTANCECFG

	rlLog "Executing: /usr/sbin/setup-ds.pl --silent --file=$INSTANCECFG > $INSTANCE_CREATE_OUT"
	rlRun "/usr/sbin/setup-ds.pl --silent --file=$INSTANCECFG > $INSTANCE_CREATE_OUT" 0 "Creating a LDAP instance"

	/usr/bin/ldapsearch -x -h $HOSTNAME -p $LDAP_PORT -D "$LDAP_ROOT_DN" -w  $LDAP_ROOT_DN_PWD -b "$LDAP_SUFFIX"

	if [ -f  $INSTANCE_CREATE_OUT ]; then
		rlRun "cat $INSTANCE_CREATE_OUT"
		rlLog "Ldap new server instance created successfully."
	else

		rlLog "Error creating ldap new server instance."
	fi

	if [ -f /var/log/dirsrv/slapd-$LDAP_INSTANCE_NAME/errors ]; then
		cp /var/log/dirsrv/slapd-$LDAP_INSTANCE_NAME/errors /var/log/dirsrv/slapd-$LDAP_INSTANCE_NAME/errors.quickinstall
		rhts-submit-log -l /var/log/dirsrv/slapd-$LDAP_INSTANCE_NAME/errors.quickinstall
	fi
	if [ -f /var/log/dirsrv/slapd-$LDAP_INSTANCE_NAME/access ]; then
		cp /var/log/dirsrv/slapd-$LDAP_INSTANCE_NAME/access /var/log/dirsrv/slapd-$LDAP_INSTANCE_NAME/access.quickinstall
		rhts-submit-log -l /var/log/dirsrv/slapd-$LDAP_INSTANCE_NAME/access.quickinstall
	fi
        #rlPhaseEnd
}

rhds_install_prep_pkgInstalls()
{
        rlRun "yum clean all"
        rlRun "yum -y install bind expect"
}


rhds_install_prep()
{
        rlLog "$FUNCNAME"
        if [ -z "$RHDS_SERVER_PACKAGES" ]; then
                rlFail "$RHDS_SERVER_PACKAGES variable not set."
                return 1
        fi

        rhds_install_prep_pkgInstalls

        rlRun "yum -y install $RHDS_SERVER_PACKAGES"
        rlRun "yum -y update"

	# if [ "$IPv6SETUP" != "TRUE" ]; then
	# Install DS in IPV6 environment
}