[Kolab-devel] kolab_setup (part of Kolab bootstrap rewrite)

Stephan Buys list at codefusion.co.za
Tue Mar 23 10:42:26 CET 2004


Hi all, 

Here is the script that will be used to generate kolab.bootstrap (you can
refer to the bootstrap design doc for more information around the process).

The reason I am releasing this to the list is that I want feedback with regards
to the options as well as the default we have chosen.

The highlights visible from this script is:

Users goes to: cn=Users,base_dn
Address book goes to: cn=Contacts,base_dn
etc.

We have specifically chosen Microsoft terminilogy to make it easy for people
with little directory/Unix knowledge to pick up the exact meanings.

Any feedback welcome!

Kind regards,
-- 
Stephan  Buys
Code Fusion cc.
Tel: +27 11 391 1412
Mobile: +27 83 294 1876
Email: s.buys at codefusion.co.za

E-mail Solutions, Kolab Specialists.
http://www.codefusion.co.za



-------------- next part --------------
#!/kolab/bin/perl

# (c) 2004 Joon Radley <joon at radleys.co.za>
# (c) 2003 Tassilo Erlewein <tassilo.erlewein at erfrakon.de>
# (c) 2003 Martin Konold <martin.konold at erfrakon.de>
# (c) 2003 Achim Frank <achim.frank at erfrakon.de>
# This program is Free Software under the GNU General Public License (>=v2).
# Read the file COPYING that comes with this packages for details.

# kolab_setup Version 0.9
# 
# 11 March 2004 <joon at radleys.co.za>
#
# The functionality of this script was orginaly include in the
# kolab_bootstrap script. It has been moved out to seperate the
# the collection of the bootstrap information from the bootstrap
# process. This will allow other applicates to create the 
# bootstrap information.
#
# The script is based on the orginal part of the kolab_bootstrap
# file. :-)
#
# INPUT: None
#
# OUTPUT: /kolab/etc/kolab/kolab.bootstrap
#
# TODO: Remove the hard linking of file names. The location of the
# kolab.bootstrap file should be determined dynamically. 


use strict;
use vars qw($opt_b);

use URI;
use IO::File;
use IO::Select;
use File::Copy;
use Getopt::Std;
use Term::ReadKey;

#
# function to generate random password
#

srand;

sub random_password_generator
{
    my $pw_length = $_[0];
    
    my @pw_chars = ('a'..'z', 'A'..'Z', 0..9, '-', '_', '%', '#', '|');
    
    my $password = join '', map $pw_chars[rand @pw_chars], 0..$pw_length;

    return $password;
}

sub prompt_input
{
  my $prompt_string = $_[0];
  my $default_value = $_[1];
  
  my $return_value = $default_value;
  
  print "$prompt_string [$default_value]:";
  my $tmp = ReadLine;
  chomp $tmp;
  #(my $dummy, my $tmp) = split(/\:/, $tmp, 2);
  if ($tmp)
  {
    $return_value = $tmp;
  }
  
  return $return_value;
}

#
# Define and clear all the variables to use. For a definition of the
# variables, please read the design documentation.
#

my $hostname = "";
my $email_domain = "";
my $base_dn = "";
my $user_dn = "";
my $contact_dn = "";
my $system_dn = "";
my $kolab_dn = "";
my $manager_pw ="";
my $admin_dn = "";
my $admin_pw = "";
my $postmaster = "";
my $abuse = "";
my $user_cn = "Users";
my $contact_cn = "Contacts";
my $system_cn = "System";
my $admin_cn = "Administrator";
my $kolab_cn = "Kolab Configuration";
my $response = "N";

#
# Print the welcome string
#

print "\nKOLAB BOOTSTRAP SETUP\n\n";

#
# Assign the file name
#

my $kolab_setup_file = "/kolab/etc/kolab/kolab.bootstrap";


#
# Gather the hostname and email domain.
#

print "Hostname:\n" .
      "This is the fqdn (fully qualified domain name) of the Kolab server. \n" .
      "It will be used in subsequent steps to auto-generate some of the fields.\n\n";

$hostname = prompt_input( "Please enter the hostname", $hostname );

if ( !$hostname )
{
  print "\nERROR: The hostname:$hostname cannot be empty.\n\n";
  exit;
}

# extract email domain from host name
(my $dummy, my $email_domain) = split(/\./, $hostname, 2);
if (!$email_domain)
{
  $email_domain = $hostname;
}

print "\nE-Mail Domain:\n".
      "This is the mail domain that Kolab will accept mail for. This will map \n".
      "to the organizations' mail domain (or internal sub domains). You will \n".
      "also need an accompanying MX record in DNS for mail to be delivered across \n".
      "the internet.\n\n";
      
$email_domain = prompt_input( "Please enter your E-Mail domain" , $email_domain );

#
# Generate default advanced values
#

$manager_pw = random_password_generator(8);
$admin_pw = random_password_generator(8);
$postmaster = "administrator@".$email_domain;
$abuse = $postmaster;

#
# Generate Output Values
#

foreach my $dc ((split(/\./,$hostname)))
{
  $base_dn .= "dc=$dc,";
}
chop $base_dn;

$user_dn = "cn=" . $user_cn . "," . $base_dn;
$contact_dn = "cn=" . $contact_cn . "," . $base_dn;
$system_dn = "cn=" . $system_cn . "," . $base_dn;
$kolab_dn = "cn=$hostname,cn=" . $kolab_cn . "," . $system_dn;
$admin_dn = "cn=" . $admin_cn . "," . $user_dn;

#
# Prompt for advanced setup
#


print "\nAdvanced setup:\n".
      "The advanced setup is only for experts, should you choice to use do the \n".
      "advanced setup, please read the documentation for the meaning of the \n".
      "values. If you want to do this the easy way, just say skip the advanced \n".
      "setup, everything will be created for you.\n\n";



$response = prompt_input ("Would you like to do the advanced setup Y/N", $response);

if ($response eq "Y" or $response eq "y" )
{
  $user_cn = prompt_input( "Please enter the user DN", $user_dn );
  $contact_cn = prompt_input( "Please enter the contact DN", $contact_dn );
  $system_cn = prompt_input( "Please enter the system DN", $system_dn );
  $kolab_cn = prompt_input( "Please enter the kolab DN", $kolab_dn );
  $manager_pw = prompt_input( "Please enter the manager password", $manager_pw );
  $admin_cn = prompt_input( "Please enter the administrator DN" , $admin_dn );
  $admin_pw = prompt_input( "Please enter the administrator password", $admin_pw );
  $postmaster = prompt_input( "Please enter the postmaster e-mail address", $postmaster );
  $abuse = prompt_input( "Please enter the abuse e-mail address", $abuse );
}
#
#  Save the setup information to the kolab.bootstrap file
#

my  $fd = IO::File->new($kolab_setup_file, "w+") || die "could not create open $kolab_setup_file";
print $fd "hostname : $hostname\n";
print $fd "email_domain : $email_domain\n";
print $fd "base_dn : $base_dn\n";
print $fd "user_dn : $user_dn\n";
print $fd "contact_dn : $contact_dn\n";
print $fd "system_dn : $system_dn\n";
print $fd "kolab_dn : $kolab_dn\n";
print $fd "manager_pw : $manager_pw\n";
print $fd "admin_dn : $admin_dn\n";
print $fd "admin_pw : $admin_pw\n";
print $fd "postmaster : $postmaster\n";
print $fd "abuse : $abuse\n";
undef $fd;
print "Done building $kolab_setup_file\n\n";
chmod 0600, $kolab_setup_file;
print "IMPORTANT NOTE:\n";
print "Use login=manager and passwd=$manager_pw when you log into the webinterface!\n\n";
print "The administrator user password=$admin_pw\n\n"




More information about the devel mailing list