Changeset 331

Show
Ignore:
Timestamp:
07/28/06 13:03:44 (2 years ago)
Author:
ogawa
Message:

Add gspace support.

Location:
mysqldump2email/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • mysqldump2email/trunk/config.yaml.sample

    r324 r331  
    1919  #  via:  sendmail 
    2020 
     21gspace: 
     22  enable: 0 
     23  directory: / 
     24 
    2125tmpdir: /tmp 
    2226#time_zone: Asia/Tokyo 
  • mysqldump2email/trunk/mysqldump2email

    r327 r331  
    1111use DateTime; 
    1212use File::Spec; 
     13use File::Basename; 
    1314use Pod::Usage; 
    1415use Getopt::Long; 
    1516 
    16 our $VERSION = '0.01'; 
     17our $VERSION = '0.02'; 
    1718 
    1819my %opt = (conf => 'config.yaml'); 
     
    2627 
    2728my $zipfile = dump_mysql($cfg, $dt); 
     29my $attachfile = basename($zipfile); 
    2830my $cfg_mail = $cfg->{mail} 
    2931    or die 'No "mail" setting found in config.yaml'; 
     
    3234MIME::Lite->send($mailroute->{via}, 
    3335                 $mailroute->{host} ? ($mailroute->{host}) : ()); 
     36 
     37my $subject = __PACKAGE__; 
     38if ($cfg->{gspace} && $cfg->{gspace}->{enable}) { 
     39    $subject = join('|', ( 
     40                          'GSPACE', 
     41                          $attachfile, 
     42                          $dt->epoch % 10000, # pseudo-random id ;) 
     43                          1, 
     44                          1, 
     45                          int((-s $zipfile) / 1024), 
     46                          'gs:' . ($cfg->{gspace}->{directory} || '/') . ' d$' 
     47                          )); 
     48} 
    3449 
    3550my $rfc822date = $dt->strftime('%a, %d %b %Y %H:%M:%S %z'); 
     
    3853    From => __PACKAGE__ . ' <' . $cfg_mail->{from} . '>', 
    3954    To => $cfg_mail->{to}, 
    40     Subject => encode('MIME-Header', __PACKAGE__), 
     55    Subject => encode('MIME-Header', $subject), 
    4156    Type => 'multipart/mixed', 
    4257); 
     
    4863    Type => 'application/zip', 
    4964    Path => $zipfile, 
    50     Filename => __PACKAGE__ . '.zip', 
     65    Filename => $attachfile, 
    5166    Disposition => 'attachment', 
    5267); 
     
    189204=back 
    190205 
     206=item gspace: 
     207 
     208=over 4 
     209 
     210=item enable 
     211 
     212Set 1 to enable gspace (http://www.rjonna.com/ext/gspace.php) support. 
     213 
     214=item directory 
     215 
     216Set the gspace directory, where attached files will be stored in. 
     217 
     218=back 
     219 
    191220=item tmpdir: 
    192221