#!/bin/bash
# info: update dns templates
# options: [RESTART]
#
# The function for obtaining updated pack of dns templates.


#----------------------------------------------------------#
#                    Variable&Function                     #
#----------------------------------------------------------#

# Argument definition
restart=$1

# Includes
source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf


#----------------------------------------------------------#
#                       Action                             #
#----------------------------------------------------------#

# Get new archive
tmpdir=$(mktemp -d --dry-run)
mkdir $tmpdir
cd $tmpdir
wget http://c.vestacp.com/rhel/7/templates.tar.gz -q
if [ "$?" -ne 0 ]; then
    echo "Error: can't download template.tar.gz"
    log_event "$E_CONNECT" "$ARGUMENTS"
    rm -rf $tmpdir
    exit $E_CONNECT
fi

# Update templates
tar -xzpf templates.tar.gz -C $VESTA/data/ templates/dns


#----------------------------------------------------------#
#                       Vesta                              #
#----------------------------------------------------------#

# Clean tmpdir
rm -rf $tmpdir

exit
