diff --git a/debian/alternc.config b/debian/alternc.config index 2e58796d..848e3baf 100644 --- a/debian/alternc.config +++ b/debian/alternc.config @@ -26,6 +26,8 @@ MYSQL_HOST=127.0.0.1 MYSQL_DATABASE=alternc MYSQL_USER=sysusr MYSQL_PASS="`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10)' `" +MYSQL_MAIL_USER=alternc_mail_user +MYSQL_MAIL_PASS="`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10)' `" MYSQL_CLIENT=localhost FQDN="`cat /etc/mailname 2>/dev/null || hostname -f`" INTERNAL_IP="`env LANG=C /sbin/ifconfig|grep inet | grep -v 127.0.0.1| head -1 | cut -d: -f2 | sed -e 's/\([0-9\.]*\).*$/\1/' 2>/dev/null || hostname -f`" @@ -53,6 +55,16 @@ if [ -r /etc/alternc/my.cnf ]; then 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` fi +if [ -r /etc/alternc/my_mail.cnf ]; then + # make mysql configuration available as shell variables + # to convert from .cnf to shell syntax, we: + # * match only lines with "equal" in them (/=/) + # * remove whitespace around the = and add a left quote operator ' (;s) + # * add a right quote operator at the end of line (;s) + # * convert mysql variables into our MYSQL_ naming convention (;s) + # * print the result (;p) + 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` +fi # mettre les valeurs de local.sh comme "default" pour debconf db_get alternc/hostingname @@ -157,6 +169,15 @@ if [ -z "$RET" ] db_set alternc/alternc_location "$ALTERNC_LOC" fi +if [ -z "$RET" ] + then +db_set alternc/mysql/alternc_mail_user "$MYSQL_MAIL_USER" +fi + +if [ -z "$RET" ] + then +db_set alternc/mysql/alternc_mail_password "$MYSQL_MAIL_PASS" +fi db_input medium alternc/desktopname || true db_input medium alternc/hostingname || true db_input medium alternc/internal_ip || true @@ -170,6 +191,8 @@ db_input low alternc/mysql/host || true db_input low alternc/mysql/db || true db_input low alternc/mysql/user || true db_input low alternc/mysql/password || true +db_input low alternc/mysql/alternc_mail_password || true +db_input low alternc/mysql/alternc_mail_user || true db_input low alternc/mysql/client || true db_input low alternc/sql/backup_type || true db_input low alternc/sql/overwrite || true diff --git a/debian/alternc.postinst b/debian/alternc.postinst index 3e4ea622..88efdd98 100644 --- a/debian/alternc.postinst +++ b/debian/alternc.postinst @@ -231,7 +231,8 @@ EOF chmod 0440 /etc/sudoers.d/alternc-sudoers else echo "running an older version of sudo" - echo "copy content of /usr/share/doc/aegir-provision/examples/example.sudoers into /etc/sudoers for aegir to run properly" + #FIXME + echo "copy content of /usr/share/doc/examples/example.sudoers into /etc/sudoers.d for to run properly" fi # important: postinst gele sans ca diff --git a/debian/changelog b/debian/changelog index d9a4ffd0..27efc753 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,8 @@ alternc (1.1+nmu2) stable; urgency=low * Templating of dovecot and postfix - adding a view for dovecot usage (dovecot_view) - adding of user vmail dedicated to the mail system + adding a view for dovecot usage (dovecot_view) + adding of user vmail dedicated to the mail system * Bugfixes -- Squidly Sat, 03 Mar 2012 13:09:06 +0100 @@ -30,7 +30,7 @@ alternc (1.0.3) stable; urgency=high alternc (1.0.2) stable; urgency=high * Bugfix : dependency on gamin OR fam : gamin is better for courier-imap - and fam makes sasl imap auth fail + and fam makes sasl imap auth fail * Bugfix : adding french messages for domain new error messages * Bugfix : Fixing domaines types templates issues (incompatibility with pre 1.0 alternc) diff --git a/etc/alternc/templates/postfix/myalias.cf b/etc/alternc/templates/postfix/myalias.cf index a1079420..9ffc2873 100644 --- a/etc/alternc/templates/postfix/myalias.cf +++ b/etc/alternc/templates/postfix/myalias.cf @@ -2,8 +2,8 @@ # %%warning_message%% # -user = %%dbuser%% -password = %%dbpwd%% +user = %%db_mail_user%% +password = %%db_mail_pwd%% hosts =%%dbhost%% dbname = %%dbname%% query = select concat( if(isnull(mailbox.id), '', concat(concat(address.address,'@',domaines.domaine), '\n')), recipient.recipients ) from recipient join address on address.id = re diff --git a/etc/alternc/templates/postfix/mydomain.cf b/etc/alternc/templates/postfix/mydomain.cf index 5c67e46e..8c7fd32f 100644 --- a/etc/alternc/templates/postfix/mydomain.cf +++ b/etc/alternc/templates/postfix/mydomain.cf @@ -2,8 +2,8 @@ # %%warning_message%% # -user = %%dbuser%% -password = %%dbpwd%% +user = %%db_mail_user%% +password = %%db_mail_pwd%% hosts =%%dbhost%% dbname = %%dbname%% query = select domaines.domaine from domaines where domaine='%s' and gesmx=1; diff --git a/etc/alternc/templates/postfix/mygid.cf b/etc/alternc/templates/postfix/mygid.cf index 3fa3f349..c8193fc0 100644 --- a/etc/alternc/templates/postfix/mygid.cf +++ b/etc/alternc/templates/postfix/mygid.cf @@ -2,8 +2,8 @@ # %%warning_message%% # -user = %%dbuser%% -password = %%dbpwd%% +user = %%db_mail_user%% +password = %%db_mail_pwd%% hosts =%%dbhost%% dbname = %%dbname%% 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' diff --git a/etc/alternc/templates/postfix/myrelay.cf b/etc/alternc/templates/postfix/myrelay.cf index b50a17a2..99c79ce6 100644 --- a/etc/alternc/templates/postfix/myrelay.cf +++ b/etc/alternc/templates/postfix/myrelay.cf @@ -2,8 +2,8 @@ # %%warning_message%% # -user = %%dbuser%% -password = %%dbpwd%% +user = %%db_mail_user%% +password = %%db_mail_pwd%% hosts =%%dbhost%% dbname = %%dbname%% table = mail_domain diff --git a/etc/alternc/templates/postfix/myvirtual.cf b/etc/alternc/templates/postfix/myvirtual.cf index 479af8f1..7b28e63f 100644 --- a/etc/alternc/templates/postfix/myvirtual.cf +++ b/etc/alternc/templates/postfix/myvirtual.cf @@ -2,8 +2,8 @@ # %%warning_message%% # -user = %%dbuser%% -password = %%dbpwd%% +user = %%db_mail_user%% +password = %%db_mail_pwd%% hosts =%%dbhost%% dbname = %%dbname%% 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, diff --git a/install/alternc.install b/install/alternc.install index b26a972b..3f236164 100644 --- a/install/alternc.install +++ b/install/alternc.install @@ -110,6 +110,19 @@ if [ -r /etc/alternc/my.cnf ]; then chmod 640 /etc/alternc/my.cnf fi +if [ -r /etc/alternc/my_mail.cnf ]; then + # make mysql configuration available as shell variables + # to convert from .cnf to shell syntax, we: + # * match only lines with "equal" in them (/=/) + # * remove whitespace around the = and add a left quote operator ' (;s) + # * add a right quote operator at the end of line (;s) + # * convert mysql variables into our MYSQL_ naming convention (;s) + # * print the result (;p) + 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` + chown root:alterncpanel /etc/alternc/my_mail.cnf + chmod 640 /etc/alternc/my_mail.cnf +fi + WARNING="WARNING: Do not edit this file, edit the one in /etc/alternc/templates and launch alternc.install again." VERSION="`dpkg -s alternc | sed -n -e 's/^Version: \(.*\)/\1/p'`" @@ -148,6 +161,8 @@ s\\%%dbhost%%\\$MYSQL_HOST\\; s\\%%dbname%%\\$MYSQL_DATABASE\\; s\\%%dbuser%%\\$MYSQL_USER\\; s\\%%dbpwd%%\\$MYSQL_PASS\\; +s\\%%db_mail_user%%\\$MYSQL_MAIL_USER\\; +s\\%%db_mail_pwd%%\\$MYSQL_MAIL_PASS\\; s\\%%ALTERNC_LOC%%\\$ALTERNC_LOC\\; s\\%%warning_message%%\\$WARNING\\; s\\%%fqdn_lettre%%\\$FQDN_LETTER\\; diff --git a/install/mysql.sh b/install/mysql.sh index 5bec4e3c..fea689a5 100755 --- a/install/mysql.sh +++ b/install/mysql.sh @@ -34,6 +34,8 @@ # * user # * password # * database +# * mail_user +# * mail_password # * MYSQL_CLIENT # # XXX: the sed script should be generated here @@ -47,12 +49,13 @@ echo "Granting users..." MYSQL_CONFIG="/etc/alternc/my.cnf" +MYSQL_MAIL_CONFIG="/etc/alternc/my_mail.cnf" . /etc/alternc/local.sh # the purpose of this "grant" is to make sure that the generated my.cnf works # this means (a) creating the user and (b) creating the database grant="GRANT ALL ON *.* TO '$user'@'${MYSQL_CLIENT}' IDENTIFIED BY '$password' WITH GRANT OPTION; -CREATE DATABASE IF NOT EXISTS $database;" +CREATE DATABASE IF NOT EXISTS $database;GRANT ALL ON '$database'.dovecot_view TO '$mail_user'@'${MYSQL_CLIENT}' IDENTIFIED BY '$mail_password'; " echo -n "Trying debian.cnf: " mysql="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf" @@ -110,11 +113,29 @@ EOF chmod 640 $MYSQL_CONFIG fi +if [ -f $MYSQL_MAIL_CONFIG ]; then + echo "Updating mysql configuration in $MYSQL_MAIL_CONFIG" +else + echo "Creating mysql configuration in $MYSQL_MAIL_CONFIG" + cat > $MYSQL_MAIL_CONFIG </dev/null && echo "MYSQL.SH OK!" || echo "MYSQL.SH FAILED!" +$mysql -e "SHOW TABLES" >/dev/null && echo "MYSQL.SH OK!" || echo "MYSQL.SH FAILED: database user setup failed" +$mysql_mail -e "SHOW TABLES" >/dev/null && echo "MYSQL.SH OK!" || echo "MYSQL.SH FAILED: database mail user setup failed" # Final mysql setup: db schema echo "installing AlternC schema in $database..."