Results 1 to 7 of 7

Thread: sme 7 migration

  1. #1
    agarrett5 is offline Intermediate Member
    Join Date
    Oct 2013
    Location
    Tadley
    Posts
    23
    Rep Power
    1

    Default sme 7 migration

    Hi,

    I am trying to migrate sme aliases from SME7 server install to latest version of zimbra OSE (8.0.7)

    I have downloaded a script from the research I have done to find out how to do this, but when the script is run I get errors.

    The errors I get are:

    perl -w aliascript.pl
    Name "main::alias" used only once: possible typo at aliascript.pl line 143 (#1)
    (W once) Typographical errors often show up as unique variable names.
    If you had a good reason for having a unique name, then just mention it
    again somehow to suppress the message. The our declaration is
    provided for this purpose.

    NOTE: This warning detects symbols that have been used only once so $c, @c,
    %c, *c, &c, sub c{}, c(), and c (the filehandle or format) are considered
    the same; if a program uses $c only once but also uses any of the others it
    will not trigger this warning.

    Name "main:u" used only once: possible typo at aliascript.pl line 150 (#1)
    The script that I am running is:

    Code:
    #!/usr/bin/perl 
    use diagnostics; 
    ################################################## ############################## 
    # $Id: aliases2zmprov,v 1.4 2007/03/07 22:18:56 dlbewley Exp $ 
    #------------------------------------------------------------------------------- 
    # Description: 
    # Tool to create commands suitable for zmprov from a unix aliases file. 
    # 
    # Handles the case of an :include: construct. 
    # - Comments in include file are parsed as follows 
    # - "Foo" goes in LDAP description attribute, "Bar" in the displayname. 
    # # Description: foo 
    # # Name: Bar 
    # 
    # Handles the case of remote and multiple recipients by making a dist list. 
    # - A Zimbra alias must be associated with exactly one Zimbra account. 
    # - A Zimbra distribution list may contain users on remote hosts. 
    # 
    # See Also: 
    # http://wiki.zimbra.com/index.php?title=Bulk_Create 
    # 
    # Usage: 
    # ./aliases2zmprov /etc/aliases 1> aliases.zmp 2> aliases.err 
    # zmprov < aliases.zmp 
    # 
    ################################################## ############################## 
     
    my @CNAME_SKIP = qw( ftp news postmaster root webmaster ); 
    my @ALIAS_SKIP = qw( abuse mailer-daemon postmaster ); 
    my @DISTRIBUTION_LISTS; 
    my $DOMAIN      = 'abacuscover.com'; 
    my $SOURCE_HOST = 'eserver'; 
     
    use File::Basename; 
     
    while (<>) { 
        chomp; 
        s/#.*$//;    # skip comments 
        next if /^\s*$/;    # skip blank lines 
     
        my ( $description, $display_name, @cnames ); 
        my ( $alias, $cname ) = split( /:/, $_, 2 ); 
     
        $alias =~ s/\s*//g; 
     
        # scrutinize the aliases 
        if ( grep /^$alias$/, @ALIAS_SKIP ) { 
            warn "skipping alias $alias -> $cname"; 
            next; 
        } 
     
        $cname =~ s/\s*//g;    # remove all spaces 
     
        # scrutinize the canonical names 
        if ( $cname =~ m/:include:/ ) { 
            ( ( $description, $display_name, $cnames_ref ) = parse_include($cname) ) 
              || next; 
            @cnames = @{$cnames_ref}; 
        } 
        if ( $cname =~ m/,/ ) { 
     
            # multiple recipients make this a list instead of an alias 
            @cnames = split( /,/, $cname ); 
        } 
     
        # if more than one cname then it is a dist list 
        if ( length( $cnames[0] ) ) { 
            print "\n"; 
            print "createDistributionList $alias\@$DOMAIN\n"; 
            push( @DISTRIBUTION_LISTS, $alias ); 
            if ($display_name) { 
                print "modifyDistributionList $alias\@$DOMAIN displayname \"$display_name\"\n"; 
                $display_name = undef; 
            } 
            if ($description) { 
                print "modifyDistributionList $alias\@$DOMAIN description \"$description\"\n"; 
                $description = undef; 
            } 
            foreach my $member (@cnames) { 
     
                # skip aliases to certain users 
                if ( grep /^$member$/, @CNAME_SKIP ) { 
                    warn "skipping cname $member <- $alias"; 
                    next;    # go to next member 
                } 
     
                # A Zimbra distribution list may contain users on remote hosts. 
                if ( $member =~ m/\@/ ) { 
                    print "addDistributionListMember $alias\@$DOMAIN $member\n"; 
                } 
                else { 
                    print "addDistributionListMember $alias\@$DOMAIN $member\@$DOMAIN\n"; 
                } 
            } 
            print "\n"; 
            @cnames = (); 
            next;    # go to next line of aliases file 
        } 
     
        # skip aliases to certain users 
        if ( grep /^$cname$/, @CNAME_SKIP ) { 
            warn "skipping cname $cname <- $alias"; 
            next; 
        } 
        if ( $cname =~ m/\/|\|/ ) { 
     
            # alias to a file or a program. don't try to accomodate 
            warn "WARNING skipping cname $cname <- $alias it is a file or pipe"; 
            next; 
        } 
     
        # A Zimbra alias must be associated with exactly one Zimbra account. 
        if ( $cname =~ m/\@/ ) { 
     
          # alias to remote host. this could be created as a dist list with 1 member 
          # that seems undersirable though. 
            print "\n"; 
            print "createDistributionList $alias\@$DOMAIN\n"; 
            print "addDistributionListMember $alias\@$DOMAIN $cname\n"; 
            print "\n"; 
            next;    # go to next line of aliases file 
        } 
     
        # is the cname a distribution_list already? 
        if ( grep /^$cname$/, @DISTRIBUTION_LISTS ) { 
            print "addDistributionListAlias $cname\@$DOMAIN $alias\@$DOMAIN\n"; 
        } 
     
        # are we sure that account $cname\@$DOMAIN exists? 
        else { 
            print "addAccountAlias $cname\@$DOMAIN $alias\@$DOMAIN\n"; 
        } 
    } 
     
    # read an included alias file. commens with Name: and Description: 
    # are placed into LDAP attributes for the list 
    sub parse_include { 
        my $cname = shift; 
        my @cnames; 
     
        # need to pull in contents of file and make a dist 
        # list instead of an alias 
        my $fullfile = $cname; 
        $fullfile =~ s/:include://; 
        my ( $file, $path ) = fileparse($fullfile); 
        if ( !-e $file ) { 
            warn "WARNING skipping $alias -> $cname Please run 'scp $SOURCE_HOST:$fullfile .'"; 
            return;    # go to next line of aliases file 
        } 
        else { 
            # process include file 
            open( F, $file ) || warn "Can not read $file"; 
            while (<F>) { 
                chomp; 
                (m/#\s*Department:*\s*(.*)/) 
                  && ( $ou = $1 );    # can't make use of this in zmprov mdl 
                if (m/#\s*Description:*\s*(.*)/) { 
                    $description = $1; 
                    $description =~ s/"/'/g;    # don't blow our command line 
                } 
                if (m/#\s*Name:*\s*(.*)/) { 
                    $display_name = $1; 
                    $display_name =~ s/"/'/g;    # don't blow our command line 
                } 
                s/#.*$//;                        # skip comments 
                next if /^\s*$/;                 # skip blank lines 
                push @cnames, $_; 
            } 
        } 
        return $description, $display_name, \@cnames; 
    }
    I am assuming theres something within this I need to change as regards to tailoring it to the SME install? I'm not a coder at best of times! I suspect its something very simple I am missing here. Looks to me like theres a couple of things that need declaring.
    Last edited by agarrett5; 05-15-2014 at 07:10 AM. Reason: changing the quotes into code tags
    Computer Engineer

  2. #2
    agarrett5 is offline Intermediate Member
    Join Date
    Oct 2013
    Location
    Tadley
    Posts
    23
    Rep Power
    1

    Default

    I have changed the script and it is now giving me the required output from /etc/aliases and no errors in the .err file. Here is the current script for anyone who may find it useful

    Code:
    #!/usr/bin/perl
    use strict;
    use warnings;
    
    my @CNAME_SKIP= qw( ftp news postmaster root webmaster );
    my @ALIAS_SKIP= qw( abuse mailer-daemon postmaster );
    my @DISTRIBUTION_LISTS;
    my $DOMAIN = 'abacuscover.com';
    my $SOURCE_HOST = 'eserver';
    
    use File::Basename;
    
    while(<>) {
    	chomp;
    	s/#.*$//; # skip comments
    	next if /^\s*$/; # skip blank lines
    
    	my ($description,$display_name,@cnames);
    	my ($alias,$cname) = split(/:/,$_,2);
    
    	$alias =~ s/\s*//g;
    	# scrutinize the aliases
    	#if (grep /^$alias$/, @ALIAS_SKIP) {
    		#warn "skipping alias $alias -> $cname";
    		#next;
    	#}
    
    	$cname =~ s/\s*//g; # remove all spaces
    
    	# scrutinize the canonical names
    	if ($cname =~ m/:include:/) {
    		my ($description, $display_name, $cnames_ref) = parse_include($alias,$cname);
    		next unless $cnames_ref;
    		@cnames = @{$cnames_ref};
    	}
    
    	if ($cname =~ m/,/) {
    		# multiple recipients make this a list instead of an alias
    		@cnames = split(/,/,$cname);
    	}
    
    	# if more than one cname then it is a dist list
    	if (length($cnames[0])) {
    		print "\n";
    		print "createDistributionList $alias\@$DOMAIN\n";
    		push (@DISTRIBUTION_LISTS, $alias);
    	
    		if ($display_name) {
    			print "modifyDistributionList $alias\@$DOMAIN displayname \"$display_name\"\n";
    			$display_name = undef;
    		}
    	
    		if ($description) {
    			print "modifyDistributionList $alias\@$DOMAIN description \"$description\"\n";
    			$description = undef;
    		}
    	
    		foreach my $member (@cnames) {
    			 #skip aliases to certain users
    			if (grep /^$member$/, @CNAME_SKIP) {
    				warn "skipping cname $member <- $alias";
    				next; # go to next member
    			}
    		
    			 #A Zimbra distribution list may contain users or remote hosts.
    			if ($member =~ m/\@/) {
    				#print "addDistributionListMember $alias\@$DOMAIN $member\n";
    			} else {
    				#print "addDistributionListMember $alias\@$DOMAIN $member\@$DOMAIN\n";
    			}
    		}
    	
    		print "\n";
    		@cnames=();
    		next; # go to next line of aliases file
    	}
    
    	# skip aliases to certain users
    	#if (grep /^$cname$/, @CNAME_SKIP) {
    		#warn "skipping cname $cname <- $alias";
    		#next;
    	#}
    
    	if ($cname =~ m/\/|\|/) {
    		# alias to a file or a program. don't try to accomodate
    		warn "WARNING skipping cname $cname <- $alias it is a file or pipe";
    		next;
    	}
    
    	# A Zimbra alias must be associated with exactly one Zimbra account.
    	if ($cname =~ m/\@/) {
    		# alias to remote host. this could be created as a dist list with 1 member
    		# that seems undersirable though.
    		print "\n";
    		print "createDistributionList $alias\@$DOMAIN\n";
    		print "addDistributionListMember $alias\@$DOMAIN $cname\n";
    		print "\n";
    		next; # go to next line of aliases file
    	}
    
    	# is the cname a distribution_list already?
    	if (grep /^$cname$/, @DISTRIBUTION_LISTS) {
    		print "addDistributionListAlias $cname\@$DOMAIN $alias\@$DOMAIN\n";
    	} else {
    		print "zmprov aaa $cname\@$DOMAIN $alias\@$DOMAIN\n";
    	}
    }
    
    # read an included alias file. comments with Name: and Description:
    # are placed into LDAP attributes for the list
    sub parse_include {
    	my ($alias, $cname) = @_;
    	
    	# need to pull in contents of file and make a dist
    	# list instead of an alias
    	my $fullfile = $cname;
    	$fullfile =~ s/:include://;
    	
    	my ($file,$path) = fileparse($fullfile);
    	
    	if (! -e $file) {
    		warn "WARNING skipping $alias -> $cname Please run 'scp $SOURCE_HOST:$fullfile .'";
    		return; # go to next line of aliases file
    	} else {
    		my (@cnames, $description, $display_name);
    		
    		# process include file
    		open(F,$file) || warn "Can not read $file";
    
    		while (<F>) {
    			chomp;
    			#(m/#\s*Department:*\s*(.*)/) && ($ou = $1); #can't make use of this in zmprov mdl
    			
    			if (m/#\s*Description:*\s*(.*)/) {
    				$description = $1;
    				$description =~ s/"/'/g; # don't blow our command line
    			}
    
    			if (m/#\s*Name:*\s*(.*)/) {
    				$display_name = $1;
    				$display_name =~ s/"/'/g; # don't blow our command line
    			}
    			
    			s/#.*$//; # skip comments
    			next if /^\s*$/; # skip blank lines
    			push @cnames, $_;
    		}
    		
    		return ($description, $display_name, \@cnames);
    	}
    }
    The issue I have is /etc/aliases doesn't reflect the aliases on the GUI. This suggests to me that its not held in this file. Where would the aliases and distribution groups be held in SME7? Is this a question for this forum or an SME forum?
    Last edited by agarrett5; 05-29-2014 at 03:30 AM.
    Computer Engineer

  3. #3
    jorgedelacruz.es is offline Advanced Member
    Join Date
    May 2014
    Location
    Madrid
    Posts
    185
    Rep Power
    1

    Default

    Great agarrett5,
    Very nice job. I have a Blog and I will write with your script and mention to you.

    Kind regards !

  4. #4
    agarrett5 is offline Intermediate Member
    Join Date
    Oct 2013
    Location
    Tadley
    Posts
    23
    Rep Power
    1

    Default

    I used another forum to help me with that, I made some alterations on a suggested script from them (so combined work between me and the forum!). One thing I am stuck on is it works with /etc/aliases but that doesn't seem to be where the SME server manager (GUI) is holding its aliases, so I am trying to work out where thats being held. The script works on /etc/aliases when I run

    ./aliases2zmprov.pl /etc/aliases 1> aliases.zmp 2> aliases.err

    It doesn't seem to move groups though so I need to have a look at this as well. I'm not a programmer anyway, so getting my head around Perl and learning both coding and Perl at the same time is a slow process! so its still work in process. Your more than welcome to put it on your blog as it may help someone on the way, but bear in mind its still work in process a little bit.

    The script I am running is called aliases2zmprov.pl
    Computer Engineer

  5. #5
    agarrett5 is offline Intermediate Member
    Join Date
    Oct 2013
    Location
    Tadley
    Posts
    23
    Rep Power
    1

    Default

    In my search for the aliases file that is used by SME gui here is the command I used

    Code:
    find / -name aliases
    /etc/aliases
    /sbin/e-smith/audittools/aliases
    /usr/lib/python2.3/site-packages/japanese/aliases
    /usr/share/doc/bash-3.0/startup-files/apple/aliases
    Looking at all these files they dont correlate with the server-manager. This must mean its held in a completely different file to where Aliases file Migration - Zimbra :: Wiki points to. Is there a config file which decides where the aliases are located?

    The script I posted in an earlier post works but from the /etc/aliases file which isnt consistant with the server-manager (gui). Using SME 7
    Computer Engineer

  6. #6
    agarrett5 is offline Intermediate Member
    Join Date
    Oct 2013
    Location
    Tadley
    Posts
    23
    Rep Power
    1

    Default

    I have located the file I think contains the aliases, correct me if I'm wrong. as opposed to the suggested script location (/etc/aliases)(Im assuming thats for either earlier vesions?) everything seems to be being stored in /home/e-smith/db/accounts.

    It does seem to be creating the .zmp file now, still not 100% correctly, but a lot closer. The errors I get are

    Code:
    Use of uninitialized value $cname in substitution (s///) at ./aliascript3.pl line 28, <> line 7.
    Use of uninitialized value $cname in substitution (s///) at ./aliascript3.pl line 28, <> line 7.
    Use of uninitialized value $cname in substitution (s///) at ./aliascript3.pl line 28, <> line 8.
    Use of uninitialized value $cname in substitution (s///) at ./aliascript3.pl line 28, <> line 8.
    Correct me on anything I do wrong as I go through as I am a noob to both Zimbra and SME
    Computer Engineer

  7. #7
    agarrett5 is offline Intermediate Member
    Join Date
    Oct 2013
    Location
    Tadley
    Posts
    23
    Rep Power
    1

    Default

    Update on where I am with this. The file gives the correct command in the zmp file out put. Problem is it just shows the @domain and not the user\alias. the It The error log is coming out with

    Code:
    Use of uninitialized value $cname in substitution (s///) at ./test.pl line 51, <> line 14.
    Use of uninitialized value $cname in substitution (s///) at ./test.pl line 51, <> line 15.
    Use of uninitialized value $cname in substitution (s///) at ./test.pl line 51, <> line 15.
    Use of uninitialized value $cname in substitution (s///) at ./test.pl line 51, <> line 16.
    Use of uninitialized value $cname in substitution (s///) at ./test.pl line 51, <> line 16.
    Use of uninitialized value $cname in substitution (s///) at ./test.pl line 51, <> line 17.
    Use of uninitialized value $cname in substitution (s///) at ./test.pl line 51, <> line 17.
    Use of uninitialized value $cname in concatenation (.) or string at ./test.pl line 46, <> line 18.
    skipping alias abacusclaims=user|City||Company|Abacus|Dept|Insurance|EmailForward|forward|FirstName|Abacus|ForwardAddress|abacusclaims@directgroup.co.uk|FreeBusy||LastName|Claims|PasswordSet|no|Phone|abacusclaims@bevalued.co.uk|Shell|/usr/bin/rssh|Street|Kingsclere|Uid|5109|VPNClientAccess|no ->  at ./test.pl line 46, <> line 18.
    Use of uninitialized value $cname in substitution (s///) at ./test.pl line 51, <> line 19.
    looks to me that $cname isnt getting any value. I am now wondering if my assumption of accounts file (looking at the data inside) being where the info was wrong. If aliases are not held in the aliases file or accounts file where are aliases likely to be stored?

    The current script I am using is:

    Code:
    #!/usr/bin/perl -w
    ################################################################################
    # $Id: aliases2zmprov,v 1.4 2007/03/07 22:18:56 dlbewley Exp $
    #-------------------------------------------------------------------------------
    # Description:
    #   Tool to create commands suitable for zmprov from a unix aliases file.
    #
    #   Handles the case of an :include: construct.
    #   - Comments in include file are parsed as follows
    #   - "Foo" goes in LDAP description attribute, "Bar" in the displayname.
    #     # Description: foo
    #     # Name: Bar
    #
    #   Handles the case of remote and multiple recipients by making a dist list.
    #   - A Zimbra alias must be associated with exactly one Zimbra account.
    #   - A Zimbra distribution list may contain users on remote hosts.
    #
    # See Also:
    #   http://wiki.zimbra.com/index.php?title=Bulk_Create
    #
    # Usage:
    #    ./aliases2zmprov /etc/aliases 1> aliases.zmp 2> aliases.err
    #    zmprov < aliases.zmp
    #
    ################################################################################
    
    my @CNAME_SKIP= qw( ftp news postmaster root webmaster );
    my @ALIAS_SKIP= qw( abuse mailer-daemon postmaster  );
    my @DISTRIBUTION_LISTS;
    my $DOMAIN = 'abacuscover.com';
    my $SOURCE_HOST = 'mail';
    
    use File::Basename;
    
    while(<>) {
        chomp;
        s/#.*$//; # skip comments
        next if /^\s*$/; # skip blank lines
    
        my ($description,$display_name,@cnames);
        my ($alias,$cname) = split(/:/,$_,2);
    
        $alias =~ s/\s*//g;
        #scrutinize the aliases
        if (grep /^$alias$/, @ALIAS_SKIP) {
            warn "skipping alias $alias -> $cname";
            next;
    	}
    	
    	
        $cname =~ s/\s*//g; # remove all spaces
    
    
        # scrutinize the canonical names
        if ($cname =~ m/:include:/) {
            (($description, $display_name, $cnames_ref) = parse_include($cname)) || next;
            @cnames = @{$cnames_ref};
            
        }
        if ($cname =~ m/,/) {
            # multiple recipients make this a list instead of an alias
            @cnames = split(/,/,$cname);
           
        }
    
        # if more than one cname then it is a dist list
        if (length($cnames[0])) {
            print "\n";
            print "zmprov cdl $alias\@$DOMAIN\n";
            
            push (@DISTRIBUTION_LISTS, $alias);
            if ($display_name) {
                print "zmprov mdl $alias\@$DOMAIN displayname \"$display_name\"\n";
                $display_name = undef;
            }
            if ($description) {
                print "zmprov mdl $alias\@$DOMAIN description \"$description\"\n";
                $description = undef;
            }
            foreach my $member (@cnames) {
                # skip aliases to certain users
                
                if (grep /^$member$/, @CNAME_SKIP) {
                    warn "skipping cname $member <- $alias";
                    next; # go to next member
                }
                # A Zimbra distribution list may contain users on remote hosts.
                if ($member =~ m/\@/) {
                    print "zmprov adlm $alias\@$DOMAIN $member\n";
                } else {
                    print "zmprov adlm $alias\@$DOMAIN $member\@$DOMAIN\n";
                }
            }
            print "\n";
            @cnames=();
            next; # go to next line of aliases file
        } 
    
        # skip aliases to certain users
        if (grep /^$cname$/, @CNAME_SKIP) {
       
            warn "skipping cname $cname <- $alias";
            next;
    	}
        if ($cname =~ m/\/|\|/) {
            # alias to a file or a program. don't try to accomodate
            
            warn "WARNING skipping cname $cname <- $alias it is a file or pipe";
            next;
        }
    
        # A Zimbra alias must be associated with exactly one Zimbra account.
        if ($cname =~ m/\@/) {
            # alias to remote host. this could be created as a dist list with 1 member
            # that seems undersirable though.
            print "\n";
            print "zmprov cdl $alias\@$DOMAIN\n";
            print "zmprov adlm $alias\@$DOMAIN $cname\n";
            print "\n";
            next; # go to next line of aliases file
        }
        # is the cname a distribution_list already?
        if (grep /^$cname$/, @DISTRIBUTION_LISTS) {
            print "zmprov cdl $cname\@$DOMAIN $alias\@$DOMAIN\n";
            
        }
        # are we sure that account $cname\@$DOMAIN exists?
        else {
            print "zmprov aaa $cname\@$DOMAIN $alias\@$DOMAIN\n";
           
        }
    }
    
    # read an included alias file. comments with Name: and Description:
    # are placed into LDAP attributes for the list
    sub parse_include {
        my $cname = shift;
        my @cnames;
        # need to pull in contents of file and make a dist
        # list instead of an alias
        my $fullfile = $cname;
        $fullfile =~ s/:include://;
        my ($file,$path) = fileparse($fullfile);
      
        if (! -e $file) {
            warn "WARNING skipping $alias -> $cname Please run 'scp $SOURCE_HOST:$fullfile .'";
          
            return; # go to next line of aliases file
        } else {
            # process include file
            open(F,$file) || warn "Can not read $file";
            while (<F>) {
                chomp;
                (m/#\s*Department:*\s*(.*)/) && ($ou = $1); # can't make use of this in zmprov mdl :(
                if (m/#\s*Description:*\s*(.*)/) {
                    $description = $1;
                    $description =~ s/"/'/g; # don't blow our command line
                }
                if (m/#\s*Name:*\s*(.*)/) {
                    $display_name = $1;
                    $display_name =~ s/"/'/g; # don't blow our command line
                }
                s/#.*$//; # skip comments
                next if /^\s*$/; # skip blank lines
                push @cnames, $_;
           
            }
        }
        return $description, $display_name, \@cnames;
    }
    Last edited by agarrett5; 06-18-2014 at 02:00 AM.
    Computer Engineer

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help with Migration using ZeXtras Migration Tool
    By paultayawa1624 in forum Administrators
    Replies: 6
    Last Post: 08-18-2014, 06:54 AM
  2. Replies: 0
    Last Post: 04-26-2013, 03:31 PM
  3. zimbra 6 migration on zimbra 7 using zimbra migration wizard
    By prasadpimple in forum Administrators
    Replies: 15
    Last Post: 03-07-2012, 08:21 PM
  4. Replies: 2
    Last Post: 10-04-2011, 08:28 AM
  5. Replies: 0
    Last Post: 02-25-2011, 08:49 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •