From 6365fe984d479c669e16df19f010725f5f4f06d0 Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Sat, 1 Jun 2013 15:51:19 +0300 Subject: [PATCH] restart cron job --- bin/v-add-cron-restart-job | 43 ++++++++++++++++++++++++++++++ bin/v-add-remote-dns-host | 13 +++++++++- bin/v-delete-cron-restart-job | 44 +++++++++++++++++++++++++++++++ bin/v-delete-remote-dns-host | 8 ++++++ bin/v-list-remote-dsn-hosts | 49 +++++++++++++++++++++++++++++++++++ 5 files changed, 156 insertions(+), 1 deletion(-) create mode 100755 bin/v-add-cron-restart-job create mode 100755 bin/v-delete-cron-restart-job create mode 100755 bin/v-list-remote-dsn-hosts diff --git a/bin/v-add-cron-restart-job b/bin/v-add-cron-restart-job new file mode 100755 index 000000000..322279c76 --- /dev/null +++ b/bin/v-add-cron-restart-job @@ -0,0 +1,43 @@ +#!/bin/bash +# info: add cron reports +# opions: NONE +# +# The script for enabling restart cron tasks + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Add cron job +cmd="sudo /usr/local/vesta/bin/v-update-sys-queue restart" +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 '*' '*' '*' '*' '*' "$cmd" +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-remote-dns-host b/bin/v-add-remote-dns-host index d809cd524..238288a25 100755 --- a/bin/v-add-remote-dns-host +++ b/bin/v-add-remote-dns-host @@ -57,6 +57,17 @@ else sed -i "s/DNS_CLUSTER=.*/DNS_CLUSTER='yes'/g" $VESTA/conf/vesta.conf fi +# Enabling restart queue +HOST=$host +PORT=$port +USER=$user +PASSWORD=$password +case $type in + ssh) send_cmd="send_ssh_cmd" ;; + *) send_cmd="send_api_cmd" ;; +esac +$send_cmd v-add-cron-restart-job + # Sync current zones $BIN/v-sync-dns-cluster $host return_code=$? @@ -64,7 +75,7 @@ if [ "$return_code" -ne 0 ]; then exit $return_code fi -# Add cron job +# Add dns-cluster 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 diff --git a/bin/v-delete-cron-restart-job b/bin/v-delete-cron-restart-job new file mode 100755 index 000000000..6baf07cd8 --- /dev/null +++ b/bin/v-delete-cron-restart-job @@ -0,0 +1,44 @@ +#!/bin/bash +# info: delete restart job +# opions: NONE +# +# The script for disabling restart cron tasks + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Add cron job +cmd="sudo /usr/local/vesta/bin/v-update-sys-queue restart" +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 + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-remote-dns-host b/bin/v-delete-remote-dns-host index 86289ae0b..c972f71a9 100755 --- a/bin/v-delete-remote-dns-host +++ b/bin/v-delete-remote-dns-host @@ -34,6 +34,14 @@ is_object_valid "../../conf/dns-cluster" 'HOST' "$host" # Deleting domains $BIN/v-delete-remote-dns-domains $host >>/dev/null 2>&1 +# Disabling restart queue +eval $(grep $host $VESTA/conf/dns-cluster) +case $TYPE in + ssh) send_cmd="send_ssh_cmd" ;; + *) send_cmd="send_api_cmd" ;; +esac +$send_cmd v-add-cron-restart-job + # Deleting server sed -i "/HOST='$host' /d" $VESTA/conf/dns-cluster.conf diff --git a/bin/v-list-remote-dsn-hosts b/bin/v-list-remote-dsn-hosts new file mode 100755 index 000000000..6f8c05b24 --- /dev/null +++ b/bin/v-list-remote-dsn-hosts @@ -0,0 +1,49 @@ +#!/bin/bash +# info: list remote dns host +# options: [FORMAT] +# +# The function for obtaining the list of remote dns host. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Check config +conf=$VESTA/conf/dns-cluster.conf +if [ ! -e "$conf" ]; then + exit +fi + +# Defining fileds to select +fields='$HOST $USER $DNS_USER $TYPE $TIME $DATE' + +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) shell_list| column -t ;; + *) check_args '1' '0' 'USER [FORMAT]';; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit