--- smeserver-affa-0.9.0/root/sbin/e-smith/affa.dovecotDeleteNewStyleIndexFiles 2008-03-03 19:04:04.000000000 +0100 +++ smeserver-affa-0.9.0/root/sbin/e-smith/affa 2008-03-03 19:04:26.000000000 +0100 @@ -71,7 +71,8 @@ sub getStatus(); sub getStatusRaw(); sub hTime2Timestamp($); -sub imapIndexFilesDelete( ); +sub imapIndexFilesDelete(); +sub imapIndexFilesDeleteCommand(); sub installedRPMsList($); sub installWatchdog(); sub isMounted($$); @@ -1950,6 +1951,18 @@ ); ExecCmd( @cmd, 0 ); } + + if( $job{'remoteHostName'} eq 'localhost' ) + { + imapIndexFilesDelete(); + } + else + { + $txt="Deleting Dovecot's index files on $job{'remoteHostName'}"; lg( $txt ); print "$txt\n"; + @cmd=("/usr/bin/ssh", '-o', "HostKeyAlias=$jobname", '-p', $job{'sshPort'}, $job{'remoteHostName'}, "'" . imapIndexFilesDeleteCommand() . "'" ); + ExecCmd( @cmd, 0 ); + } + $txt="Signaling post-upgrade event on $job{'remoteHostName'}"; lg( $txt ); print "$txt\n"; if( $job{'remoteHostName'} eq 'localhost' ) { @@ -1960,6 +1973,7 @@ @cmd=("/usr/bin/ssh", '-o', "HostKeyAlias=$jobname", '-p', $job{'sshPort'}, $job{'remoteHostName'}, "/sbin/e-smith/signal-event", "post-upgrade"); } ExecCmd( @cmd, 0 ); + $txt="Signaling reboot event on $job{'remoteHostName'}"; lg( $txt ); print "$txt\n"; if( $job{'remoteHostName'} eq 'localhost' ) { @@ -2624,14 +2638,17 @@ return $size; } +sub imapIndexFilesDeleteCommand() + { + return 'USERS=`/usr/bin/find /home/e-smith/files/users -type d -maxdepth 1`;USERS="/home/e-smith/ $USERS"; for u in $USERS ; do ! /usr/bin/test -d $u/Maildir && continue; /usr/bin/find $u/Maildir -maxdepth 2 -type f -name ".imap.index*" -exec /bin/rm -f \'{}\' \; ; /usr/bin/find $u/Maildir -maxdepth 2 -type f -name "dovecot.index*" -exec /bin/rm -f \'{}\' \; ; done'; + } + sub imapIndexFilesDelete() { # Sometimes Dovecot index files are corrupted after a restore # It is save to delete them all. Dovecot will rebuild them when the mailbox is accessed. - print "Deleting Dovecot imap index files\n"; - my @cmd=('cd /home/e-smith/files/users; /usr/bin/find -maxdepth 4 -type f -name ".imap.index*" -print0 | /usr/bin/xargs -0 /bin/rm'); - ExecCmd( @cmd, 0 ); - @cmd=('cd /home/e-smith/Maildir; /usr/bin/find -maxdepth 2 -type f -name ".imap.index*" -print0 | /usr/bin/xargs -0 /bin/rm'); + print "Deleting Dovecot's index files\n"; + my @cmd=( imapIndexFilesDeleteCommand() ); ExecCmd( @cmd, 0 ); }