Ignore:
Timestamp:
01/29/11 18:58:19 (2 years ago)
Author:
fufroma
Message:

Update domains, l'aventure continue

File:
1 edited

Legend:

Unmodified
Added
Removed
  • alternc/trunk/src/update_domains.sh

    r2820 r2821  
    4343# Sub_domaines we want to delete 
    4444# sub_domaines.web_action = delete 
    45 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 
    46     host_delete $sub 
     45for 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 
     46    host_delete $(echo $sub|tr '|µ' ' ') 
    4747    # TODO Update the entry in the DB with the result and the action 
    4848done 
     
    5252params=$( $MYSQL_DO " 
    5353  select concat_ws('|µ',lower(sd.type), if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine), valeur)  
    54   from sub_domaines sd, domaines_type dt 
     54  from sub_domaines sd 
    5555  where sd.web_action ='UPDATE' 
    56   and lower(sd.type) = lower(dt.name) 
    57   and dt.only_dns = false 
    5856  ;") 
    5957for sub in $params;do 
    6058    host_create $(echo $sub|tr '|µ' ' ') 
    61     # TODO Update the entry in the DB with the result and the action 
     59    $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'" 
    6260done 
    6361 
    6462# Domaine to enable 
    65 for sub in $( $MYSQL_DO "select if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) from sub_domaines sd where sd.web_action ='ENABLE' ;");do 
    66     host_enable $sub 
    67     # TODO Update the entry in the DB with the result and the action 
     63for 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 
     64    host_enable $(echo $sub|tr '|µ' ' ') 
     65    $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';" 
    6866done 
    6967 
    7068# Domains to disable 
    71 for sub in $( $MYSQL_DO "select if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) from sub_domaines sd where sd.web_action ='DISABLE' ;");do 
    72     host_disable $sub 
    73     # TODO Update the entry in the DB with the result and the action 
     69for 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 
     70    host_disable $(echo $sub|tr '|µ' ' ') 
     71    $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';" 
    7472done 
    7573 
Note: See TracChangeset for help on using the changeset viewer.