mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-02-03 16:43:09 -08:00
83 lines
2.1 KiB
Bash
Executable File
83 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: add web/dns/mail domain
|
|
# options: USER DOMAIN [IP]
|
|
#
|
|
# The function adds web/dns/mail domain to a server.
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument defenition
|
|
user=$1
|
|
domain=$2
|
|
ip=$3
|
|
|
|
# Includes
|
|
source $VESTA/func/main.sh
|
|
source $VESTA/func/ip.sh
|
|
source $VESTA/conf/vesta.conf
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
check_args '2' "$#" 'USER DOMAIN [IP]'
|
|
validate_format 'user' 'domain'
|
|
if [ ! -z "$ip" ]; then
|
|
validate_format 'ip'
|
|
fi
|
|
is_object_valid 'user' 'USER' "$user"
|
|
is_object_unsuspended 'user' 'USER' "$user"
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Get ip if it wasn't defined
|
|
if [ -z "$ip" ]; then
|
|
ip=$(get_user_ip $user)
|
|
if [ -z "$ip" ]; then
|
|
echo "Error: no avaiable IP address"
|
|
log_event "$E_NOTEXIST" "$EVENT"
|
|
exit $E_NOTEXIST
|
|
fi
|
|
fi
|
|
|
|
# Web domain
|
|
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
|
|
$BIN/v-add-web-domain $user $domain $ip
|
|
retun_code=$?
|
|
fi
|
|
|
|
# Proxy support
|
|
if [ ! -z "$PROXY_SYSTEM" ] && [ "$retun_code" -eq 0 ]; then
|
|
$BIN/v-add-web-domain-proxy $user $domain
|
|
fi
|
|
|
|
# DNS domain
|
|
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
|
|
if [ "$retun_code" -eq 0 ]; then
|
|
$BIN/v-add-dns-domain $user $domain $ip
|
|
retun_code=$?
|
|
fi
|
|
fi
|
|
|
|
# Mail domain
|
|
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
|
|
if [ "$retun_code" -eq 0 ]; then
|
|
$BIN/v-add-mail-domain $user $domain
|
|
retun_code=$?
|
|
fi
|
|
fi
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
exit $retun_code
|