Conf web : CREATION ok

This commit is contained in:
Alan Garcia 2011-01-29 15:12:26 +00:00
parent a25f22729a
commit 527c0f3f0e
5 changed files with 30 additions and 20 deletions

View File

@ -27,6 +27,7 @@ INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibil
('cname', 'cname entry', 'DOMAIN', '%SUB% CNAME %TARGET%', 'txt',true, true),
('txt', 'txt entry', 'TXT', '%SUB% IN TXT "%TARGET%"','local,url,ip,webmail,ipv6,cname,txt',true, true),
('mx', 'mx entry', 'IP', '%SUB% IN MX %TARGET%', 'local,url,ip,webmail,ipv6,cname,txt',true, false)
('panel', 'Panel redirection', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'local,url,ip,webmail,ipv6,cname,txt',true, false)
;
-- Changing stanby use

View File

@ -93,12 +93,12 @@ dns_regenerate() {
# Add the entry
file=$(
echo -e "$file"
$MYSQL_DO "select replace(replace(dt.entry,'%TARGET%',sd.valeur), '%SUB%', if(length(sd.sub)>0,sd.sub,'@')) from sub_domaines sd,domaines_type dt where sd.type=dt.name and sd.domaine='$domain';"|sort
$MYSQL_DO "select distinct replace(replace(dt.entry,'%TARGET%',sd.valeur), '%SUB%', if(length(sd.sub)>0,sd.sub,'@')) as entry from sub_domaines sd,domaines_type dt where sd.type=dt.name and sd.domaine='$domain' order by entry ;"
)
# Get some usefull vars
local mx=$( $MYSQL_DO "select mx from domaines where domaine='$domain';")
local mx=$( $MYSQL_DO "select mx from domaines where domaine='$domain' limit 1;")
# Replace the vars by their values
# Here we can add dynamic value for the default MX

View File

@ -5,7 +5,7 @@
. /etc/alternc/local.sh
# Init some other vars
MYSQL_DO="mysql --defaults-file=/etc/alternc/my.cnf -Bs -e "
MYSQL_DO="/usr/bin/mysql --defaults-file=/etc/alternc/my.cnf -Bs -e "
DOMAIN_LOG_FILE="/var/log/alternc/update_domains.log"
# Some usefull miscellaneous shell functions
@ -27,16 +27,16 @@ print_user_letter() {
# imprime le nom d'usager associé au domaine
get_account_by_domain() {
# les admintools ne sont peut-être pas là
if [ -x "/usr/bin/get_account_by_domain" ]
then
# only first field, only first line
/usr/bin/get_account_by_domain "$1"|head -1|awk '{ print $1;}'
else
# if [ -x "/usr/bin/get_account_by_domain" ]
# then
# # only first field, only first line
# /usr/bin/get_account_by_domain "$1"|head -1|awk '{ print $1;}'
# else
# implantons localement ce que nous avons besoin, puisque admintools
# n'est pas là
$MYSQL_DO 'SELECT a.login FROM membres a, sub_domaines b WHERE a.uid = b.compte AND \
CONCAT(IF(sub="", "", CONCAT(sub, ".")), domaine) = "'"$1"'" LIMIT 1;'
fi
# fi
}
log_error() {

View File

@ -7,7 +7,6 @@ HOSTING_DIR="/usr/lib/alternc/hosting_functions"
HTML_HOME="$ALTERNC_LOC/html"
VHOST_DIR="$ALTERNC_LOC/apache-vhost"
VHOST_FILE="$VHOST_DIR/vhosts_all.conf"
host_create() {
@ -41,17 +40,17 @@ host_create() {
# First, usefull vars. Some may be empty or false, it's
# OK, it will be solve in the "case" below
local USER=$2
local FQDN=$3
local REDIRECT=$4 # Yes, TARGET_DIR and REDIRECT are the same
local TARGET_DIR=$4 # It's used by different template
local FQDN=$2
local REDIRECT=$3 # Yes, TARGET_DIR and REDIRECT are the same
local TARGET_DIR=$3 # It's used by different template
local USER=$(get_account_by_domain $FQDN)
local user_letter=`print_user_letter "$USER"`
local DOCUMENT_ROOT="${HTML_HOME}/${user_letter}/${USER}/$TARGET_DIR"
local FILE_TARGET="$VHOST_DIR/${user_letter}/$USER/$FQDN.conf"
# In case VTYPE don't have the same name as the template file,
# here we can define it
local TEMPLATE=''
case $VTYPE in
# "example")
# TEMPLATE="$TEMPLATE_DIR/an-example.conf"
@ -114,7 +113,7 @@ host_change_enable() {
fi
local FQDN=$2
local USER=`get_account_by_domain $FQDN`
local USER=$(get_account_by_domain $FQDN)
local user_letter=`print_user_letter "$USER"`
local FENABLED="$VHOST_DIR/${user_letter}/$USER/$FQDN.conf"
local FDISABLED="$FENABLED-disabled"
@ -167,4 +166,3 @@ host_delete() {
[ -w "$FDISABLED" ] && rm -f "$FDISABLED"
}

View File

@ -50,8 +50,19 @@ done
# Sub domaines we want to update
# sub_domaines.web_action = update and sub_domains.only_dns = false
# TODO do the conf
params=$( $MYSQL_DO "
select concat_ws('|µ',lower(sd.type), if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine), valeur)
from sub_domaines sd, domaines_type dt
where sd.web_action ='UPDATE'
and lower(sd.type) = lower(dt.name)
and dt.only_dns = false
;")
for sub in $params;do
echo host_create $(echo $sub|tr '|µ' ' ')
host_create $(echo $sub|tr '|µ' ' ')
# TODO Update the entry in the DB with the result and the action
done
unset IFS
# Domains we do not want to be the DNS serveur anymore :
# domaines.dns_action = UPDATE and domaines.gesdns = 0