Dev in progress
This commit is contained in:
parent
3417461db0
commit
f402a5fcc0
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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\\;
|
||||
|
|
|
@ -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 <<EOF
|
||||
# AlternC - Web Hosting System - MySQL mail user Configuration
|
||||
# Automatically generated by AlternC configuration, do not edit
|
||||
# This file will be modified on package configuration
|
||||
# (e.g. upgrade or dpkg-reconfigure alternc)
|
||||
[mysql]
|
||||
database=
|
||||
|
||||
[client]
|
||||
EOF
|
||||
chown root:www-data $MYSQL_MAIL_CONFIG
|
||||
chmod 640 $MYSQL_MAIL_CONFIG
|
||||
fi
|
||||
# create a sed script to create/update the file
|
||||
set_value() {
|
||||
var=$1
|
||||
RET=$2
|
||||
grep -Eq "^ *$var=" $MYSQL_CONFIG || echo "$var=" >> $MYSQL_CONFIG
|
||||
file=$3
|
||||
grep -Eq "^ *$var=" $file || echo "$var=" >> $file
|
||||
SED_SCRIPT="$SED_SCRIPT;s\\^ *$var=.*\\$var=\"$RET\"\\"
|
||||
}
|
||||
|
||||
|
@ -123,10 +144,19 @@ SED_SCRIPT=""
|
|||
if [ -z "$host" ]; then
|
||||
host="localhost"
|
||||
fi
|
||||
set_value host $host
|
||||
set_value database $database
|
||||
set_value user $user
|
||||
set_value password $password
|
||||
#filling the config file for the sysusr
|
||||
set_value host $host $MYSQL_CONFIG
|
||||
set_value database $database $MYSQL_CONFIG
|
||||
set_value user $user $MYSQL_CONFIG
|
||||
set_value password $password $MYSQL_CONFIG
|
||||
|
||||
|
||||
#filling the config file for the mailuser
|
||||
set_value host $host $MYSQL_MAIL_CONFIG
|
||||
set_value database $database $MYSQL_MAIL_CONFIG
|
||||
set_value user $mail_user $MYSQL_MAIL_CONFIG
|
||||
set_value password $mail_password $MYSQL_MAIL_CONFIG
|
||||
|
||||
|
||||
# take extra precautions here with the mysql password:
|
||||
# put the sed script in a temporary file
|
||||
|
@ -140,9 +170,11 @@ rm -f $SED_SCRIPT_NAME
|
|||
|
||||
# Now we should be able to use the mysql configuration
|
||||
mysql="/usr/bin/mysql --defaults-file=$MYSQL_CONFIG"
|
||||
mysql_mail="/usr/bin/mysql --defaults-file=$MYSQL_MAIL_CONFIG"
|
||||
|
||||
echo "Checking for MySQL connectivity"
|
||||
$mysql -e "SHOW TABLES" >/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..."
|
||||
|
|
Loading…
Reference in New Issue