mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-14 02:28:03 -07:00
dns cluster support
This commit is contained in:
parent
0f7ea97e12
commit
68a34e18b7
47 changed files with 1536 additions and 64 deletions
|
@ -128,6 +128,12 @@ update_domain_zone
|
|||
chmod 640 $conf
|
||||
chown root:named $conf
|
||||
|
||||
# dns-cluster
|
||||
if [ ! -z "$DNS_CLUSTER" ]; then
|
||||
cmd="v-add-remote-dns-domain $user $domain"
|
||||
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
|
@ -139,7 +145,7 @@ increase_user_value "$user" '$U_DNS_RECORDS' "$records"
|
|||
|
||||
# Restart named
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-dns "$EVENT"
|
||||
$BIN/v-restart-dns
|
||||
fi
|
||||
|
||||
# Logging
|
||||
|
|
|
@ -61,7 +61,7 @@ else
|
|||
$user $dom $IP '' '' '' '' $restart > /dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
$BIN/v-add-dns-domain-record \
|
||||
$BIN/v-add-dns-record \
|
||||
$user $dom "$sub" A $IP '' '' $restart
|
||||
fi
|
||||
else
|
||||
|
@ -71,7 +71,7 @@ else
|
|||
rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$dom.conf)
|
||||
fi
|
||||
if [ -z "$rec" ]; then
|
||||
$BIN/v-add-dns-domain-record \
|
||||
$BIN/v-add-dns-record \
|
||||
$user $dom "$sub" A $IP '' '' $restart > /dev/null
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# info: add dns domain record
|
||||
# info: add dns record
|
||||
# options: USER DOMAIN RECORD TYPE VALUE [PRIORITY] [ID] [RESTART]
|
||||
#
|
||||
# The call is used for adding new DNS record. Complex records of TXT, MX and
|
||||
|
@ -73,6 +73,12 @@ sort_dns_records
|
|||
# Updating zone
|
||||
update_domain_zone
|
||||
|
||||
# dns-cluster
|
||||
if [ ! -z "$DNS_CLUSTER" ]; then
|
||||
cmd="v-add-remote-dns-record $user $domain $id"
|
||||
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
|
@ -85,7 +91,7 @@ increase_user_value "$user" '$U_DNS_RECORDS'
|
|||
|
||||
# Restart named
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-dns "$EVENT"
|
||||
$BIN/v-restart-dns
|
||||
fi
|
||||
|
||||
# Logging
|
|
@ -85,11 +85,11 @@ if [ "$dkim" = 'yes' ]; then
|
|||
p=$(cat $USER_DATA/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n')
|
||||
record='_domainkey'
|
||||
policy="\"t=y; o=~;\""
|
||||
$BIN/v-add-dns-domain-record $user $domain $record TXT "$policy"
|
||||
$BIN/v-add-dns-record $user $domain $record TXT "$policy"
|
||||
|
||||
record='mail._domainkey'
|
||||
selector="\"k=rsa\; p=$p\""
|
||||
$BIN/v-add-dns-domain-record $user $domain $record TXT "$selector"
|
||||
$BIN/v-add-dns-record $user $domain $record TXT "$selector"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -58,11 +58,11 @@ if [ "$?" -eq 0 ]; then
|
|||
p=$(cat $USER_DATA/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n')
|
||||
record='_domainkey'
|
||||
policy="\"t=y; o=~;\""
|
||||
$BIN/v-add-dns-domain-record $user $domain $record TXT "$policy"
|
||||
$BIN/v-add-dns-record $user $domain $record TXT "$policy"
|
||||
|
||||
record='mail._domainkey'
|
||||
selector="\"k=rsa\; p=$p\""
|
||||
$BIN/v-add-dns-domain-record $user $domain $record TXT "$selector"
|
||||
$BIN/v-add-dns-record $user $domain $record TXT "$selector"
|
||||
fi
|
||||
|
||||
|
||||
|
|
133
bin/v-add-remote-dns-domain
Executable file
133
bin/v-add-remote-dns-domain
Executable file
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
# info: add remote dns domain
|
||||
# options: USER DOMAIN
|
||||
#
|
||||
# The function synchronize dns domain with the remote server.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
domain=$2
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/remote.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'USER DOMAIN'
|
||||
validate_format 'user' 'domain'
|
||||
is_system_enabled "$DNS_CLUSTER"
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_valid 'dns' 'DOMAIN' "$domain"
|
||||
|
||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||
echo "Error: dns-cluster.conf doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
||||
if [ "$number_of_proc" -gt 2 ]; then
|
||||
echo "Error: another sync process already exists"
|
||||
log_event "$E_EXISTS $EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
old_ifs="$IFS"
|
||||
IFS=$'\n'
|
||||
|
||||
# Starting cluster loop
|
||||
for cluster_str in $(cat $VESTA/conf/dns-cluster.conf); do
|
||||
|
||||
# Get host values
|
||||
eval $cluster_str
|
||||
|
||||
# Check connection type
|
||||
if [ -z "TYPE" ]; then
|
||||
TYPE='api'
|
||||
fi
|
||||
|
||||
# Switch on connection type
|
||||
case $TYPE in
|
||||
ssh) send_cmd="send_ssh_cmd" ;;
|
||||
*) send_cmd="send_api_cmd" ;;
|
||||
esac
|
||||
|
||||
# Check host connection
|
||||
$send_cmd v-list-sys-config
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
|
||||
# Check recipient dns user
|
||||
if [ -z "$DNS_USER" ]; then
|
||||
DNS_USER='dns-cluster'
|
||||
fi
|
||||
$send_cmd v-list-user $DNS_USER
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: dns user $DNS_USER doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
# Check dns exceptions
|
||||
if [ -z "$DNS_CLUSTER_IGNORE" ]; then
|
||||
DNS_CLUSTER_IGNORE='dns-cluster'
|
||||
fi
|
||||
|
||||
# Sync domain
|
||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
||||
eval $str
|
||||
$send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME
|
||||
|
||||
# Sync records
|
||||
if [ "$TYPE" = 'ssh' ]; then
|
||||
tmp=$(mktemp -u)
|
||||
scp_cmd $USER_DATA/dns/$DOMAIN.conf $tmp
|
||||
$send_cmd v-insert-dns-records $DNS_USER $DOMAIN $tmp
|
||||
else
|
||||
for str in $(cat $USER_DATA/dns/$DOMAIN.conf); do
|
||||
str=$(echo "$str" | sed 's/"/\\"/g')
|
||||
$send_cmd v-insert-dns-record $DNS_USER $DOMAIN "$str"
|
||||
done
|
||||
fi
|
||||
|
||||
# Rebuild dns zone
|
||||
$send_cmd v-rebuild-dns-domain $DNS_USER $domain no
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed (rebuild)"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
# Update pipe
|
||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||
str=$(grep -n "$SCRIPT $1 $2$" $pipe | cut -f1 -d: | head -n1)
|
||||
if [ ! -z "$str" ]; then
|
||||
sed -i "$str d" $pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
123
bin/v-add-remote-dns-record
Executable file
123
bin/v-add-remote-dns-record
Executable file
|
@ -0,0 +1,123 @@
|
|||
#!/bin/bash
|
||||
# info: add remote dns domain record
|
||||
# options: USER DOMAIN ID
|
||||
#
|
||||
# The function synchronize dns domain with the remote server.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
domain=$2
|
||||
id=$3
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/remote.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN ID'
|
||||
validate_format 'user' 'domain' 'id'
|
||||
is_system_enabled "$DNS_CLUSTER"
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_valid 'dns' 'DOMAIN' "$domain"
|
||||
is_object_valid "dns/$domain" 'ID' "$id"
|
||||
|
||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||
echo "Error: dns-cluster.conf doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
||||
if [ "$number_of_proc" -gt 2 ]; then
|
||||
echo "Error: another sync process already exists"
|
||||
log_event "$E_EXISTS $EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
old_ifs="$IFS"
|
||||
IFS=$'\n'
|
||||
|
||||
# Starting cluster loop
|
||||
for cluster_str in $(cat $VESTA/conf/dns-cluster.conf); do
|
||||
|
||||
# Get host values
|
||||
eval $cluster_str
|
||||
|
||||
# Check connection type
|
||||
if [ -z "TYPE" ]; then
|
||||
TYPE='api'
|
||||
fi
|
||||
|
||||
# Switch on connection type
|
||||
case $TYPE in
|
||||
ssh) send_cmd="send_ssh_cmd" ;;
|
||||
*) send_cmd="send_api_cmd" ;;
|
||||
esac
|
||||
|
||||
# Check host connection
|
||||
$send_cmd v-list-sys-config
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
|
||||
# Check recipient dns user
|
||||
if [ -z "$DNS_USER" ]; then
|
||||
DNS_USER='dns-cluster'
|
||||
fi
|
||||
$send_cmd v-list-user $DNS_USER
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: dns user $DNS_USER doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
# Check dns exceptions
|
||||
if [ -z "$DNS_CLUSTER_IGNORE" ]; then
|
||||
DNS_CLUSTER_IGNORE='dns-cluster'
|
||||
fi
|
||||
|
||||
# Sync record
|
||||
str=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf)
|
||||
str=$(echo "$str" | sed 's/"/\\"/g')
|
||||
$send_cmd v-insert-dns-record $DNS_USER $domain "$str"
|
||||
|
||||
# Rebuild dns zone
|
||||
$send_cmd v-rebuild-dns-domain $DNS_USER $domain no
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed (rebuild)"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
# Update pipe
|
||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||
str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
|
||||
if [ ! -z "$str" ]; then
|
||||
sed -i "$str d" $pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
|
@ -41,6 +41,12 @@ is_object_unsuspended 'dns' 'DOMAIN' "$domain"
|
|||
# Changing exp
|
||||
update_object_value 'dns' 'DOMAIN' "$domain" '$EXP' "$exp"
|
||||
|
||||
# dns-cluster
|
||||
if [ ! -z "$DNS_CLUSTER" ]; then
|
||||
cmd="v-change-remote-dns-domain-exp $user $domain"
|
||||
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
|
|
|
@ -52,6 +52,12 @@ sed -i "s/$old/$ip/g" $USER_DATA/dns/$domain.conf
|
|||
# Updating zone
|
||||
update_domain_zone
|
||||
|
||||
# dns-cluster
|
||||
if [ ! -z "$DNS_CLUSTER" ]; then
|
||||
cmd="v-add-remote-dns-domain $user $domain"
|
||||
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
|
@ -59,7 +65,7 @@ update_domain_zone
|
|||
|
||||
# Restart named
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-dns "$EVENT"
|
||||
$BIN/v-restart-dns
|
||||
fi
|
||||
|
||||
# Logging
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# options: USER DOMAIN SOA
|
||||
#
|
||||
# The function for changing SOA record. This type of records can not be
|
||||
# modified by v-change-dns-domain-record call.
|
||||
# modified by v-change-dns-record call.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
|
@ -46,6 +46,12 @@ update_object_value 'dns' 'DOMAIN' "$domain" '$SOA' "$soa"
|
|||
# Updating zone
|
||||
update_domain_zone
|
||||
|
||||
# dns-cluster
|
||||
if [ ! -z "$DNS_CLUSTER" ]; then
|
||||
cmd="v-change-remote-dns-domain-soa $user $domain"
|
||||
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
# info: change dns domain template
|
||||
# options: USER DOMAIN
|
||||
# options: USER DOMAIN TEMPLATE [RESTART]
|
||||
#
|
||||
# The function for changing the template of records. By updating old records
|
||||
# will be removed and new records will be generated in accordance with
|
||||
|
@ -16,6 +16,7 @@ user=$1
|
|||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
template=$3
|
||||
restart=$4
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
@ -27,7 +28,7 @@ source $VESTA/func/domain.sh
|
|||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN TEMPLATE'
|
||||
check_args '3' "$#" 'USER DOMAIN TEMPLATE [RESTART]'
|
||||
validate_format 'user' 'domain' 'template'
|
||||
is_system_enabled "$DNS_SYSTEM"
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
@ -69,13 +70,21 @@ cat $DNSTPL/$template.tpl |\
|
|||
# Updating zone
|
||||
update_domain_zone
|
||||
|
||||
# dns-cluster
|
||||
if [ ! -z "$DNS_CLUSTER" ]; then
|
||||
cmd="v-add-remote-dns-domain $user $domain"
|
||||
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Restart named
|
||||
$BIN/v-restart-dns "$EVENT"
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-dns
|
||||
fi
|
||||
|
||||
# Logging
|
||||
log_history "changed dns template for $domain to $template" '' 'admin'
|
||||
|
|
|
@ -45,6 +45,12 @@ update_object_value 'dns' 'DOMAIN' "$domain" '$TTL' "$ttl"
|
|||
# Updating zone
|
||||
update_domain_zone
|
||||
|
||||
# dns-cluster
|
||||
if [ ! -z "$DNS_CLUSTER" ]; then
|
||||
cmd="v-change-remote-dns-domain-ttl $user $domain"
|
||||
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
# info: change dns domain record
|
||||
# options: USER DOMAIN ID VALUE [PRIORITY]
|
||||
# options: USER DOMAIN ID VALUE [PRIORITY] [RESTART]
|
||||
#
|
||||
# The function for changing DNS record.
|
||||
|
||||
|
@ -18,6 +18,7 @@ id=$3
|
|||
dvalue=$(idn -t --quiet -u "$4" )
|
||||
dvalue=$(echo $dvalue | tr '[:upper:]' '[:lower:]')
|
||||
priority=$5
|
||||
restart=$6
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
@ -29,7 +30,7 @@ source $VESTA/func/domain.sh
|
|||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '4' "$#" 'USER DOMAIN ID VALUE [PRIORITY]'
|
||||
check_args '4' "$#" 'USER DOMAIN ID VALUE [PRIORITY] [RESTART]'
|
||||
validate_format 'user' 'domain' 'id' 'dvalue'
|
||||
is_system_enabled "$DNS_SYSTEM"
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
@ -62,13 +63,21 @@ sort_dns_records
|
|||
# Updating zone
|
||||
update_domain_zone
|
||||
|
||||
# dns-cluster
|
||||
if [ ! -z "$DNS_CLUSTER" ]; then
|
||||
cmd="v-add-remote-dns-domain $user $domain"
|
||||
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Restart named
|
||||
$BIN/v-restart-dns "$EVENT"
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-dns
|
||||
fi
|
||||
|
||||
# Logging
|
||||
log_history "changed dns record on $domain to $dvalue"
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
# info: change dns domain record id
|
||||
# options: USER DOMAIN ID NEWID
|
||||
# options: USER DOMAIN ID NEWID [RESTART]
|
||||
#
|
||||
# The function for changing internal record id.
|
||||
|
||||
|
@ -16,6 +16,7 @@ domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
|||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
id=$3
|
||||
newid=$4
|
||||
restart=$5
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
@ -27,7 +28,7 @@ source $VESTA/func/domain.sh
|
|||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '4' "$#" 'USER DOMAIN ID NEWID'
|
||||
check_args '4' "$#" 'USER DOMAIN ID NEWID [RESTART]'
|
||||
validate_format 'user' 'domain' 'id' 'newid'
|
||||
is_system_enabled "$DNS_SYSTEM"
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
@ -38,7 +39,6 @@ is_object_valid "dns/$domain" 'ID' "$id"
|
|||
is_object_new "dns/$domain" 'ID' "$newid"
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
@ -52,13 +52,21 @@ sort_dns_records
|
|||
# Updating zone
|
||||
update_domain_zone
|
||||
|
||||
# dns-cluster
|
||||
if [ ! -z "$DNS_CLUSTER" ]; then
|
||||
cmd="v-add-remote-dns-domain $user $domain"
|
||||
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Restart named
|
||||
$BIN/v-restart-dns "$EVENT"
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-dns
|
||||
fi
|
||||
|
||||
# Logging
|
||||
log_history "changed dns record id on $domain"
|
113
bin/v-change-remote-dns-domain-exp
Executable file
113
bin/v-change-remote-dns-domain-exp
Executable file
|
@ -0,0 +1,113 @@
|
|||
#!/bin/bash
|
||||
# info: change remote dns domain expiriation date
|
||||
# options: USER DOMAIN
|
||||
#
|
||||
# The function synchronize dns domain with the remote server.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
domain=$2
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/remote.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'USER DOMAIN'
|
||||
validate_format 'user' 'domain'
|
||||
is_system_enabled "$DNS_CLUSTER"
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_valid 'dns' 'DOMAIN' "$domain"
|
||||
|
||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||
echo "Error: dns-cluster.conf doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
||||
if [ "$number_of_proc" -gt 2 ]; then
|
||||
echo "Error: another sync process already exists"
|
||||
log_event "$E_EXISTS $EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
old_ifs="$IFS"
|
||||
IFS=$'\n'
|
||||
|
||||
# Starting cluster loop
|
||||
for cluster_str in $(cat $VESTA/conf/dns-cluster.conf); do
|
||||
|
||||
# Get host values
|
||||
eval $cluster_str
|
||||
|
||||
# Check connection type
|
||||
if [ -z "TYPE" ]; then
|
||||
TYPE='api'
|
||||
fi
|
||||
|
||||
# Switch on connection type
|
||||
case $TYPE in
|
||||
ssh) send_cmd="send_ssh_cmd" ;;
|
||||
*) send_cmd="send_api_cmd" ;;
|
||||
esac
|
||||
|
||||
# Check host connection
|
||||
$send_cmd v-list-sys-config
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
|
||||
# Check recipient dns user
|
||||
if [ -z "$DNS_USER" ]; then
|
||||
DNS_USER='dns-cluster'
|
||||
fi
|
||||
$send_cmd v-list-user $DNS_USER
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: dns user $DNS_USER doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
# Check dns exceptions
|
||||
if [ -z "$DNS_CLUSTER_IGNORE" ]; then
|
||||
DNS_CLUSTER_IGNORE='dns-cluster'
|
||||
fi
|
||||
|
||||
# Sync domain
|
||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
||||
eval $str
|
||||
$send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'no'
|
||||
|
||||
done
|
||||
|
||||
# Update pipe
|
||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||
str=$(grep -n "$SCRIPT $1 $2$" $pipe | cut -f1 -d: | head -n1)
|
||||
if [ ! -z "$str" ]; then
|
||||
sed -i "$str d" $pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
121
bin/v-change-remote-dns-domain-soa
Executable file
121
bin/v-change-remote-dns-domain-soa
Executable file
|
@ -0,0 +1,121 @@
|
|||
#!/bin/bash
|
||||
# info: change remote dns domain SOA
|
||||
# options: USER DOMAIN
|
||||
#
|
||||
# The function synchronize dns domain with the remote server.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
domain=$2
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/remote.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'USER DOMAIN'
|
||||
validate_format 'user' 'domain'
|
||||
is_system_enabled "$DNS_CLUSTER"
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_valid 'dns' 'DOMAIN' "$domain"
|
||||
|
||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||
echo "Error: dns-cluster.conf doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
||||
if [ "$number_of_proc" -gt 2 ]; then
|
||||
echo "Error: another sync process already exists"
|
||||
log_event "$E_EXISTS $EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
old_ifs="$IFS"
|
||||
IFS=$'\n'
|
||||
|
||||
# Starting cluster loop
|
||||
for cluster_str in $(cat $VESTA/conf/dns-cluster.conf); do
|
||||
|
||||
# Get host values
|
||||
eval $cluster_str
|
||||
|
||||
# Check connection type
|
||||
if [ -z "TYPE" ]; then
|
||||
TYPE='api'
|
||||
fi
|
||||
|
||||
# Switch on connection type
|
||||
case $TYPE in
|
||||
ssh) send_cmd="send_ssh_cmd" ;;
|
||||
*) send_cmd="send_api_cmd" ;;
|
||||
esac
|
||||
|
||||
# Check host connection
|
||||
$send_cmd v-list-sys-config
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
|
||||
# Check recipient dns user
|
||||
if [ -z "$DNS_USER" ]; then
|
||||
DNS_USER='dns-cluster'
|
||||
fi
|
||||
$send_cmd v-list-user $DNS_USER
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: dns user $DNS_USER doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
# Check dns exceptions
|
||||
if [ -z "$DNS_CLUSTER_IGNORE" ]; then
|
||||
DNS_CLUSTER_IGNORE='dns-cluster'
|
||||
fi
|
||||
|
||||
# Sync domain
|
||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
||||
eval $str
|
||||
$send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'no'
|
||||
|
||||
# Rebuild dns zone
|
||||
$send_cmd v-rebuild-dns-domain $DNS_USER $domain no
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed (rebuild)"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
# Update pipe
|
||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||
str=$(grep -n "$SCRIPT $1 $2$" $pipe | cut -f1 -d: | head -n1)
|
||||
if [ ! -z "$str" ]; then
|
||||
sed -i "$str d" $pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
120
bin/v-change-remote-dns-domain-ttl
Executable file
120
bin/v-change-remote-dns-domain-ttl
Executable file
|
@ -0,0 +1,120 @@
|
|||
#!/bin/bash
|
||||
# info: change remote dns domain TTL
|
||||
# options: USER DOMAIN
|
||||
#
|
||||
# The function synchronize dns domain with the remote server.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
domain=$2
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/remote.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'USER DOMAIN'
|
||||
validate_format 'user' 'domain'
|
||||
is_system_enabled "$DNS_CLUSTER"
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_valid 'dns' 'DOMAIN' "$domain"
|
||||
|
||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||
echo "Error: dns-cluster.conf doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
||||
if [ "$number_of_proc" -gt 2 ]; then
|
||||
echo "Error: another sync process already exists"
|
||||
log_event "$E_EXISTS $EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
old_ifs="$IFS"
|
||||
IFS=$'\n'
|
||||
|
||||
# Starting cluster loop
|
||||
for cluster_str in $(cat $VESTA/conf/dns-cluster.conf); do
|
||||
|
||||
# Get host values
|
||||
eval $cluster_str
|
||||
|
||||
# Check connection type
|
||||
if [ -z "TYPE" ]; then
|
||||
TYPE='api'
|
||||
fi
|
||||
|
||||
# Switch on connection type
|
||||
case $TYPE in
|
||||
ssh) send_cmd="send_ssh_cmd" ;;
|
||||
*) send_cmd="send_api_cmd" ;;
|
||||
esac
|
||||
|
||||
# Check host connection
|
||||
$send_cmd v-list-sys-config
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
|
||||
# Check recipient dns user
|
||||
if [ -z "$DNS_USER" ]; then
|
||||
DNS_USER='dns-cluster'
|
||||
fi
|
||||
$send_cmd v-list-user $DNS_USER
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: dns user $DNS_USER doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
# Check dns exceptions
|
||||
if [ -z "$DNS_CLUSTER_IGNORE" ]; then
|
||||
DNS_CLUSTER_IGNORE='dns-cluster'
|
||||
fi
|
||||
|
||||
# Sync domain
|
||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
||||
eval $str
|
||||
$send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'no'
|
||||
|
||||
# Rebuild dns zone
|
||||
$send_cmd v-rebuild-dns-domain $DNS_USER $domain no
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed (rebuild)"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
# Update pipe
|
||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||
str=$(grep -n "$SCRIPT $1 $2$" $pipe | cut -f1 -d: | head -n1)
|
||||
if [ ! -z "$str" ]; then
|
||||
sed -i "$str d" $pipe
|
||||
fi
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
|
@ -41,9 +41,15 @@ is_object_unsuspended 'dns' 'DOMAIN' "$domain"
|
|||
records=$(wc -l $USER_DATA/dns/$domain.conf | cut -f 1 -d ' ')
|
||||
|
||||
# Deleting domain in named.conf
|
||||
sed -i "/\/$domain.db\"/d" /etc/named.conf
|
||||
sed -i "/\/$user\/conf\/dns\/$domain.db\"/d" /etc/named.conf
|
||||
rm -f $HOMEDIR/$user/conf/dns/$domain.db
|
||||
|
||||
# dns-cluster
|
||||
if [ ! -z "$DNS_CLUSTER" ]; then
|
||||
cmd="v-delete-remote-dns-domain $user $domain"
|
||||
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
|
@ -62,7 +68,6 @@ if [ "$restart" != 'no' ]; then
|
|||
$BIN/v-restart-dns "$EVENT"
|
||||
fi
|
||||
|
||||
|
||||
# Logging
|
||||
log_history "deleted dns domain $domain"
|
||||
log_event "$OK" "$EVENT"
|
||||
|
|
54
bin/v-delete-dns-domains-src
Executable file
54
bin/v-delete-dns-domains-src
Executable file
|
@ -0,0 +1,54 @@
|
|||
#!/bin/bash
|
||||
# info: delete dns domains based on SRC field
|
||||
# options: USER SRC [RESTART]
|
||||
#
|
||||
# The function for deleting DNS domains related to a certain host.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
src=$2
|
||||
restart=$3
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
source $VESTA/func/main.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'USER SRC [RESTART]'
|
||||
validate_format 'user' 'src'
|
||||
is_system_enabled "$DNS_SYSTEM"
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Starting delete loop
|
||||
for domain in $(search_objects 'dns' 'SRC' "$src" 'DOMAIN'); do
|
||||
$BIN/v-delete-dns-domain "$user" "$domain" 'no'
|
||||
done
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Restart named
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-dns "$EVENT"
|
||||
fi
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
|
@ -63,7 +63,7 @@ else
|
|||
fi
|
||||
if [ ! -z "$rec" ]; then
|
||||
eval "$rec"
|
||||
$BIN/v-delete-dns-domain-record $user "$root" "$ID"
|
||||
$BIN/v-delete-dns-record $user "$root" "$ID"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
# info: delete dns record
|
||||
# options: USER DOMAIN ID
|
||||
# options: USER DOMAIN ID [RESTART]
|
||||
#
|
||||
# The function for deleting a certain record of DNS zone.
|
||||
|
||||
|
@ -14,6 +14,7 @@ user=$1
|
|||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
id=$3
|
||||
restart=$4
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
@ -25,7 +26,7 @@ source $VESTA/func/domain.sh
|
|||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN ID'
|
||||
check_args '3' "$#" 'USER DOMAIN ID [RESTART]'
|
||||
validate_format 'user' 'domain' 'id'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
|
@ -44,6 +45,12 @@ sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf
|
|||
# Updating zone
|
||||
update_domain_zone
|
||||
|
||||
# dns-cluster
|
||||
if [ ! -z "$DNS_CLUSTER" ]; then
|
||||
cmd="v-delete-remote-dns-record $user $domain $id"
|
||||
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
|
@ -55,7 +62,9 @@ update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
|
|||
decrease_user_value "$user" '$U_DNS_RECORDS'
|
||||
|
||||
# Restart named
|
||||
$BIN/v-restart-dns "$EVENT"
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-dns
|
||||
fi
|
||||
|
||||
# Logging
|
||||
log_history "deleted dns record $id on $domain"
|
|
@ -46,10 +46,10 @@ rm -f $HOMEDIR/$user/conf/mail/$domain/dkim.pem
|
|||
# Checking dns domain
|
||||
check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain")
|
||||
if [ "$?" -eq 0 ]; then
|
||||
records=$($BIN/v-list-dns-domain-records $user $domain plain)
|
||||
records=$($BIN/v-list-dns-records $user $domain plain)
|
||||
dkim_records=$(echo "$records" |grep -w '_domainkey' | cut -f 1 -d ' ')
|
||||
for id in $dkim_records; do
|
||||
$BIN/v-delete-dns-domain-record $user $domain $id
|
||||
$BIN/v-delete-dns-record $user $domain $id
|
||||
done
|
||||
fi
|
||||
|
||||
|
|
109
bin/v-delete-remote-dns-domain
Executable file
109
bin/v-delete-remote-dns-domain
Executable file
|
@ -0,0 +1,109 @@
|
|||
#!/bin/bash
|
||||
# info: delete remote dns domain
|
||||
# options: USER DOMAIN
|
||||
#
|
||||
# The function synchronize dns with the remote server.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
domain=$2
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/remote.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'USER DOMAIN'
|
||||
validate_format 'user' 'domain'
|
||||
is_system_enabled "$DNS_CLUSTER"
|
||||
|
||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||
echo "Error: dns-cluster.conf doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
||||
if [ "$number_of_proc" -gt 2 ]; then
|
||||
echo "Error: another sync process already exists"
|
||||
log_event "$E_EXISTS $EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
old_ifs="$IFS"
|
||||
IFS=$'\n'
|
||||
|
||||
# Starting cluster loop
|
||||
for cluster_str in $(cat $VESTA/conf/dns-cluster.conf); do
|
||||
|
||||
# Get host values
|
||||
eval $cluster_str
|
||||
|
||||
# Check connection type
|
||||
if [ -z "TYPE" ]; then
|
||||
TYPE='api'
|
||||
fi
|
||||
|
||||
# Switch on connection type
|
||||
case $TYPE in
|
||||
ssh) send_cmd="send_ssh_cmd" ;;
|
||||
*) send_cmd="send_api_cmd" ;;
|
||||
esac
|
||||
|
||||
# Check host connection
|
||||
$send_cmd v-list-sys-config
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
|
||||
# Check recipient dns user
|
||||
if [ -z "$DNS_USER" ]; then
|
||||
DNS_USER='dns-cluster'
|
||||
fi
|
||||
$send_cmd v-list-user $DNS_USER
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: dns user $DNS_USER doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
# Check dns exceptions
|
||||
if [ -z "$DNS_CLUSTER_IGNORE" ]; then
|
||||
DNS_CLUSTER_IGNORE='dns-cluster'
|
||||
fi
|
||||
|
||||
# Sync domain
|
||||
$send_cmd v-delete-dns-domain $DNS_USER $domain 'no'
|
||||
|
||||
done
|
||||
|
||||
# Update pipe
|
||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||
str=$(grep -n "$SCRIPT $1 $2$" $pipe | cut -f1 -d: | head -n1)
|
||||
if [ ! -z "$str" ]; then
|
||||
sed -i "$str d" $pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
105
bin/v-delete-remote-dns-record
Executable file
105
bin/v-delete-remote-dns-record
Executable file
|
@ -0,0 +1,105 @@
|
|||
#!/bin/bash
|
||||
# info: delete remote dns domain record
|
||||
# options: USER DOMAIN ID
|
||||
#
|
||||
# The function synchronize dns with the remote server.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
domain=$2
|
||||
id=$3
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/remote.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN ID'
|
||||
validate_format 'user' 'domain' 'id'
|
||||
is_system_enabled "$DNS_CLUSTER"
|
||||
|
||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||
echo "Error: dns-cluster.conf doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
||||
if [ "$number_of_proc" -gt 2 ]; then
|
||||
echo "Error: another sync process already exists"
|
||||
log_event "$E_EXISTS $EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
old_ifs="$IFS"
|
||||
IFS=$'\n'
|
||||
|
||||
# Starting cluster loop
|
||||
for cluster_str in $(cat $VESTA/conf/dns-cluster.conf); do
|
||||
|
||||
# Get host values
|
||||
eval $cluster_str
|
||||
|
||||
# Check connection type
|
||||
if [ -z "TYPE" ]; then
|
||||
TYPE='api'
|
||||
fi
|
||||
|
||||
# Switch on connection type
|
||||
case $TYPE in
|
||||
ssh) send_cmd="send_ssh_cmd" ;;
|
||||
*) send_cmd="send_api_cmd" ;;
|
||||
esac
|
||||
|
||||
# Check host connection
|
||||
$send_cmd v-list-sys-config
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
|
||||
# Check recipient dns user
|
||||
if [ -z "$DNS_USER" ]; then
|
||||
DNS_USER='dns-cluster'
|
||||
fi
|
||||
$send_cmd v-list-user $DNS_USER
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: dns user $DNS_USER doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
# Sync domain
|
||||
$send_cmd v-delete-dns-record $DNS_USER $domain $id 'no'
|
||||
|
||||
done
|
||||
|
||||
# Update pipe
|
||||
pipe="$VESTA/data/queue/dns-cluster.pipe"
|
||||
str=$(grep -n "$SCRIPT $1 $2 &3$" $pipe | cut -f1 -d: | head -n1)
|
||||
if [ ! -z "$str" ]; then
|
||||
sed -i "$str d" $pipe
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
62
bin/v-insert-dns-domain
Executable file
62
bin/v-insert-dns-domain
Executable file
|
@ -0,0 +1,62 @@
|
|||
#!/bin/bash
|
||||
# info: insert dns domain
|
||||
# options: USER DATA [SRC] [FLUSH]
|
||||
#
|
||||
# The function inserts raw record to the dns.conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
data=$2
|
||||
src=$3
|
||||
flush=$4
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
source $VESTA/func/main.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'USER DATA [SRC]'
|
||||
validate_format 'user' 'data'
|
||||
is_system_enabled "$DNS_SYSTEM"
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Prepare values for the insert
|
||||
eval $data
|
||||
dns_rec="DOMAIN='$DOMAIN' IP='$IP' TPL='$TPL' TTL='$TTL' EXP='$EXP'"
|
||||
dns_rec="$dns_rec SOA='$SOA' SRC='$src' RECORDS='$RECORDS'"
|
||||
dns_rec="$dns_rec SUSPENDED='$SUSPENDED' TIME='$TIME' DATE='$DATE'"
|
||||
sed -i "/DOMAIN='$DOMAIN'/d" $USER_DATA/dns.conf 2> /dev/null
|
||||
echo "$dns_rec" >> $USER_DATA/dns.conf
|
||||
chmod 660 $USER_DATA/dns.conf
|
||||
|
||||
# Flush dns records
|
||||
if [ "$flush" != 'no' ]; then
|
||||
rm -f $USER_DATA/dns/$DOMAIN.conf
|
||||
touch $USER_DATA/dns/$DOMAIN.conf
|
||||
chmod 660 $USER_DATA/dns/$DOMAIN.conf
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
49
bin/v-insert-dns-record
Executable file
49
bin/v-insert-dns-record
Executable file
|
@ -0,0 +1,49 @@
|
|||
#!/bin/bash
|
||||
# info: insert dns record
|
||||
# options: USER DOMAIN DATA
|
||||
#
|
||||
# The function inserts raw dns record to the domain conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
domain=$2
|
||||
data=$3
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
source $VESTA/func/main.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN DATA'
|
||||
validate_format 'user' 'domain' 'data'
|
||||
is_system_enabled "$DNS_SYSTEM"
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
is_object_valid 'dns' 'DOMAIN' "$domain"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Insert values
|
||||
echo "$data" >> $USER_DATA/dns/$domain.conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
52
bin/v-insert-dns-records
Executable file
52
bin/v-insert-dns-records
Executable file
|
@ -0,0 +1,52 @@
|
|||
#!/bin/bash
|
||||
# info: inserts dns records
|
||||
# options: USER DOMAIN DATA_FILE
|
||||
#
|
||||
# The function copy dns record to the domain conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
domain=$2
|
||||
data_file=$3
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
source $VESTA/func/main.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN DATAFILE'
|
||||
validate_format 'user' 'domain' 'data_file'
|
||||
is_system_enabled "$DNS_SYSTEM"
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
is_object_valid 'dns' 'DOMAIN' "$domain"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Insert values
|
||||
if [ -e "$data_file" ]; then
|
||||
mv -f $data_file $USER_DATA/dns/$domain.conf
|
||||
chmod 660 $USER_DATA/dns/$domain.conf
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
|
@ -32,7 +32,7 @@ is_object_valid 'user' 'USER' "$user"
|
|||
|
||||
# Defining config and fields
|
||||
conf=$USER_DATA/dns.conf
|
||||
fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $RECORDS $SUSPENDED $TIME $DATE'
|
||||
fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $SRC $RECORDS $SUSPENDED $TIME $DATE'
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
|
|
51
bin/v-list-dns-domains-src
Executable file
51
bin/v-list-dns-domains-src
Executable file
|
@ -0,0 +1,51 @@
|
|||
#!/bin/bash
|
||||
# info: list dns domains
|
||||
# options: USER [FORMAT]
|
||||
#
|
||||
# The function for obtaining all DNS domains of a user.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
format=${2-shell}
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '1' "$#" 'USER [FORMAT]'
|
||||
validate_format 'user'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Defining config and fields
|
||||
conf=$USER_DATA/dns.conf
|
||||
fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $SRC $RECORDS $SUSPENDED $TIME $DATE'
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) json_list ;;
|
||||
plain) nohead=1; shell_list ;;
|
||||
shell) fields='$DOMAIN $IP $SRC $DATE';
|
||||
shell_list| column -t ;;
|
||||
*) check_args '1' '0' 'USER [FORMAT]';;
|
||||
esac
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
77
bin/v-rebuild-dns-domain
Executable file
77
bin/v-rebuild-dns-domain
Executable file
|
@ -0,0 +1,77 @@
|
|||
#!/bin/bash
|
||||
# info: rebuild dns domain
|
||||
# options: USER DOMAIN [RESTART]
|
||||
#
|
||||
# The function rebuilds DNS configuration files.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
domain=$2
|
||||
restart=$3
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/domain.sh
|
||||
source $VESTA/func/rebuild.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'USER DOMAIN [RESTART]'
|
||||
validate_format 'user' 'domain'
|
||||
is_system_enabled "$DNS_SYSTEM"
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
is_object_valid 'dns' 'DOMAIN' "$domain"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
user_domains=0
|
||||
user_records=0
|
||||
suspended_dns=0
|
||||
conf="$USER_DATA/dns.conf"
|
||||
|
||||
# Defining user name servers
|
||||
ns=$(get_user_value '$NS')
|
||||
i=1
|
||||
for nameserver in ${ns//,/ };do
|
||||
eval ns$i="$nameserver"
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
# Remove old user's zone
|
||||
sed -i "/\/$user\/conf\/dns/d" /etc/named.conf
|
||||
|
||||
# Starting loop
|
||||
rebuild_dns_domain_conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Updating counters
|
||||
update_user_value "$user" '$U_DNS_DOMAINS' "$user_domains"
|
||||
update_user_value "$user" '$U_DNS_RECORDS' "$user_records"
|
||||
update_user_value "$user" '$SUSPENDED_DNS' "$suspended_dns"
|
||||
|
||||
# Restart named
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-dns "$EVENT"
|
||||
fi
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
|
@ -2,7 +2,7 @@
|
|||
# info: rebuild dns domains
|
||||
# options: USER [RESTART]
|
||||
#
|
||||
# The function rebuilds BIND configuration files for all dns domains.
|
||||
# The function rebuilds DNS configuration files.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# info: rebuild dns domains
|
||||
# options: USER [RESTART]
|
||||
#
|
||||
# The function rebuilds BIND configuration files for all dns domains.
|
||||
# The function rebuilds web configuration files.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
|
|
157
bin/v-sync-dns-cluster
Executable file
157
bin/v-sync-dns-cluster
Executable file
|
@ -0,0 +1,157 @@
|
|||
#!/bin/bash
|
||||
# info: synchronize dns domains
|
||||
#
|
||||
# The function synchronize all dns domains.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
verbose=$1
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/remote.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
is_system_enabled "$DNS_CLUSTER"
|
||||
|
||||
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
|
||||
echo "Error: dns-cluster.conf doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
|
||||
if [ "$number_of_proc" -gt 2 ]; then
|
||||
echo "Error: another sync process already exists"
|
||||
log_event "$E_EXISTS $EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
old_ifs="$IFS"
|
||||
IFS=$'\n'
|
||||
|
||||
# Starting cluster loop
|
||||
for cluster_str in $(cat $VESTA/conf/dns-cluster.conf); do
|
||||
|
||||
# Get host values
|
||||
eval $cluster_str
|
||||
|
||||
# Check connection type
|
||||
if [ -z "TYPE" ]; then
|
||||
TYPE='api'
|
||||
fi
|
||||
|
||||
# Print hostname
|
||||
if [ ! -z "$verbose" ]; then
|
||||
echo "HOSTNAME: $HOSTNAME"
|
||||
echo "TYPE: $TYPE"
|
||||
fi
|
||||
|
||||
# Switch on connection type
|
||||
case $TYPE in
|
||||
ssh) send_cmd="send_ssh_cmd" ;;
|
||||
*) send_cmd="send_api_cmd" ;;
|
||||
esac
|
||||
|
||||
# Check host connection
|
||||
$send_cmd v-list-sys-config
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
|
||||
# Check recipient dns user
|
||||
if [ -z "$DNS_USER" ]; then
|
||||
DNS_USER='dns-cluster'
|
||||
fi
|
||||
if [ ! -z "$verbose" ]; then
|
||||
echo "DNS_USER: $DNS_USER"
|
||||
fi
|
||||
$send_cmd v-list-user $DNS_USER
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: dns user $DNS_USER doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
# Check dns exceptions
|
||||
if [ -z "$DNS_CLUSTER_IGNORE" ]; then
|
||||
DNS_CLUSTER_IGNORE='dns-cluster'
|
||||
fi
|
||||
|
||||
# Create userlist
|
||||
user_list=$(ls $VESTA/data/users)
|
||||
for exception in $(echo -e "${DNS_CLUSTER_IGNORE//,/\n}"); do
|
||||
user_list=$(echo "$user_list" | grep -v "^$exception$")
|
||||
done
|
||||
|
||||
# Clean source records
|
||||
$send_cmd v-delete-dns-domains-src $DNS_USER $HOSTNAME no
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed (cleanup)"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
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
|
||||
|
||||
# Sync domain
|
||||
for str in $(cat $VESTA/data/users/$user/dns.conf); do
|
||||
eval $str
|
||||
if [ ! -z "$verbose" ]; then
|
||||
echo "DOMAIN: $DOMAIN"
|
||||
fi
|
||||
$send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME
|
||||
|
||||
# Sync record
|
||||
if [ "$TYPE" = 'ssh' ]; then
|
||||
tmp=$(mktemp -u)
|
||||
scp_cmd $USER_DATA/$user/dns/$DOMAIN.conf $tmp
|
||||
$send_cmd v-insert-dns-records $DNS_USER $DOMAIN $tmp
|
||||
else
|
||||
for str in $(cat $USER_DATA/$user/dns/$DOMAIN.conf); do
|
||||
str=$(echo "$str" | sed 's/"/\\"/g')
|
||||
$send_cmd v-insert-dns-record \
|
||||
$DNS_USER $DOMAIN "$str"
|
||||
done
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# Rebuild dns zones
|
||||
$send_cmd v-rebuild-dns-domains $DNS_USER
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $TYPE connection to $HOST failed (rebuild)"
|
||||
log_event "$E_CONNECT $EVENT"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
|
@ -32,27 +32,29 @@ PATH=$PATH:$BIN
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '1' "$#" 'QUEUE'
|
||||
b_task=$(ps auxf |grep -v "grep" |grep "$VESTA/bin/v-update-sys-queue backup")
|
||||
b_task=$(echo "$b_task" |grep -v sudo |wc -l)
|
||||
if [ "$b_task" -gt 2 ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
b_task=$(ps auxf |grep -v "grep" |grep "$VESTA/bin/v-update-sys-queue backup")
|
||||
b_task=$(echo "$b_task" |grep -v sudo |wc -l)
|
||||
d_task=$(ps auxf |grep -v "grep" |grep "$VESTA/bin/v-update-sys-queue dns")
|
||||
d_task=$(echo "$d_task" |grep -v sudo |wc -l)
|
||||
if [ "$b_task" -gt 2 ] || [ "$d_task" -gt 2 ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Defining pipe functions
|
||||
case $queue in
|
||||
restart) bash $VESTA/data/queue/restart.pipe;
|
||||
rm $VESTA/data/queue/restart.pipe;
|
||||
touch $VESTA/data/queue/restart.pipe;;
|
||||
webstats) bash $VESTA/data/queue/webstats.pipe > /dev/null 2>&1 ;;
|
||||
backup) bash $VESTA/data/queue/backup.pipe > /dev/null 2>&1 ;;
|
||||
disk) bash $VESTA/data/queue/disk.pipe;;
|
||||
traffic) bash $VESTA/data/queue/traffic.pipe;;
|
||||
*) check_args '1' '0' 'QUEUE'
|
||||
restart) bash $VESTA/data/queue/$queue.pipe ;;
|
||||
webstats) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
|
||||
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 ;;
|
||||
*) check_args '1' '0' 'QUEUE' ;;
|
||||
esac
|
||||
|
||||
|
||||
|
|
|
@ -429,10 +429,10 @@ rebuild_mail_domain_conf() {
|
|||
chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem
|
||||
|
||||
# Deleting old dkim records
|
||||
records=$($BIN/v-list-dns-domain-records $user $domain plain)
|
||||
records=$($BIN/v-list-dns-records $user $domain plain)
|
||||
dkim_records=$(echo "$records" |grep -w '_domainkey'|cut -f 1 -d ' ')
|
||||
for id in $dkim_records; do
|
||||
$BIN/v-delete-dns-domain-record $user $domain $id
|
||||
$BIN/v-delete-dns-record $user $domain $id
|
||||
done
|
||||
|
||||
# Adding dkim dns records
|
||||
|
@ -441,11 +441,11 @@ rebuild_mail_domain_conf() {
|
|||
p=$(cat $pub|grep -v ' KEY---'|tr -d '\n')
|
||||
record='_domainkey'
|
||||
policy="\"t=y; o=~;\""
|
||||
$BIN/v-add-dns-domain-record $user $domain $record TXT "$policy"
|
||||
$BIN/v-add-dns-record $user $domain $record TXT "$policy"
|
||||
|
||||
record='mail._domainkey'
|
||||
slct="\"k=rsa\; p=$p\""
|
||||
$BIN/v-add-dns-domain-record $user $domain $record TXT "$slct"
|
||||
$BIN/v-add-dns-record $user $domain $record TXT "$slct"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
63
func/remote.sh
Normal file
63
func/remote.sh
Normal file
|
@ -0,0 +1,63 @@
|
|||
send_api_cmd() {
|
||||
if [ -z $PORT ]; then
|
||||
PORT=8083
|
||||
fi
|
||||
if [ -z $USER ]; then
|
||||
USER=admin
|
||||
fi
|
||||
|
||||
auth="user=$USER&password=$PASSWORD&returncode=yes"
|
||||
cmd="cmd=$1"
|
||||
args="arg1=$2&arg2=$3&arg3=$4&arg4=$5&arg5=$6&arg6=$7&arg7=$8&arg8=$9"
|
||||
answer=$(curl -s -k --data "$auth&$cmd&$args" https://$HOST:$PORT/api/)
|
||||
if [ "$answer" != '0' ]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
send_ssh_cmd() {
|
||||
if [ -z $PORT ]; then
|
||||
PORT=22
|
||||
fi
|
||||
if [ -z $USER ]; then
|
||||
USER=admin
|
||||
fi
|
||||
if [ -z "$IDENTITY_FILE" ] && [ "$USER" = 'root' ]; then
|
||||
IDENTITY_FILE="/root/.ssh/id_rsa"
|
||||
fi
|
||||
if [ -z "$IDENTITY_FILE" ]; then
|
||||
IDENTITY_FILE="/home/$USER/.ssh/id_rsa"
|
||||
fi
|
||||
|
||||
if [ "$USER" = 'root' ]; then
|
||||
args="$VESTA/bin/$1 \"$2\" \"$3\" \"$4\" \"$5\""
|
||||
else
|
||||
args="sudo $VESTA/bin/$1 \"$2\" \"$3\" \"$4\" \"$5\""
|
||||
fi
|
||||
ssh -i $IDENTITY_FILE $USER@$HOST -p $PORT "$args" > /dev/null 2>&1
|
||||
if [ "$?" -ne '0' ]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
scp_cmd() {
|
||||
if [ -z $PORT ]; then
|
||||
PORT=22
|
||||
fi
|
||||
if [ -z $USER ]; then
|
||||
USER=admin
|
||||
fi
|
||||
if [ -z "$IDENTITY_FILE" ]; then
|
||||
IDENTITY_FILE="/home/admin/.ssh/id_rsa"
|
||||
fi
|
||||
scp -P $PORT -i $IDENTITY_FILE $1 $USER@$HOST:$2 > /dev/null 2>&1
|
||||
if [ "$?" -ne '0' ]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
|
@ -105,7 +105,7 @@ if (!empty($_POST['ok_rec'])) {
|
|||
$_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
|
||||
} else {
|
||||
// Add DNS Record
|
||||
exec (VESTA_CMD."v-add-dns-domain-record ".$user." ".$v_domain." ".$v_rec." ".$v_type." ".$v_val." ".$v_priority, $output, $return_var);
|
||||
exec (VESTA_CMD."v-add-dns-record ".$user." ".$v_domain." ".$v_rec." ".$v_type." ".$v_val." ".$v_priority, $output, $return_var);
|
||||
$v_type = $_POST['v_type'];
|
||||
if ($return_var != 0) {
|
||||
$error = implode('<br>', $output);
|
||||
|
|
|
@ -23,11 +23,11 @@ if ($_SESSION['user'] == 'admin') {
|
|||
}
|
||||
} else {
|
||||
switch ($action) {
|
||||
case 'delete': $cmd='v-delete-dns-domain-record';
|
||||
case 'delete': $cmd='v-delete-dns-record';
|
||||
break;
|
||||
case 'suspend': $cmd='v-suspend-dns-domain-record';
|
||||
case 'suspend': $cmd='v-suspend-dns-record';
|
||||
break;
|
||||
case 'unsuspend': $cmd='v-unsuspend-dns-domain-record';
|
||||
case 'unsuspend': $cmd='v-unsuspend-dns-record';
|
||||
break;
|
||||
default: header("Location: /list/dns/?domain=".$domain); exit;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ if ($_SESSION['user'] == 'admin') {
|
|||
}
|
||||
} else {
|
||||
switch ($action) {
|
||||
case 'delete': $cmd='v-delete-dns-domain-record';
|
||||
case 'delete': $cmd='v-delete-dns-record';
|
||||
break;
|
||||
default: header("Location: /list/dns/?domain=".$domain); exit;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
|||
$v_username = escapeshellarg($user);
|
||||
$v_domain = escapeshellarg($_GET['domain']);
|
||||
$v_record_id = escapeshellarg($_GET['record_id']);
|
||||
exec (VESTA_CMD."v-delete-dns-domain-record ".$v_username." ".$v_domain." ".$v_record_id, $output, $return_var);
|
||||
exec (VESTA_CMD."v-delete-dns-record ".$v_username." ".$v_domain." ".$v_record_id, $output, $return_var);
|
||||
if ($return_var != 0) {
|
||||
$error = implode('<br>', $output);
|
||||
if (empty($error)) $error = __('Error: vesta did not return any output.');
|
||||
|
|
|
@ -152,7 +152,7 @@ if ((!empty($_GET['domain'])) && (empty($_GET['record_id']))) {
|
|||
} else {
|
||||
$v_domain = escapeshellarg($_GET['domain']);
|
||||
$v_record_id = escapeshellarg($_GET['record_id']);
|
||||
exec (VESTA_CMD."v-list-dns-domain-records ".$user." ".$v_domain." 'json'", $output, $return_var);
|
||||
exec (VESTA_CMD."v-list-dns-records ".$user." ".$v_domain." 'json'", $output, $return_var);
|
||||
if ($return_var != 0) {
|
||||
$error = implode('<br>', $output);
|
||||
if (empty($error)) $error = __('Error code:',$return_var);
|
||||
|
@ -184,7 +184,7 @@ if ((!empty($_GET['domain'])) && (empty($_GET['record_id']))) {
|
|||
if (($v_val != $_POST['v_val']) || ($v_priority != $_POST['v_priority']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_val = escapeshellarg($_POST['v_val']);
|
||||
$v_priority = escapeshellarg($_POST['v_priority']);
|
||||
exec (VESTA_CMD."v-change-dns-domain-record ".$v_username." ".$v_domain." ".$v_record_id." ".$v_val." ".$v_priority, $output, $return_var);
|
||||
exec (VESTA_CMD."v-change-dns-record ".$v_username." ".$v_domain." ".$v_record_id." ".$v_val." ".$v_priority, $output, $return_var);
|
||||
if ($return_var != 0) {
|
||||
$error = implode('<br>', $output);
|
||||
if (empty($error)) $error = __('Error code:',$return_var);
|
||||
|
@ -198,7 +198,7 @@ if ((!empty($_GET['domain'])) && (empty($_GET['record_id']))) {
|
|||
|
||||
if (($_GET['record_id'] != $_POST['v_record_id']) && (empty($_SESSION['error_msg']))) {
|
||||
$v_old_record_id = escapeshellarg($_GET['record_id']);
|
||||
exec (VESTA_CMD."v-change-dns-domain-record-id ".$v_username." ".$v_domain." ".$v_old_record_id." ".$v_record_id, $output, $return_var);
|
||||
exec (VESTA_CMD."v-change-dns-record-id ".$v_username." ".$v_domain." ".$v_old_record_id." ".$v_record_id, $output, $return_var);
|
||||
if ($return_var != 0) {
|
||||
$error = implode('<br>', $output);
|
||||
if (empty($error)) $error = __('Error code:',$return_var);
|
||||
|
|
|
@ -23,7 +23,7 @@ if (empty($_GET['domain'])){
|
|||
include($_SERVER['DOCUMENT_ROOT'].'/templates/user/list_dns.html');
|
||||
}
|
||||
} else {
|
||||
exec (VESTA_CMD."v-list-dns-domain-records '".$user."' '".$_GET['domain']."' 'json'", $output, $return_var);
|
||||
exec (VESTA_CMD."v-list-dns-records '".$user."' '".$_GET['domain']."' 'json'", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
$data = array_reverse($data, true);
|
||||
unset($output);
|
||||
|
|
|
@ -35,7 +35,7 @@ if ($_SESSION['user'] == 'admin') {
|
|||
$v_username = escapeshellarg($user);
|
||||
$v_domain = escapeshellarg($_GET['domain']);
|
||||
$v_record_id = escapeshellarg($_GET['record_id']);
|
||||
exec (VESTA_CMD."v-suspend-dns-domain-record ".$v_username." ".$v_domain." ".$v_record_id, $output, $return_var);
|
||||
exec (VESTA_CMD."v-suspend-dns-record ".$v_username." ".$v_domain." ".$v_record_id, $output, $return_var);
|
||||
if ($return_var != 0) {
|
||||
$error = implode('<br>', $output);
|
||||
if (empty($error)) $error = __('Error: vesta did not return any output.');
|
||||
|
|
|
@ -46,8 +46,8 @@
|
|||
<tr class="data-row">
|
||||
<td class="data-dotted" style="padding: 0px 10px 0px 0px" width="150">
|
||||
<table class="data-col1">
|
||||
<tr><td style="padding: 18 0 4 18;"><input type="checkbox" class="ch-toggle" name="domain[]" value="<?php echo "$key" ?>" ></td></tr>
|
||||
<tr><td><a class="data-date" title="<?php echo $data[$key]['DATE']." ".$data[$key]['TIME'] ?>"><?php echo strftime("%d %b %Y", strtotime($data[$key]['DATE'])) ?></td></tr>
|
||||
<tr><td style="padding: 18 0 4 18;"><input type="checkbox" class="ch-toggle" name="domain[]" value="<?php echo "$key" ?>" > </td></tr>
|
||||
<tr><td><a class="data-date" title="<?php echo $data[$key]['DATE']." ".$data[$key]['TIME'] ?>"><?php echo strftime("%d %b %Y", strtotime($data[$key]['DATE'])) ?></a></td></tr>
|
||||
<tr><td class="data-<?php echo $status ?>"><b><?php echo __($status) ?></b></td></tr>
|
||||
</table>
|
||||
</td>
|
||||
|
@ -100,10 +100,15 @@
|
|||
<td style="vertical-align:top;" >
|
||||
<table>
|
||||
<tr>
|
||||
<td class="counter-name" style="padding: 2px 0 0 2px;">
|
||||
<td class="counter-name" style="padding: 0 0 0 2px;">
|
||||
<?php echo $data[$key]['IP'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="counter-name" style="padding: 0 0 0 2px;">
|
||||
<?php print $data[$key]['SRC'] ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="vertical-align:top;" width="270">
|
||||
|
|
|
@ -35,7 +35,7 @@ if ($_SESSION['user'] == 'admin') {
|
|||
$v_username = escapeshellarg($user);
|
||||
$v_domain = escapeshellarg($_GET['domain']);
|
||||
$v_record_id = escapeshellarg($_GET['record_id']);
|
||||
exec (VESTA_CMD."v-unsuspend-dns-domain-record ".$v_username." ".$v_domain." ".$v_record_id, $output, $return_var);
|
||||
exec (VESTA_CMD."v-unsuspend-dns-record ".$v_username." ".$v_domain." ".$v_record_id, $output, $return_var);
|
||||
if ($return_var != 0) {
|
||||
$error = implode('<br>', $output);
|
||||
if (empty($error)) $error = __('Error: vesta did not return any output.');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue