#!/usr/bin/env perl # BEGIN COPYRIGHT BLOCK # This Program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software # Foundation; version 2 of the License. # # 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., 59 Temple # Place, Suite 330, Boston, MA 02111-1307 USA. # # Copyright (C) 2007 Red Hat, Inc. # All rights reserved. # END COPYRIGHT BLOCK # use lib qw(/usr/lib64/dirsrv/perl); use strict; use Setup; use SetupLog; use Inf; use Resource; use DialogManager; use DSCreate; use AdminUtil; use AdminServer; use Util; my $res = new Resource("/usr/share/dirsrv/properties/setup-ds.res", "/usr/share/dirsrv/properties/setup-ds-admin.res"); my $setup = new Setup($res); # see if there is already a configds my $admConf = AdminUtil::getAdmConf("$setup->{configdir}/admin-serv"); # set defaults if ($admConf && %{$admConf}) { $setup->{inf}->{General}->{ConfigDirectoryLdapURL} = $admConf->{ldapurl}; $setup->{inf}->{General}->{ConfigDirectoryAdminID} = $admConf->{userdn}; $setup->{inf}->{General}->{AdminDomain} = $admConf->{AdminDomain}; $setup->{inf}->{General}->{SuiteSpotUserID} = $admConf->{SuiteSpotUserID}; $setup->{inf}->{General}->{SuiteSpotGroup} = $admConf->{SuiteSpotGroup}; $setup->{inf}->{admin}->{SysUser} = $admConf->{sysuser}; # read additional config from config DS my $pset = AdminUtil::getPset($admConf); if ($pset && %{$pset}) { $setup->{inf}->{admin}->{Port} = $pset->{"configuration.nsserverport"}; $setup->{asorigport} = $pset->{"configuration.nsserverport"}; # save orig. port $setup->{inf}->{admin}->{ServerIpAddress} = $pset->{"configuration.nsserveraddress"}; $setup->{inf}->{General}->{FullMachineName} = $pset->{"serverhostname"}; } my $admpw = AdminUtil::getAdmpw($admConf); if ($admpw && %{$admpw}) { $setup->{inf}->{admin}->{ServerAdminID} = $admpw->{ServerAdminID}; $setup->{inf}->{admin}->{ServerAdminPwd} = $admpw->{ServerAdminPwd}; } # default to using the existing config DS $setup->{inf}->{slapd}->{UseExistingMC} = 1; $setup->{inf}->{slapd}->{SlapdConfigForMC} = 0; $setup->{reconfigas} = 1; # allow AS reconfig } if (!$setup->{silent}) { my $dialogmgr = new DialogManager($setup, $res, $TYPICAL); require SetupDialogs; require DSDialogs; require ConfigDSDialogs; require ASDialogs; my @dialogs; push @dialogs, SetupDialogs->getDialogs(); push @dialogs, ASDialogs->getDialogs(); my $readytoproceed = new DialogYesNo ( $EXPRESS, 'dialog_readytoproceed_text', 1, sub { my $self = shift; my $ans = shift; my $resp = $self->handleResponse($ans); if ($resp == $DialogManager::NEXT) { if (!$self->isYes()) { $resp = $DialogManager::BACK; } } return $resp; }, ['dialog_readytoproceed_prompt'], ); push @dialogs, $readytoproceed; $dialogmgr->addDialog(@dialogs); my $rc = $dialogmgr->run(); if ($rc) { $setup->doExit($rc); } } my @errs; # configure and register the admin server instance if (!$setup->{reconfigas}) { if (!createAdminServer($setup)) { $setup->msg($FATAL, 'error_create_adminserver'); $setup->doExit(1); } } else { if (!reconfigAdminServer($setup)) { $setup->msg($FATAL, 'error_reconfig_adminserver'); $setup->doExit(1); } } $setup->doExit(0); END { if ($setup) { if (!$setup->{keep}) { unlink $setup->{inffile}; } } }