documentazione_3di_riservata:manuali_sysadmin:mail
Differenze
Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.
| Entrambe le parti precedenti la revisioneRevisione precedente | |||
| documentazione_3di_riservata:manuali_sysadmin:mail [2016/02/12 10:23] – [Procedure automatizzate] mpascale | documentazione_3di_riservata:manuali_sysadmin:mail [Data sconosciuta] (versione attuale) – eliminata - modifica esterna (Data sconosciuta) 127.0.0.1 | ||
|---|---|---|---|
| Linea 1: | Linea 1: | ||
| - | ====== Gestione servizi di posta ====== | ||
| - | |||
| - | ===== Mail interna ===== | ||
| - | |||
| - | ===== Mail esterna ===== | ||
| - | |||
| - | ====== Procedure automatizzate ====== | ||
| - | |||
| - | ===== Conversione maildir posftfix in file mbox (no struttura subdir) ===== | ||
| - | |||
| - | Dalla [[http:// | ||
| - | |||
| - | Si riporta il codice utilizzato per la conversione. Lo script necessita del pacchetto **Path:: | ||
| - | |||
| - | cpan -i Path:: | ||
| - | |||
| - | <code perl maildir2mbox.pl> | ||
| - | # | ||
| - | |||
| - | use Path:: | ||
| - | use Cwd; | ||
| - | use File:: | ||
| - | use File::Spec; | ||
| - | |||
| - | use warnings; | ||
| - | |||
| - | sub recurse_maildir { | ||
| - | my $rule = Path:: | ||
| - | |||
| - | $rule-> | ||
| - | $rule-> | ||
| - | |||
| - | foreach my $dir ( $rule-> | ||
| - | next unless stat(" | ||
| - | print "Going into ", | ||
| - | my $pwd = getcwd; | ||
| - | chdir ($dir); | ||
| - | if ($dir eq $parentDir ) { | ||
| - | $dir = " | ||
| - | | ||
| - | my $cleanDir = basename($dir); | ||
| - | if ($cleanDir =~ m/^\.(.*)/ ) { | ||
| - | | ||
| - | } | ||
| - | my $finalOutputFile = File:: | ||
| - | print " | ||
| - | my @files = (< | ||
| - | foreach my $file (@files) { | ||
| - | next unless -f $file; # skip non-regular files | ||
| - | next unless -s $file; # skip empty files | ||
| - | next unless -r $file; # skip unreadable files | ||
| - | $file =~ s/'/'"'"'/; | ||
| - | my $run = "cat ' | ||
| - | | ||
| - | } | ||
| - | chdir ($pwd); | ||
| - | } | ||
| - | |||
| - | } | ||
| - | |||
| - | # dw-maildirtombox.pl | ||
| - | # dw = Dovecot Wiki :-) | ||
| - | # NOTE! The output file must not contain single quotes (')! | ||
| - | # figure out which program to run | ||
| - | $cmd=" | ||
| - | system(" | ||
| - | system(" | ||
| - | or die " | ||
| - | $parentDir=$ARGV[0]; | ||
| - | $outputfile=$ARGV[1]; | ||
| - | if (($outputfile eq '' | ||
| - | { die " | ||
| - | |||
| - | recurse_maildir ($parentDir); | ||
| - | |||
| - | </ | ||
| - | |||
| - | ===== Conversione maildir posftfix in file mbox (con struttura subdir) ===== | ||
| - | |||
| - | Frugando nel web, è venuto fuori [[https:// | ||
| - | |||
| - | Il codice dello script è riportato nel seguito. | ||
| - | |||
| - | <WRAP center round important> | ||
| - | **NB**: si è dovuto modificare l' | ||
| - | </ | ||
| - | |||
| - | |||
| - | <WRAP center round important> | ||
| - | **NB**: lo script funziona solo se lanciato da dentro la maildir che si intende convertire. È quindi necessario specificare come percorso per la maildir il path attuale, ovvero ' | ||
| - | </ | ||
| - | |||
| - | |||
| - | <code python maildir2mbox.py> | ||
| - | # | ||
| - | # -*- coding: utf-8 -*- | ||
| - | """ | ||
| - | Frédéric Grosshans, 19 January 2012 | ||
| - | Nathan R. Yergler, 6 June 2010 | ||
| - | |||
| - | This file does not contain sufficient creative expression to invoke | ||
| - | assertion of copyright. No warranty is expressed or implied; use at | ||
| - | your own risk. | ||
| - | |||
| - | --- | ||
| - | |||
| - | Uses Python' | ||
| - | maildir [http:// | ||
| - | mbox [http:// | ||
| - | |||
| - | See http:// | ||
| - | full documentation on this library. | ||
| - | |||
| - | --- | ||
| - | |||
| - | To run, save as md2mb.py and run: | ||
| - | |||
| - | $ python md2mb.py [maildir_path] [mbox_filename] | ||
| - | |||
| - | [maildir_path] should be the the path to the actual maildir (containing new, | ||
| - | cur, tmp, and the subfolders, which are hidden directories with names like | ||
| - | .subfolde.subsubfolder.subsubsbfolder); | ||
| - | |||
| - | [mbox_filename] will be newly created, as well as a [mbox_filename].sbd the | ||
| - | directory. | ||
| - | """ | ||
| - | |||
| - | import mailbox | ||
| - | import sys | ||
| - | import email | ||
| - | import os | ||
| - | |||
| - | def maildir2mailbox(maildirname, | ||
| - | """ | ||
| - | | ||
| - | | ||
| - | | ||
| - | |||
| - | |||
| - | """ | ||
| - | # open the existing maildir and the target mbox file | ||
| - | | ||
| - | mbox = mailbox.mbox(mboxfilename) | ||
| - | |||
| - | # lock the mbox | ||
| - | | ||
| - | |||
| - | # iterate over messages in the maildir and add to the mbox | ||
| - | for msg in maildir: | ||
| - | | ||
| - | |||
| - | # close and unlock | ||
| - | | ||
| - | | ||
| - | |||
| - | |||
| - | dirname=sys.argv[-2] | ||
| - | mboxname=sys.argv[-1] | ||
| - | print(dirname +' -> ' +mboxname) | ||
| - | mboxdirname=mboxname+' | ||
| - | maildir2mailbox(dirname, | ||
| - | if not os.path.exists(mboxdirname): | ||
| - | |||
| - | listofdirs=[dn for dn in os.walk(dirname).next()[1] if dn not in [' | ||
| - | # | ||
| - | for curfold in listofdirs: | ||
| - | if os.path.exists(os.path.join(curfold,' | ||
| - | curlist=[mboxname]+curfold.split(' | ||
| - | curpath=os.path.join(*[dn+' | ||
| - | if not os.path.exists(curpath): | ||
| - | print(' | ||
| - | maildir2mailbox(os.path.join(dirname, | ||
| - | |||
| - | |||
| - | print(' | ||
| - | </ | ||
| - | |||
| - | |||
| - | ===== Backup di tutte le cartelle di posta ===== | ||
| - | |||
| - | In concomitanza agli script sopra riportati, sono stato realizzati altri script bash per effettuare il backup automatizzato di tutte le maildir degli utenti. | ||
| - | Il primo script esegue le seguenti operazioni per ogni maildir: | ||
| - | - compressione in 7z di tutta la maildir così com'è | ||
| - | - conversione in mbox di tutte le cartelle contenute nella maildir e successiva compressione in 7z | ||
| - | - salvataggio degli archivi compressi su \\storage\UTSHARE\nomeUtente | ||
| - | |||
| - | Di seguito il codice dello script. | ||
| - | <code bash backupMaildirs.sh> | ||
| - | #!/bin/bash | ||
| - | |||
| - | MAILDIR_ROOT=/ | ||
| - | OUTPUT_ROOT=/ | ||
| - | OUTPUT_GROUP=5106 | ||
| - | MAILDIRS=(aalberghini abarducci afistani bcerr commerciale dcwerr dpranteda eluconi fcappelli ganastasi gmgelli helpdesk helpdesk-area itarlassi lpalumbo lsopko mb-archivio mb-proto mbelluomini mbernardini mbrugnetti mciullo mgelli mpascale mstancikova ncandelora opera-assistenza pgramaccioni ppala rtirabassi scavinato sesar siammtest spassarotto sstagni sviluppo test-archiviatore tickets vcapoccia) | ||
| - | |||
| - | set -e | ||
| - | |||
| - | cd " | ||
| - | for USER in ${MAILDIRS[@]} | ||
| - | do | ||
| - | echo " | ||
| - | TEMPDIR=$(mktemp -d) | ||
| - | if [ ! -d " | ||
| - | then | ||
| - | echo " | ||
| - | install -d -m700 -g " | ||
| - | fi | ||
| - | echo " | ||
| - | 7z a -mx=9 -m0=LZMA2 " | ||
| - | echo " | ||
| - | / | ||
| - | ( cd " | ||
| - | rm -rf " | ||
| - | chown $USER: | ||
| - | done | ||
| - | </ | ||
| - | |||
| - | Il secondo script provvede ad utilizzare lo script Python riportato in precedenza per esportare anche la struttura di cartelle in formato mbox: | ||
| - | |||
| - | <code bash backupMaildirs_struct.sh> | ||
| - | #!/bin/bash | ||
| - | |||
| - | MAILDIR_ROOT=/ | ||
| - | OUTPUT_ROOT=/ | ||
| - | OUTPUT_GROUP=5106 | ||
| - | MAILDIRS=(aalberghini abarducci afistani bcerr commerciale dcwerr dpranteda eluconi fcappelli ganastasi gmgelli helpdesk helpdesk-area itarlassi lpalumbo lsopko mb-archivio mb-proto mbelluomini mbernardini mbrugnetti mciullo mgelli mpascale mstancikova ncandelora opera-assistenza pgramaccioni ppala rtirabassi scavinato sesar siammtest spassarotto sstagni sviluppo test-archiviatore tickets vcapoccia) | ||
| - | TMPDIR=/ | ||
| - | |||
| - | set -e | ||
| - | |||
| - | cd " | ||
| - | for USER in ${MAILDIRS[@]} | ||
| - | do | ||
| - | echo " | ||
| - | TEMPDIR=$(mktemp -p " | ||
| - | if [ ! -d " | ||
| - | then | ||
| - | echo " | ||
| - | install -d -m700 -g " | ||
| - | fi | ||
| - | echo " | ||
| - | cd " | ||
| - | echo " | ||
| - | / | ||
| - | echo " | ||
| - | cd .. | ||
| - | ( cd " | ||
| - | rm -rf " | ||
| - | chown $USER: | ||
| - | done | ||
| - | </ | ||
| - | |||
| - | ====== Mailing listi ====== | ||
| - | In aruba per poter scrivere ad una mailing list bisogna essere membri. Se un servizio, come nel caso di jenkins, va aggiunto l' | ||
| - | |||
| - | |||
| - | |||
/data/attic/documentazione_3di_riservata/manuali_sysadmin/mail.1455268993.txt.gz · Ultima modifica: (modifica esterna)