Subversion Repositories sysadmin_scripts

Rev

Rev 86 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 86 Rev 108
Line 21... Line 21...
21
#
21
#
22
#    version 2.1.0 20190822 RWR
22
#    version 2.1.0 20190822 RWR
23
#           Added sleeptime parameter to target which makes process sleep a number of seconds between each mail transfer
23
#           Added sleeptime parameter to target which makes process sleep a number of seconds between each mail transfer
24
#              We use HiRes, so this can be a decimal number (ie, 0.5 for half a second).
24
#              We use HiRes, so this can be a decimal number (ie, 0.5 for half a second).
25
#
25
#
-
 
26
#    version 2.2.0 20220512 RWR
-
 
27
#           Added ability to utilized Dovecot admin account, which can process any account using an admin user. No knowledge of
-
 
28
#           client credentials needed. See https://doc.dovecot.org/configuration_manual/authentication/master_users/
26
#
29
#
27
#    This program is free software: you can redistribute it and/or modify
30
#    This program is free software: you can redistribute it and/or modify
28
#    it under the terms of the GNU General Public License as published by
31
#    it under the terms of the GNU General Public License as published by
29
#    the Free Software Foundation, either version 3 of the License, or
32
#    the Free Software Foundation, either version 3 of the License, or
30
#    (at your option) any later version.
33
#    (at your option) any later version.
Line 36... Line 39...
36
#
39
#
37
#    You should have received a copy of the GNU General Public License
40
#    You should have received a copy of the GNU General Public License
38
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
41
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
39
#
42
#
40
#    for required libraries
43
#    for required libraries
41
#    apt-get -y install libnet-imap-simple-ssl-perl libyaml-tiny-perl libhash-merge-simple-perl libclone-perl libdate-manip-perl libemail-simple-perl
44
#    apt -y install libnet-imap-simple-ssl-perl libyaml-tiny-perl libhash-merge-simple-perl libclone-perl libdate-manip-perl libemail-simple-perl
42
 
45
 
43
use strict;
46
use strict;
44
use warnings;
47
use warnings;
45
use Net::IMAP::Simple; # libnet-imap-simple-ssl-perl
48
use Net::IMAP::Simple; # libnet-imap-simple-ssl-perl
46
use POSIX; # to get floor and ceil
49
use POSIX; # to get floor and ceil
Line 379... Line 382...
379
 
382
 
380
   &logit( 0, "========= Test Mode ========\n" ) if $TESTING;
383
   &logit( 0, "========= Test Mode ========\n" ) if $TESTING;
381
   
384
   
382
   # open and log into both source and target, and get the separator used
385
   # open and log into both source and target, and get the separator used
383
   foreach my $acct ( 'target','source' ) {
386
   foreach my $acct ( 'target','source' ) {
-
 
387
      # check if we should use admin info instead of the actual account
-
 
388
      # If they do not set a password, but there is an admin account, set that up
-
 
389
      if ( ! $account->{$acct}->{'password'} && $account->{$acct}->{'adminUsername'} && $account->{$acct}->{'adminPassword'} ) {
-
 
390
         $account->{$acct}->{'username'} = $account->{$acct}->{'adminUsername'} . $account->{$acct}->{'adminSeparator'} . $account->{$acct}->{'username'};
-
 
391
         $account->{$acct}->{'password'} = $account->{$acct}->{'adminPassword'};
-
 
392
      }
384
      $account->{$acct}->{'connection'} = &openIMAPConnection( $account->{$acct}->{'server'}, $account->{$acct}->{'username'}, $account->{$acct}->{'password'} );
393
      $account->{$acct}->{'connection'} = &openIMAPConnection( $account->{$acct}->{'server'}, $account->{$acct}->{'username'}, $account->{$acct}->{'password'} );
385
      unless ( $account->{$acct}->{'connection'} ) {
394
      unless ( $account->{$acct}->{'connection'} ) {
386
         warn "Unable to open $acct for $account->{$acct}->{username}, aborting move: $!\n";
395
         warn "Unable to open $acct for $account->{$acct}->{username}, aborting move: $!\n";
387
         return -1;
396
         return -1;
388
      }
397
      }
Line 446... Line 455...
446
#print Dumper( $config ); die;
455
#print Dumper( $config ); die;
447
foreach my $account ( keys %{$config->{'accounts'}} ) {
456
foreach my $account ( keys %{$config->{'accounts'}} ) {
448
    $config->{'accounts'}->{$account} = &fixupAccount( $config->{'default'}, $config->{'accounts'}->{$account} );
457
    $config->{'accounts'}->{$account} = &fixupAccount( $config->{'default'}, $config->{'accounts'}->{$account} );
449
}
458
}
450
 
459
 
451
#print Dumper( $config ) ; die;
460
print Dumper( $config ) ; die;
452
 
461
 
453
# just a place to gather some stats
462
# just a place to gather some stats
454
my %processed;
463
my %processed;
455
$processed{'Accounts'} = 0;
464
$processed{'Accounts'} = 0;
456
$processed{'Messages'} = 0;
465
$processed{'Messages'} = 0;