11#! /bin/bash
22# info: add web/dns/mail domain
3- # options: USER DOMAIN [IP]
3+ # options: USER DOMAIN [IP] [RESTART]
44#
55# The function adds web/dns/mail domain to a server.
66
1313user=$1
1414domain=$2
1515ip=$3
16+ restart=" ${4-yes} "
1617
1718# Includes
1819source $VESTA /func/main.sh
@@ -24,9 +25,9 @@ source $VESTA/conf/vesta.conf
2425# Verifications #
2526# ----------------------------------------------------------#
2627
27- check_args ' 2' " $# " ' USER DOMAIN [IP]'
28+ check_args ' 2' " $# " ' USER DOMAIN [IP] [RESTART] '
2829validate_format ' user' ' domain'
29- if [ ! -z " $ip " ]; then
30+ if [ ! -z " $ip " ] ; then
3031 validate_format ' ip'
3132fi
3233is_object_valid ' user' ' USER' " $user "
5051# Web domain
5152# Do Not restart at this point, will loose connection from API calls
5253if [ ! -z " $WEB_SYSTEM " ] && [ " $WEB_SYSTEM " != ' no' ]; then
53- $BIN /v-add-web-domain $user $domain $ip no
54+ $BIN /v-add-web-domain $user $domain $ip ' no '
5455 return_code=$?
5556fi
5657
5758# Proxy support
5859# Do Not restart at this point, will loose connection from API calls
5960if [ ! -z " $PROXY_SYSTEM " ] && [ " $return_code " -eq 0 ]; then
60- $BIN /v-add-web-domain-proxy $user $domain ' ' ' ' no
61+ extentions=" jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls"
62+ extentions=" $extentions ,exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav"
63+ extentions=" $extentions ,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm"
64+ $BIN /v-add-web-domain-proxy $user $domain ' default' " $extentions " ' no'
6165fi
6266
6367# DNS domain
6468if [ ! -z " $DNS_SYSTEM " ] && [ " $DNS_SYSTEM " != ' no' ]; then
6569 if [ " $return_code " -eq 0 ]; then
66- $BIN /v-add-dns-domain $user $domain $ip
70+ $BIN /v-add-dns-domain $user $domain $ip ' no '
6771 return_code=$?
6872 fi
6973fi
@@ -76,6 +80,13 @@ if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
7680 fi
7781fi
7882
83+ # Restart services
84+ if [ " $restart " != ' no' ] && [ " $return_code " -eq 0 ]; then
85+ $BIN /v-restart-web
86+ $BIN /v-restart-proxy
87+ $BIN /v-restart-dns
88+ fi
89+
7990
8091# ----------------------------------------------------------#
8192# Vesta #
0 commit comments