1
0
mirror of https://github.com/serghey-rodin/vesta.git synced 2025-03-12 04:36:25 -07:00
vesta/bin/v-add-domain

82 lines
2.1 KiB
Plaintext
Raw Normal View History

2013-02-19 17:47:10 +02:00
#!/bin/bash
# info: add web/dns/mail domain
# options: USER DOMAIN [IP] [RESTART]
2013-02-19 17:47:10 +02:00
#
# The function adds web/dns/mail domain to a server.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument definition
2013-02-19 17:47:10 +02:00
user=$1
domain=$2
ip=$3
restart="${4-yes}"
2013-02-19 17:47:10 +02:00
# Includes
source $VESTA/func/main.sh
source $VESTA/func/ip.sh
source $VESTA/conf/vesta.conf
2013-02-19 17:47:10 +02:00
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'USER DOMAIN [IP] [RESTART]'
is_format_valid 'user' 'domain'
if [ ! -z "$ip" ] ; then
is_format_valid 'ip'
2013-02-19 17:47:10 +02:00
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
2016-06-25 11:08:19 +03:00
get_user_ip
2013-02-19 17:47:10 +02:00
if [ -z "$ip" ]; then
check_result $E_NOTEXIST "no avaiable IP address"
2013-02-19 17:47:10 +02:00
fi
fi
2015-10-21 15:55:07 +03:00
# Working on web domain
2014-10-07 00:24:49 +03:00
if [ ! -z "$WEB_SYSTEM" ]; then
$BIN/v-add-web-domain $user $domain $ip 'no'
2015-10-21 15:55:07 +03:00
check_result $? "can't add web domain" >/dev/null
2013-05-10 11:04:40 +03:00
fi
2015-10-21 15:55:07 +03:00
# Working on DNS domain
if [ ! -z "$DNS_SYSTEM" ]; then
2016-06-28 02:26:07 +03:00
$BIN/v-add-dns-domain $user $domain $ip "" "" "" "" "" '' '' '' 'no'
2015-10-21 15:55:07 +03:00
check_result $? "can't add dns domain" >/dev/null
2013-02-19 17:47:10 +02:00
fi
2015-10-21 15:55:07 +03:00
# Working on mail domain
if [ ! -z "$MAIL_SYSTEM" ]; then
2014-10-07 00:24:49 +03:00
$BIN/v-add-mail-domain $user $domain
2015-10-21 15:55:07 +03:00
check_result $? "can't add mail domain" >/dev/null
2013-02-19 17:47:10 +02:00
fi
2015-10-21 15:55:07 +03:00
# Restarting services
$BIN/v-restart-web $restart
check_result $? "can't restart web" > /dev/null
$BIN/v-restart-proxy $restart
check_result $? "can't restart proxy" > /dev/null
$BIN/v-restart-dns $restart
check_result $? "can't restart dns" > /dev/null
2013-02-19 17:47:10 +02:00
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
2015-10-21 15:55:07 +03:00
exit