Je met le separateur en variable

This commit is contained in:
Alan Garcia 2011-01-30 17:22:59 +00:00
parent 0830dbf871
commit 052ac514d2
1 changed files with 12 additions and 11 deletions

View File

@ -17,6 +17,7 @@ done
# Some vars # Some vars
umask 022 umask 022
LOCK_FILE="$ALTERNC_LOC/bureau/cron.lock" LOCK_FILE="$ALTERNC_LOC/bureau/cron.lock"
B='µµ' # Strange letters to make split in query
# Somes check before start operations # Somes check before start operations
@ -42,33 +43,33 @@ $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 concat_ws('|µ',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),sd.type) from sub_domaines sd where web_action ='DELETE';") ; do for sub in $( $MYSQL_DO "select concat_ws('$B',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),sd.type) from sub_domaines sd where web_action ='DELETE';") ; do
host_delete $(echo $sub|tr '|µ' ' ') host_delete $(echo $sub|tr "$B" ' ')
# 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
done 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
params=$( $MYSQL_DO " params=$( $MYSQL_DO "
select concat_ws('',lower(sd.type), if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine), valeur) select concat_ws('$B',lower(sd.type), if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine), valeur)
from sub_domaines sd from sub_domaines sd
where sd.web_action ='UPDATE' where sd.web_action ='UPDATE'
;") ;")
for sub in $params;do for sub in $params;do
host_create $(echo $sub|tr '|µ' ' ') host_create $(echo $sub|tr "$B" ' ')
$MYSQL_DO "update sub_domaines sd set web_action='OK',web_result='$?' where concat_ws('',lower(sd.type),if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),valeur)='$sub'" $MYSQL_DO "update sub_domaines sd set web_action='OK',web_result='$?' where concat_ws('$B',lower(sd.type),if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),valeur)='$sub'"
done done
# Domaine to enable # Domaine to enable
for sub in $( $MYSQL_DO "select concat_ws('|µ',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),lower(sd.type)) from sub_domaines sd where sd.enable ='ENABLE' ;");do for sub in $( $MYSQL_DO "select concat_ws('$B',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),lower(sd.type)) from sub_domaines sd where sd.enable ='ENABLE' ;");do
host_enable $(echo $sub|tr '|µ' ' ') host_enable $(echo $sub|tr "$B" ' ')
$MYSQL_DO "update sub_domaines sd set enable='ENABLED' where concat_ws('',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),lower(sd.type)) = '$sub';" $MYSQL_DO "update sub_domaines sd set enable='ENABLED' where concat_ws('$B',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),lower(sd.type)) = '$sub';"
done done
# Domains to disable # Domains to disable
for sub in $( $MYSQL_DO "select concat_ws('|µ',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),lower(sd.type)) from sub_domaines sd where sd.enable ='DISABLE' ;");do for sub in $( $MYSQL_DO "select concat_ws('$B',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),lower(sd.type)) from sub_domaines sd where sd.enable ='DISABLE' ;");do
host_disable $(echo $sub|tr '|µ' ' ') host_disable $(echo $sub|tr "$B" ' ')
$MYSQL_DO "update sub_domaines sd set enable='DISABLED' where concat_ws('',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),lower(sd.type)) = '$sub';" $MYSQL_DO "update sub_domaines sd set enable='DISABLED' where concat_ws('$B',if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine),lower(sd.type)) = '$sub';"
done done
# Domains we do not want to be the DNS serveur anymore : # Domains we do not want to be the DNS serveur anymore :