From 22ab6d500c205646fc70ce774c8ab2c1809bc575 Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Wed, 29 May 2013 14:20:05 +0300 Subject: [PATCH] added sys-queue handler --- bin/v-add-remote-dns-host | 10 +++++++++- bin/v-delete-remote-dns-host | 10 +++++++++- bin/v-sync-dns-cluster | 21 +++++++++++++-------- bin/v-update-sys-queue | 2 +- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/bin/v-add-remote-dns-host b/bin/v-add-remote-dns-host index 59ac5c991..d809cd524 100755 --- a/bin/v-add-remote-dns-host +++ b/bin/v-add-remote-dns-host @@ -58,12 +58,20 @@ else fi # Sync current zones -$BIN/v-sync-dns-cluster +$BIN/v-sync-dns-cluster $host return_code=$? if [ "$return_code" -ne 0 ]; then exit $return_code fi +# Add cron job +cmd="sudo /usr/local/vesta/bin/v-update-sys-queue dns-cluster" +check_cron=$(grep "$cmd" $VESTA/data/users/admin/cron.conf 2> /dev/null) +if [ -z "$check_cron" ] && [ ! -z "$CRON_SYSTEM" ]; then + $BIN/v-add-cron-job admin '*/5' '*' '*' '*' '*' "$cmd" +fi + + #----------------------------------------------------------# # Vesta # #----------------------------------------------------------# diff --git a/bin/v-delete-remote-dns-host b/bin/v-delete-remote-dns-host index 9eaa980c2..86289ae0b 100755 --- a/bin/v-delete-remote-dns-host +++ b/bin/v-delete-remote-dns-host @@ -37,11 +37,19 @@ $BIN/v-delete-remote-dns-domains $host >>/dev/null 2>&1 # Deleting server sed -i "/HOST='$host' /d" $VESTA/conf/dns-cluster.conf -# Disabling DNS_CLUSTER +# Delete DNS_CLUSTER key check_cluster=$(grep HOST $VESTA/conf/dns-cluster.conf |wc -l) if [ "$check_cluster" -eq '0' ]; then rm -f $VESTA/conf/dns-cluster.conf sed -i "/DNS_CLUSTER=/d" $VESTA/conf/vesta.conf + + # Delete cron job + cmd="sudo /usr/local/vesta/bin/v-update-sys-queue dns-cluster" + check_cron=$(grep "$cmd" $VESTA/data/users/admin/cron.conf 2> /dev/null) + if [ ! -z "$check_cron" ]; then + eval $check_cron + $BIN/v-delete-cron-job admin "$JOB" + fi fi diff --git a/bin/v-sync-dns-cluster b/bin/v-sync-dns-cluster index 4eaaa6256..3a0b7141f 100755 --- a/bin/v-sync-dns-cluster +++ b/bin/v-sync-dns-cluster @@ -1,6 +1,6 @@ #!/bin/bash # info: synchronize dns domains -# +# options: HOST # The function synchronize all dns domains. @@ -9,7 +9,8 @@ #----------------------------------------------------------# # Argument defenition -verbose=$1 +host=$1 +verbose=$2 # Includes source $VESTA/conf/vesta.conf @@ -44,8 +45,17 @@ fi old_ifs="$IFS" IFS=$'\n' +if [ -z $host ]; then + hosts=$(cat $VESTA/conf/dns-cluster.conf) + rm -f $VESTA/data/queue/dns-cluster.pipe + touch $VESTA/data/queue/dns-cluster.pipe + chmod 660 $VESTA/data/queue/dns-cluster.pipe +else + hosts=$(grep "HOST='$host'" $VESTA/conf/dns-cluster.conf) +fi + # Starting cluster loop -for cluster_str in $(cat $VESTA/conf/dns-cluster.conf); do +for cluster_str in $hosts; do # Get host values eval $cluster_str @@ -108,11 +118,6 @@ for cluster_str in $(cat $VESTA/conf/dns-cluster.conf); do exit $E_CONNECT fi - # Clean queue - rm -f $VESTA/data/queue/dns-cluster.pipe - touch $VESTA/data/queue/dns-cluster.pipe - chmod 660 $VESTA/data/queue/dns-cluster.pipe - # Start user loop for user in $user_list; do diff --git a/bin/v-update-sys-queue b/bin/v-update-sys-queue index 6bb433b97..7a8a2c65a 100755 --- a/bin/v-update-sys-queue +++ b/bin/v-update-sys-queue @@ -53,7 +53,7 @@ case $queue in backup) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1 ;; disk) bash $VESTA/data/queue/$queue.pipe ;; traffic) bash $VESTA/data/queue/$queue.pipe ;; - dns-cluster) bash $VESTA/data/queue/$queue.pipe ;; + dns-cluster) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1 ;; *) check_args '1' '0' 'QUEUE' ;; esac