Conf web : CREATION ok
This commit is contained in:
parent
a25f22729a
commit
527c0f3f0e
|
@ -27,6 +27,7 @@ INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibil
|
||||||
('cname', 'cname entry', 'DOMAIN', '%SUB% CNAME %TARGET%', 'txt',true, true),
|
('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),
|
('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)
|
('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
|
-- Changing stanby use
|
||||||
|
|
|
@ -93,12 +93,12 @@ dns_regenerate() {
|
||||||
# Add the entry
|
# Add the entry
|
||||||
file=$(
|
file=$(
|
||||||
echo -e "$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
|
# 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
|
# Replace the vars by their values
|
||||||
# Here we can add dynamic value for the default MX
|
# Here we can add dynamic value for the default MX
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
. /etc/alternc/local.sh
|
. /etc/alternc/local.sh
|
||||||
|
|
||||||
# Init some other vars
|
# 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"
|
DOMAIN_LOG_FILE="/var/log/alternc/update_domains.log"
|
||||||
|
|
||||||
# Some usefull miscellaneous shell functions
|
# Some usefull miscellaneous shell functions
|
||||||
|
@ -27,16 +27,16 @@ print_user_letter() {
|
||||||
# imprime le nom d'usager associé au domaine
|
# imprime le nom d'usager associé au domaine
|
||||||
get_account_by_domain() {
|
get_account_by_domain() {
|
||||||
# les admintools ne sont peut-être pas là
|
# les admintools ne sont peut-être pas là
|
||||||
if [ -x "/usr/bin/get_account_by_domain" ]
|
# if [ -x "/usr/bin/get_account_by_domain" ]
|
||||||
then
|
# then
|
||||||
# only first field, only first line
|
# # only first field, only first line
|
||||||
/usr/bin/get_account_by_domain "$1"|head -1|awk '{ print $1;}'
|
# /usr/bin/get_account_by_domain "$1"|head -1|awk '{ print $1;}'
|
||||||
else
|
# else
|
||||||
# implantons localement ce que nous avons besoin, puisque admintools
|
# implantons localement ce que nous avons besoin, puisque admintools
|
||||||
# n'est pas là
|
# n'est pas là
|
||||||
$MYSQL_DO 'SELECT a.login FROM membres a, sub_domaines b WHERE a.uid = b.compte AND \
|
$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;'
|
CONCAT(IF(sub="", "", CONCAT(sub, ".")), domaine) = "'"$1"'" LIMIT 1;'
|
||||||
fi
|
# fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_error() {
|
log_error() {
|
||||||
|
|
|
@ -7,7 +7,6 @@ HOSTING_DIR="/usr/lib/alternc/hosting_functions"
|
||||||
|
|
||||||
HTML_HOME="$ALTERNC_LOC/html"
|
HTML_HOME="$ALTERNC_LOC/html"
|
||||||
VHOST_DIR="$ALTERNC_LOC/apache-vhost"
|
VHOST_DIR="$ALTERNC_LOC/apache-vhost"
|
||||||
VHOST_FILE="$VHOST_DIR/vhosts_all.conf"
|
|
||||||
|
|
||||||
|
|
||||||
host_create() {
|
host_create() {
|
||||||
|
@ -41,17 +40,17 @@ host_create() {
|
||||||
|
|
||||||
# First, usefull vars. Some may be empty or false, it's
|
# First, usefull vars. Some may be empty or false, it's
|
||||||
# OK, it will be solve in the "case" below
|
# OK, it will be solve in the "case" below
|
||||||
local USER=$2
|
local FQDN=$2
|
||||||
local FQDN=$3
|
local REDIRECT=$3 # Yes, TARGET_DIR and REDIRECT are the same
|
||||||
local REDIRECT=$4 # Yes, TARGET_DIR and REDIRECT are the same
|
local TARGET_DIR=$3 # It's used by different template
|
||||||
local TARGET_DIR=$4 # It's used by different template
|
local USER=$(get_account_by_domain $FQDN)
|
||||||
local user_letter=`print_user_letter "$USER"`
|
local user_letter=`print_user_letter "$USER"`
|
||||||
local DOCUMENT_ROOT="${HTML_HOME}/${user_letter}/${USER}/$TARGET_DIR"
|
local DOCUMENT_ROOT="${HTML_HOME}/${user_letter}/${USER}/$TARGET_DIR"
|
||||||
local FILE_TARGET="$VHOST_DIR/${user_letter}/$USER/$FQDN.conf"
|
local FILE_TARGET="$VHOST_DIR/${user_letter}/$USER/$FQDN.conf"
|
||||||
|
|
||||||
|
|
||||||
# In case VTYPE don't have the same name as the template file,
|
# In case VTYPE don't have the same name as the template file,
|
||||||
# here we can define it
|
# here we can define it
|
||||||
|
local TEMPLATE=''
|
||||||
case $VTYPE in
|
case $VTYPE in
|
||||||
# "example")
|
# "example")
|
||||||
# TEMPLATE="$TEMPLATE_DIR/an-example.conf"
|
# TEMPLATE="$TEMPLATE_DIR/an-example.conf"
|
||||||
|
@ -114,7 +113,7 @@ host_change_enable() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local FQDN=$2
|
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 user_letter=`print_user_letter "$USER"`
|
||||||
local FENABLED="$VHOST_DIR/${user_letter}/$USER/$FQDN.conf"
|
local FENABLED="$VHOST_DIR/${user_letter}/$USER/$FQDN.conf"
|
||||||
local FDISABLED="$FENABLED-disabled"
|
local FDISABLED="$FENABLED-disabled"
|
||||||
|
@ -167,4 +166,3 @@ host_delete() {
|
||||||
[ -w "$FDISABLED" ] && rm -f "$FDISABLED"
|
[ -w "$FDISABLED" ] && rm -f "$FDISABLED"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ $MYSQL_DO "update sub_domaines sd, domaines d set sd.web_action = 'DELETE' where
|
||||||
|
|
||||||
# Sub_domaines we want to delete
|
# Sub_domaines we want to delete
|
||||||
# sub_domaines.web_action = delete
|
# sub_domaines.web_action = delete
|
||||||
for sub in $( $MYSQL_DO "select if (length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) from sub_domaines sd where web_action ='DELETE';") ; do
|
for sub in $( $MYSQL_DO "select if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) from sub_domaines sd where web_action ='DELETE';") ; do
|
||||||
echo $sub
|
echo $sub
|
||||||
# TODO Do the conf
|
# TODO Do the conf
|
||||||
# TODO Update the entry in the DB with the result and the action
|
# TODO Update the entry in the DB with the result and the action
|
||||||
|
@ -50,8 +50,19 @@ done
|
||||||
|
|
||||||
# Sub domaines we want to update
|
# Sub domaines we want to update
|
||||||
# sub_domaines.web_action = update and sub_domains.only_dns = false
|
# sub_domaines.web_action = update and sub_domains.only_dns = false
|
||||||
# TODO do the conf
|
params=$( $MYSQL_DO "
|
||||||
# TODO Update the entry in the DB with the result and the action
|
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 :
|
# Domains we do not want to be the DNS serveur anymore :
|
||||||
# domaines.dns_action = UPDATE and domaines.gesdns = 0
|
# domaines.dns_action = UPDATE and domaines.gesdns = 0
|
||||||
|
|
Loading…
Reference in New Issue