This commit is contained in:
Alan Garcia 2011-03-04 13:45:40 +00:00
parent 33e70e138a
commit 7d80d5b2d2
1 changed files with 12 additions and 5 deletions

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# Update domain next-gen by fufrom # Update domain next-gen by fufroma
for CONFIG_FILE in \ for CONFIG_FILE in \
/etc/alternc/local.sh \ /etc/alternc/local.sh \
@ -19,6 +19,7 @@ umask 022
LOCK_FILE="$ALTERNC_LOC/bureau/cron.lock" LOCK_FILE="$ALTERNC_LOC/bureau/cron.lock"
OLDIFS="$IFS" OLDIFS="$IFS"
NEWIFS=" " NEWIFS=" "
RELOAD_ZONES=""
B="µµ§§" # Strange letters to make split in query B="µµ§§" # Strange letters to make split in query
# Somes check before start operations # Somes check before start operations
@ -78,6 +79,7 @@ done
for dom in $( mysql_query "select domaine from domaines where dns_action = 'UPDATE' and gesdns = 0;") ; do for dom in $( mysql_query "select domaine from domaines where dns_action = 'UPDATE' and gesdns = 0;") ; do
dns_delete $dom dns_delete $dom
mysql_query "update domaines set dns_action = 'OK', dns_result = '$?' where domaine = '$dom'" mysql_query "update domaines set dns_action = 'OK', dns_result = '$?' where domaine = '$dom'"
RELOAD_ZONES="$RELOAD_ZONES $dom"
done done
# Domains we have to update the dns : # Domains we have to update the dns :
@ -85,6 +87,7 @@ done
for dom in $( mysql_query "select domaine from domaines where dns_action = 'UPDATE';") ; do for dom in $( mysql_query "select domaine from domaines where dns_action = 'UPDATE';") ; do
dns_regenerate $dom dns_regenerate $dom
mysql_query "update domaines set dns_action = 'OK', dns_result = '$?' where domaine = '$dom'" mysql_query "update domaines set dns_action = 'OK', dns_result = '$?' where domaine = '$dom'"
RELOAD_ZONES="$RELOAD_ZONES $dom"
done done
# Domains we want to delete completely, now we do it # Domains we want to delete completely, now we do it
@ -93,6 +96,7 @@ for dom in $( mysql_query "select domaine from domaines where dns_action = 'DELE
dns_delete $dom dns_delete $dom
# Web configurations have already bean cleaned previously # Web configurations have already bean cleaned previously
mysql_query "delete sub_domaines where domaine='$dom'; delete domaines where domaine='$dom';" mysql_query "delete sub_domaines where domaine='$dom'; delete domaines where domaine='$dom';"
RELOAD_ZONES="$RELOAD_ZONES $dom"
done done
@ -109,10 +113,13 @@ fi
mv "$tempo" "$VHOST_FILE" mv "$tempo" "$VHOST_FILE"
# Reload web and dns # we assume we run apache and bind on the master
/usr/bin/alternc_reload all /usr/bin/alternc_reload $RELOAD_ZONES || true
for slave in $ALTERNC_SLAVES; do
# TODO reload slaves if [ "$slave" != "localhost" ]; then
ssh alternc@$slave alternc_reload "$RELOAD_ZONES" || true
fi
done
rm "$LOCK_FILE" rm "$LOCK_FILE"