Changeset 3142


Ignore:
Timestamp:
04/24/12 17:51:47 (13 months ago)
Author:
squidly
Message:

Mise à jour pour la génération du paquet alternc, pour tout ce qui est mail.

Gros changement : comme discuté sur la ML, alternc.install n'est plus lancé automatiquement lors de l'installation, l'utilisateur doit le lancer manuellement
pour finir l'installation.

Changements significatifs :

  • l'installation génére et applique les template dovecot et postfix
  • un utilisateur MySQL dédié est maintenant créé pour postfix et dovecot (mail_user).
  • ajout d'un utilisateur systeme pour dovecot pour le mail delivery
Location:
alternc/trunk
Files:
3 added
15 edited

Legend:

Unmodified
Added
Removed
  • alternc/trunk/debian/alternc.config

    r3139 r3142  
    22 
    33set -e 
    4  
    54# Source debconf library. 
    65. /usr/share/debconf/confmodule 
     
    2726MYSQL_USER=sysusr 
    2827MYSQL_PASS="`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10)' `" 
    29 MYSQL_MAIL_USER=alternc_mail_user 
     28MYSQL_MAIL_USER=alternc_user 
    3029MYSQL_MAIL_PASS="`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10)' `" 
    3130MYSQL_CLIENT=localhost 
     
    170169fi 
    171170 
     171db_get alternc/mysql/alternc_mail_user 
    172172if [ -z "$RET" ] 
    173173    then 
     
    175175fi 
    176176 
     177db_get alternc/mysql/alternc_mail_password 
    177178if [ -z "$RET" ] 
    178179    then 
  • alternc/trunk/debian/alternc.postinst

    r3139 r3142  
    4646    mkdir -p /var/spool/postfix/var/run/saslauthd || true 
    4747    dpkg-statoverride --quiet --update --add root sasl 710 /var/spool/postfix/var/run/saslauthd  || true 
     48 
     49 
     50    #Create Dovecot user for mail handling FIXME change home with ALTERNC_LOC 
     51    if ! getent group vmail; then 
     52       addgroup --gid 1998 vmail 
     53    fi 
     54    if ! getent passwd vmail; then 
     55       adduser -g vmail -u 1998 vmail -d /var/alternc/mail -m  
     56    fi  
     57    chown -R vmail:vmail /var/alternc/mail 
     58    chmod u+w /var/alternc/mail 
     59 
    4860 
    4961    # build local.sh if it does not exist 
     
    145157        db_get "alternc/mysql/password" 
    146158        password="$RET" 
    147          
     159        db_get "alternc/mysql/alternc_mail_user" 
     160        alternc_mail_user="$RET" 
     161        db_get "alternc/mysql/alternc_mail_password" 
     162        alternc_mail_password="$RET" 
     163 
    148164        # we source (instead of forking) mysql.sh so that it gets the local environment above 
    149165        . /usr/share/alternc/install/mysql.sh 
  • alternc/trunk/debian/alternc.postrm

    r2559 r3142  
    1616case "$1" in 
    1717  purge) 
    18     rm -f /etc/alternc/local.sh /etc/alternc/my.cnf /etc/alternc/bureau.conf 
     18    rm -f /etc/alternc/local.sh /etc/alternc/my_mail.cnf /etc/alternc/my.cnf /etc/alternc/bureau.conf 
    1919    rm -f /var/backups/alternc/etc-installed.tar.gz 
    2020 
  • alternc/trunk/debian/alternc.preinst

    r3137 r3142  
    66 
    77# Create AlternC Panel user for web server 
    8 if ! getent group alterncpanel ; then 
     8if ! getent group alterncpanel; then 
    99        addgroup --system --gid 1999 alterncpanel 
    1010fi 
    11 if ! getent passwd alterncpanel ; then 
     11if ! getent passwd alterncpanel; then 
    1212adduser --system --home "/etc/alternc/.alterncpanel" \ 
    1313  --disabled-password --uid 1999 --ingroup alterncpanel alterncpanel 
  • alternc/trunk/debian/templates

    r2997 r3142  
    9393 the system database !!! 
    9494 
     95 
     96Template: alternc/mysql/alternc_mail_user 
     97Type: string 
     98_Description: AlternC's mysql account: 
     99 AlternC will create a mysql administrator account. Please choose it's 
     100 username here. The default value should be good in most case. 
     101 
     102Template: alternc/mysql/alternc_mail_password 
     103Type: password 
     104_Description: Password of the AlternC's mysql account: 
     105 AlternC requires an administrator account on the mysql server. It will be 
     106 created automatically during the install process. Please choose a password 
     107 for this account. 
     108 
    95109Template: alternc/mysql/client 
    96110Type: string 
  • alternc/trunk/etc/alternc/postfix.cf

    r3003 r3142  
     1# Used by alternc.install with postconf 
    12home_mailbox = Maildir/ 
    23smtpd_banner = $myhostname ESMTP 
     
    2728alias_database = hash:/etc/aliases 
    2829virtual_alias_maps = proxy:mysql:/etc/postfix/myalias.cf 
    29 virtual_alias_domains = 
     30virtual_alias_domains =  
    3031virtual_mailbox_domains = proxy:mysql:/etc/postfix/mydomain.cf 
    3132virtual_mailbox_maps = proxy:mysql:/etc/postfix/myvirtual.cf 
     33virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/myquota.cf 
    3234virtual_mailbox_base = /var/alternc/mail 
    3335virtual_minimum_uid = 2000 
    3436virtual_gid_maps = proxy:mysql:/etc/postfix/mygid.cf 
    3537virtual_uid_maps = proxy:mysql:/etc/postfix/mygid.cf 
     38virtual_transport = dovecot 
     39dovecot_destination_recipient_limit = 1 
    3640smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_invalid_hostname, reject_non_fqdn_hostname, reject_non_fqdn_sender, reject_rbl_client zen.spamhaus.org, reject_non_fqdn_recipient, reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_unauth_pipelining, reject_unlisted_recipient, reject_unauth_destination 
  • alternc/trunk/etc/alternc/templates/dovecot/dovecot-sql.conf

    r3137 r3142  
    6161#   connect = /etc/dovecot/authdb.sqlite 
    6262# 
    63 connect = host=%%dbhost%% dbname=%%dbname%% user=%%dbuser%% password=%%dbpwd%% 
     63connect = host=%%dbhost%% dbname=%%dbname%% user=%%db_mail_user%% password=%%db_mail_pwd%% 
    6464 
    6565# Default password scheme. 
     
    6868# http://wiki.dovecot.org/Authentication/PasswordSchemes 
    6969# 
    70 default_pass_scheme = MD5 
     70default_pass_scheme = PLAIN-MD5 
    7171 
    7272# passdb query to retrieve the password. It can return fields: 
  • alternc/trunk/etc/alternc/templates/dovecot/dovecot.conf

    r3137 r3142  
    2323# If you only want to use dovecot-auth, you can set this to "none". 
    2424protocols = imap imaps pop3 pop3s managesieve 
    25 #protocols = none 
     25protocols = imap imaps 
    2626 
    2727# A space separated list of IP or host addresses where to listen in for 
     
    4545#     .. 
    4646#   } 
    47 #listen = * 
     47listen = * 
    4848 
    4949# Disable LOGIN command and all other plaintext authentications unless 
     
    230230# </usr/share/doc/dovecot-common/wiki/MailLocation.txt> 
    231231# 
    232 mail_location = maildir:~/Maildir  
     232mail_location = maildir:~/Maildir 
    233233 
    234234# If you need to set multiple mailbox locations or want to change default 
     
    700700  # list of plugins to load. 
    701701  #mail_plugins =  
    702   mail_plugins = quota  
     702  mail_plugins = quota 
    703703  #mail_plugin_dir = /usr/lib/dovecot/modules/pop3 
    704704 
     
    756756protocol lda { 
    757757  # Address to use when sending rejection mails (e.g. postmaster@example.com). 
    758   postmaster_address = postmaster@lautre.net 
     758  postmaster_address = postmaster@localhost 
    759759 
    760760  # Hostname to use in various parts of sent mails, eg. in Message-Id. 
     
    11281128      # can find mailbox locations. 
    11291129      path = /var/run/dovecot/auth-master 
    1130       mode = 0666 
     1130      mode = 0600 
    11311131      # Default user/group is the one who started dovecot-auth (root) 
    1132       user = vmail  
     1132      user = vmail 
    11331133      #group =  
    11341134    } 
     
    11691169 
    11701170dict { 
    1171   quota = mysql:/etc/dovecot/dovecot-dict-quota.conf 
     1171  quotadict = mysql:/etc/dovecot/dovecot-dict-quota.conf 
    11721172  #expire = db:/var/lib/dovecot/expire.db 
    11731173} 
     
    12171217     quota_warning = storage=80%% /usr/local/bin/quota-warning.sh 80 
    12181218  #quota = maildir 
    1219   quota = dict:user:proxy::quotadict 
     1219  quota = dict:user::proxy::quotadict 
    12201220 
    12211221  # ACL plugin. vfile backend reads ACLs from "dovecot-acl" file from maildir 
  • alternc/trunk/etc/alternc/templates/postfix/myalias.cf

    r3139 r3142  
    77hosts =%%dbhost%% 
    88dbname = %%dbname%% 
    9 query = select concat( if(isnull(mailbox.id), '', concat(concat(address.address,'@',domaines.domaine), '\n')), recipient.recipients ) from recipient join address on address.id = re 
    10 cipient.address_id left outer join mailbox on mailbox.address_id = address.id join domaines on domaines.id = address.domain_id where concat(address.address,'@',domaines.domaine)='% 
    11 s'; 
     9query = select concat( if(isnull(mailbox.id), '', concat(concat(address.address,'@',domaines.domaine), '\n')), recipient.recipients ) from recipient join address on address.id = recipient.address_id left outer join mailbox on mailbox.address_id = address.id join domaines on domaines.id = address.domain_id where concat(address.address,'@',domaines.domaine)='%s'; 
    1210  
    1311 
  • alternc/trunk/etc/alternc/templates/postfix/mydomain.cf

    r3139 r3142  
    77hosts =%%dbhost%% 
    88dbname = %%dbname%% 
    9 query = select domaines.domaine from domaines where domaine='%s' and gesmx=1; 
     9query = select domaines.domaine from domaines join address on address.id=domaines.id where concat(address.address,'@',domaines.domaine)='%s' and gesmx=1; 
    1010 
  • alternc/trunk/etc/alternc/templates/postfix/mygid.cf

    r3139 r3142  
    77hosts =%%dbhost%% 
    88dbname = %%dbname%% 
    9 query = select compte from domaines join address on address.domain_id = domaines.id join mailbox on mailbox.address_id = address.id where address.address='%s' 
     9query = select compte from domaines join address on address.domain_id = domaines.id join mailbox on mailbox.address_id = address.id where concat(address.address,'@',domaines.domaine)='%s' 
    1010 
  • alternc/trunk/etc/alternc/templates/postfix/myvirtual.cf

    r3139 r3142  
    77hosts =%%dbhost%% 
    88dbname = %%dbname%% 
    9 query = select concat(path, '/Maildir/') from mailbox join address on address.id = mailbox.address_id join domaines on domaines.id = address.domain_id where concat(address.address, 
    10 '@',domaines.domaine) ='%s'; 
     9query = select concat(path, '/Maildir/') from mailbox join address on address.id = mailbox.address_id join domaines on domaines.id = address.domain_id where concat(address.address,'@',domaines.domaine) ='%s'; 
    1110 
  • alternc/trunk/install/alternc.install

    r3139 r3142  
    119119    # * convert mysql variables into our MYSQL_ naming convention (;s) 
    120120    # * print the result (;p) 
    121     eval `sed -n -e "/=/{s/ *= *\"\?/='/;s/\"\?\$/'/;s/host/MYSQL_HOST/;s/user/MYSQL_USER/;s/password/MYSQL_PASS/;s/database/MYSQL_DATABASE/;p}" /etc/alternc/my.cnf` 
     121    eval `sed -n -e "/=/{s/ *= *\"\?/='/;s/\"\?\$/'/;s/host/MYSQL_HOST/;s/user/MYSQL_MAIL_USER/;s/password/MYSQL_MAIL_PASS/;s/database/MYSQL_DATABASE/;p}" /etc/alternc/my_mail.cnf` 
    122122    chown root:alterncpanel /etc/alternc/my_mail.cnf 
    123123    chmod 640 /etc/alternc/my_mail.cnf 
     
    281281fi 
    282282 
    283 # configure postfix appropriatly for our needs 
     283# configure Postfix appropriatly for our needs 
    284284if [ "$slave" = "1" ]; then 
    285285    postfix_conf=/etc/alternc/postfix-slave.cf 
     
    287287    postfix_conf=/etc/alternc/postfix.cf 
    288288fi 
    289 while read line 
    290 do 
     289while read line ; do 
    291290   postconf -e "$line" 
    292 done < $postfix_conf 
     291done < "$postfix_conf" 
     292 
     293# Conviguring delivery used bu Postfix FIXME change script name 
     294echo `/usr/bin/postfix-add-policy2 dovecot pipe DRhu vmail:vmail  '/usr/lib/dovecot/deliver -f ${sender} -d ${recipient} '` 
    293295 
    294296# Bug #1215: configure mydestination when $FQDN is not in 
     
    367369fi 
    368370 
     371#giving vmail user read access on dovecot sql file 
     372chgrp vmail /etc/dovecot/dovecot.conf 
     373chmod g+r /etc/dovecot/dovecot.conf 
     374 
    369375# Changing owner of web panel's files 
    370376chown -R alterncpanel:alterncpanel "$ALTERNC_LOC/bureau" 
  • alternc/trunk/install/mysql.sh

    r3139 r3142  
    3535# * password 
    3636# * database 
    37 # * mail_user 
    38 # * mail_password 
     37# * alternc_mail_user 
     38# * alternc_mail_password 
    3939# * MYSQL_CLIENT 
    4040#  
     
    5656# this means (a) creating the user and (b) creating the database 
    5757grant="GRANT ALL ON *.* TO '$user'@'${MYSQL_CLIENT}' IDENTIFIED BY '$password' WITH GRANT OPTION; 
    58 CREATE DATABASE IF NOT EXISTS $database;GRANT ALL ON '$database'.dovecot_view TO '$mail_user'@'${MYSQL_CLIENT}' IDENTIFIED BY '$mail_password'; " 
     58CREATE DATABASE IF NOT EXISTS $database; " 
     59grant_mail="GRANT ALL ON $database.dovecot_view TO '$alternc_mail_user'@'${MYSQL_CLIENT}' IDENTIFIED BY '$alternc_mail_password';" 
     60grant_mail=$grant_mail"GRANT SELECT ON $database.* TO '$alternc_mail_user'@'${MYSQL_CLIENT}' IDENTIFIED BY '$alternc_mail_password';" 
    5961 
    6062echo -n "Trying debian.cnf: " 
     
    137139    file=$3 
    138140    grep -Eq "^ *$var=" $file || echo "$var=" >> $file 
    139     SED_SCRIPT="$SED_SCRIPT;s\\^ *$var=.*\\$var=\"$RET\"\\" 
     141    if [ $file = $MYSQL_CONFIG ]; then 
     142      SED_SCRIPT_USR="$SED_SCRIPT_USR;s\\^ *$var=.*\\$var=\"$RET\"\\" 
     143    else 
     144      SED_SCRIPT_MAIL="$SED_SCRIPT_MAIL;s\\^ *$var=.*\\$var=\"$RET\"\\" 
     145    fi  
    140146} 
    141147 
    142 SED_SCRIPT="" 
     148SED_SCRIPT_USR="" 
     149SED_SCRIPT_MAIL="" 
    143150# hostname was empty in older (pre-0.9.6?) versions 
    144151if [ -z "$host" ]; then 
     
    155162set_value host $host $MYSQL_MAIL_CONFIG 
    156163set_value database $database $MYSQL_MAIL_CONFIG 
    157 set_value user $mail_user $MYSQL_MAIL_CONFIG 
    158 set_value password $mail_password $MYSQL_MAIL_CONFIG 
    159  
     164set_value user $alternc_mail_user $MYSQL_MAIL_CONFIG 
     165set_value password $alternc_mail_password $MYSQL_MAIL_CONFIG 
     166 
     167echo $SED_SCRIPT_MAIL 
     168echo XXXXXX 
     169echo $SED_SCRIPT_USR 
    160170 
    161171# take extra precautions here with the mysql password: 
     
    163173SED_SCRIPT_NAME=`mktemp` 
    164174cat > $SED_SCRIPT_NAME <<EOF 
    165 $SED_SCRIPT 
     175$SED_SCRIPT_USR 
    166176EOF 
    167177sed -f "$SED_SCRIPT_NAME" < $MYSQL_CONFIG > $MYSQL_CONFIG.$$ 
     
    169179rm -f $SED_SCRIPT_NAME 
    170180 
     181SED_SCRIPT_NAME_MAIL=`mktemp` 
     182cat > $SED_SCRIPT_NAME_MAIL <<EOF 
     183$SED_SCRIPT_MAIL 
     184EOF 
     185sed -f "$SED_SCRIPT_NAME_MAIL" < $MYSQL_MAIL_CONFIG > $MYSQL_MAIL_CONFIG.$$ 
     186mv -f $MYSQL_MAIL_CONFIG.$$ $MYSQL_MAIL_CONFIG 
     187rm -f $SED_SCRIPT_NAME_MAIL 
     188 
    171189# Now we should be able to use the mysql configuration 
    172190mysql="/usr/bin/mysql --defaults-file=$MYSQL_CONFIG" 
     
    175193echo "Checking for MySQL connectivity" 
    176194$mysql -e "SHOW TABLES" >/dev/null && echo "MYSQL.SH OK!" || echo "MYSQL.SH FAILED: database user setup failed" 
    177 $mysql_mail -e "SHOW TABLES" >/dev/null && echo "MYSQL.SH OK!" || echo "MYSQL.SH FAILED: database mail user setup failed" 
    178  
     195echo $grant_mail 
    179196# Final mysql setup: db schema 
    180197echo "installing AlternC schema in $database..." 
    181198$mysql < /usr/share/alternc/install/mysql.sql || echo cannot load database schema 
    182  
     199$mysql <<EOF 
     200 $grant_mail 
     201EOF 
  • alternc/trunk/install/mysql.sql

    r3138 r3142  
    237237-- Addresses for domain. 
    238238 
    239 CREATE TABLE `address` ( 
     239CREATE TABLE IF NOT EXISTS `address` ( 
    240240  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, -- Technical id. 
    241241  `domain_id` bigint(20) unsigned NOT NULL REFERENCES `domaines`(`id`), -- FK to sub_domains. 
     
    255255-- Local delivered mailboxes. 
    256256 
    257 CREATE TABLE `mailbox` ( 
     257CREATE TABLE IF NOT EXISTS `mailbox` ( 
    258258  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, -- Technical id. 
    259259  `address_id` bigint(20) unsigned NOT NULL REFERENCES `address`(`id`), -- Reference to address. 
     
    273273-- Other recipients for an address (aliases) 
    274274 
    275 CREATE TABLE `recipient` ( 
     275CREATE TABLE IF NOT EXISTS `recipient` ( 
    276276  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, -- Technical id. 
    277277  `address_id` bigint(20) unsigned NOT NULL REFERENCES `address`(`id`), -- Reference to address 
     
    287287-- Table containing mailman addresses 
    288288 
    289 CREATE TABLE `mailman` ( 
     289CREATE TABLE IF NOT EXISTS `mailman` ( 
    290290  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, -- Technical id. 
    291291  `address_id` bigint(20) unsigned NOT NULL REFERENCES `address`(`id`), -- Reference to address 
     
    546546-- Add function who are not in mysql 5 to be able ton convert ipv6 to decimal (and reverse it) 
    547547DELIMITER // 
     548DROP FUNCTION IF EXISTS INET_ATON6;// 
    548549CREATE FUNCTION INET_ATON6(n CHAR(39)) 
    549550RETURNS DECIMAL(39) UNSIGNED 
     
    570571DELIMITER ; 
    571572DELIMITER // 
     573DROP FUNCTION IF EXISTS INET_NTOA6;// 
    572574CREATE FUNCTION INET_NTOA6(n DECIMAL(39) UNSIGNED) 
    573575RETURNS CHAR(39) 
     
    648650-- 
    649651 
    650 CREATE VIEW `dovecot_view` AS 
     652CREATE OR REPLACE VIEW `dovecot_view` AS 
    651653SELECT concat(`address`.`address`,'@',`domaines`.`domaine`) AS `user`, 
    652654concat('*:storage=',cast(`mailbox`.`quota` as char charset latin1),'M') AS `userdb_quota_rule`, 
Note: See TracChangeset for help on using the changeset viewer.