forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv-add-domain
More file actions
executable file
·88 lines (71 loc) · 2.36 KB
/
Copy pathv-add-domain
File metadata and controls
executable file
·88 lines (71 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
# info: add web/dns/mail domain
# options: USER DOMAIN [IP] [RESTART]
#
# The function adds web/dns/mail domain to a server.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument definition
user=$1
domain=$2
ip=$3
restart="${4-yes}"
# Includes
source $VESTA/func/main.sh
source $VESTA/func/ip.sh
source $VESTA/conf/vesta.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'USER DOMAIN [IP] [RESTART]'
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" ]; then
$BIN/v-add-web-domain $user $domain $ip 'no'
return_code=$?
fi
# Proxy support
if [ ! -z "$PROXY_SYSTEM" ] && [ "$return_code" -eq 0 ]; then
extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls"
extentions="$extentions,exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav"
extentions="$extentions,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm"
$BIN/v-add-web-domain-proxy $user $domain 'default' "$extentions" 'no'
fi
# DNS domain
if [ ! -z "$DNS_SYSTEM" ] && [ "$return_code" -eq 0 ]; then
$BIN/v-add-dns-domain $user $domain $ip 'no'
return_code=$?
fi
# Mail domain
if [ ! -z "$MAIL_SYSTEM" ] && [ "$return_code" -eq 0 ]; then
$BIN/v-add-mail-domain $user $domain
return_code=$?
fi
# Restart services
if [ "$restart" != 'no' ] && [ "$return_code" -eq 0 ]; then
$BIN/v-restart-web
$BIN/v-restart-proxy
$BIN/v-restart-dns
fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
exit $return_code