Mail-Toaster

 view release on metacpan or  search on metacpan

lib/Mail/Toaster/Setup/Vpopmail.pm  view on Meta::CPAN


    # in case someone updates their toaster and not their config file
    if ( defined $conf->{'vpopmail_qmail_ext'}
              && $conf->{'vpopmail_qmail_ext'} ) {
        $conf_args .= " --enable-qmail-ext=y";
        print "qmail extensions: yes\n";
    }
    if ( defined $conf->{'vpopmail_maildrop'} ) {
        $conf_args .= " --enable-maildrop=y";
    };

    print "fixup for longer passwords\n";
    system "sed -i -Ee '/^pw_clear_passwd char(/s/16/128/' vmysql.h";
    system "sed -i -Ee '/^pw_passwd char(/s/40/128/' vmysql.h";

    chdir($package);
    print "running configure with $conf_args\n\n";

    $self->util->syscmd( "./configure $conf_args", verbose => 0 );
    $self->util->syscmd( "make",                   verbose => 0 );
    $self->util->syscmd( "make install-strip",     verbose => 0 );

    if ( -e "vlimits.h" ) {
        # this was for a bug in vpopmail 5.4.?(1-2) installer
        $self->util->syscmd( "cp vlimits.h $vpopdir/include/", verbose => 0);
    }

    return 1;
}

sub default_domain {
    my $self = shift;
    my $version = shift;

    my $default_domain;

    if ( defined $self->conf->{'vpopmail_default_domain'} ) {
        $default_domain = $self->conf->{'vpopmail_default_domain'};
    }
    else {
        $self->util->yes_or_no( "Do you want to use a default domain? " ) or do {
            print "default domain: NONE SELECTED.\n";
            return '';
        };

        $default_domain = $self->util->ask("your default domain");
    };

    if ( ! $default_domain ) {
        print "default domain: NONE SELECTED.\n";
        return '';
    };

    if ( $self->is_newer( min => "5.3.22", cur => $version ) ) {
        my $vpopetc = $self->get_vpop_etc;
        $self->util->file_write( "$vpopetc/defaultdomain",
            lines => [ $default_domain ],
            verbose => 0,
        );

        $self->util->chown( "$vpopetc/defaultdomain",
            uid  => $self->conf->{'vpopmail_user'}  || "vpopmail",
            gid  => $self->conf->{'vpopmail_group'} || "vchkpw",
        );

        return '';
    }

    print "default domain: $default_domain\n";
    return " --enable-default-domain=$default_domain";
};

sub vpopmail_etc {
    my $self  = shift;
    my %p = validate( @_, { $self->get_std_opts } );

    my $vetc = $self->get_vpop_etc;

    mkpath( $vetc, oct('0775') ) if ! -d $vetc;

    if ( -d $vetc ) {
        print "$vetc already exists.\n";
    }
    else {
        print "creating $vetc\n";
        mkdir( $vetc, oct('0775') ) or carp "failed to create $vetc: $!\n";
    }

    $self->setup->tcp_smtp( etc_dir => $vetc );
    $self->setup->tcp_smtp_cdb( etc_dir => $vetc );
}

sub etc_passwd {
    my $self = shift;

    unless ( defined $self->conf->{'vpopmail_etc_passwd'} ) {
        print "\t\t CAUTION!!  CAUTION!!

    The system user account feature is NOT compatible with qmail-smtpd-chkusr.
    If you selected that option in the qmail build, you should not answer
    yes here. If you are unsure, select (n).\n";

        if ( $self->util->yes_or_no( "Do system users (/etc/passwd) get mail? (n) ")) {
            print "system password accounts: yes\n";
            return " --enable-passwd";
        }
    }

    if ( $self->conf->{'vpopmail_etc_passwd'} ) {
        print "system password accounts: yes\n";
        return " --enable-passwd";
    }

    print "system password accounts: no\n";
};

sub get_vpop_etc {
    my $self = shift;
    my $base = $self->get_vpop_dir;
    return "$base/etc";
};



( run in 1.118 second using v1.01-cache-2.11-cpan-71847e10f99 )