replaced underscore with dash in api syscalls

This commit is contained in:
Serghey Rodin 2012-11-09 18:26:32 +02:00
commit b6b7eacadb
283 changed files with 438 additions and 412 deletions

128
bin/v-rebuild-dns-domains Executable file
View file

@ -0,0 +1,128 @@
#!/bin/bash
# info: rebuild dns domains
# options: user [restart]
#
# The function rebuilds BIND configuration files for all dns domains.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
restart=$2
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '1' "$#" 'user [restart]'
validate_format 'user'
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
user_domains=0
user_records=0
suspended_dns=0
# Checking dns folder
if [ ! -d "$USER_DATA/dns" ]; then
rm -f $USER_DATA/dns
mkdir $USER_DATA/dns
fi
# Defining config and fie
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
# Starting loop
for domain in $(search_objects 'dns' 'DOMAIN' "*" 'DOMAIN'); do
# Defining variables
get_domain_values 'dns'
domain_idn=$(idn -t --quiet -a "$domain")
# Checking zone file
if [ ! -e "$USER_DATA/dns/$domain.conf" ]; then
cat $DNSTPL/$TPL.tpl |\
sed -e "s/%ip%/$IP/g" \
-e "s/%domain_idn%/$domain_idn/g" \
-e "s/%domain%/$domain/g" \
-e "s/%ns1%/$ns1/g" \
-e "s/%ns2%/$ns2/g" \
-e "s/%ns3%/$ns3/g" \
-e "s/%ns4%/$ns4/g" \
-e "s/%time%/$TIME/g" \
-e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf
fi
# Sorting records
sort_dns_records
# Updating zone
update_domain_zone
# Set file permissions
chmod 640 $HOMEDIR/$user/conf/dns/$domain.db
chown root:named $HOMEDIR/$user/conf/dns/$domain.db
# Bind config check
nconf='/etc/named.conf'
if [ "$SUSPENDED" = 'yes' ]; then
rm_string=$(grep -n /etc/namedb/$domain.db $nconf | cut -d : -f 1)
if [ ! -z "$rm_string" ]; then
sed -i "$rm_string d" $nconf
fi
suspended_dns=$((suspended_dns + 1))
else
if [ -z "$(grep /$domain.db $nconf)" ]; then
named="zone \"$domain_idn\" {type master; file"
named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};"
echo "$named" >> /etc/named.conf
fi
fi
user_domains=$((user_domains + 1))
records=$(wc -l $USER_DATA/dns/$domain.conf | cut -f 1 -d ' ')
user_records=$((user_records + records))
update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
done
#----------------------------------------------------------#
# 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