Skip to content

Commit fd4e68b

Browse files
committed
new improved template scheme
1 parent 14687f1 commit fd4e68b

File tree

96 files changed

+1386
-1416
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1386
-1416
lines changed

bin/v-add-dns-domain

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: add dns domain
3-
# options: USER DOMAIN IP [TEMPLATE] [NS1] [NS2] [NS3] [NS4] [RESTART]
3+
# options: USER DOMAIN IP [NS1] [NS2] [NS3] [NS4] [RESTART]
44
#
55
# The function adds DNS zone with records defined in the template. If the exp
66
# argument isn't stated, the expiration date value will be set to next year.
@@ -20,12 +20,11 @@ domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')
2020
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
2121
domain_idn=$(idn -t --quiet -a "$domain")
2222
ip=$3
23-
template=$4
24-
ns1=$5
25-
ns2=$6
26-
ns3=$7
27-
ns4=$8
28-
restart=$9
23+
ns1=$4
24+
ns2=$5
25+
ns3=$6
26+
ns4=$7
27+
restart=$8
2928

3029
# Includes
3130
source $VESTA/conf/vesta.conf
@@ -37,36 +36,32 @@ source $VESTA/func/domain.sh
3736
# Verifications #
3837
#----------------------------------------------------------#
3938

40-
check_args '3' "$#" 'USER DOMAIN IP [TEMPLATE] [NS1] [NS2] [NS3] [NS4]'
39+
check_args '3' "$#" 'USER DOMAIN IP [NS1] [NS2] [NS3] [NS4]'
4140
validate_format 'user' 'domain' 'ip'
4241
is_system_enabled "$DNS_SYSTEM"
4342
is_object_valid 'user' 'USER' "$user"
4443
is_object_unsuspended 'user' 'USER' "$user"
4544
is_domain_new 'dns'
4645
is_package_full 'DNS_DOMAINS'
47-
if [ ! -z "$template" ]; then
48-
validate_format 'template'
49-
is_dns_template_valid
50-
else
51-
template=$(get_user_value '$TEMPLATE')
52-
is_dns_template_valid
53-
fi
46+
47+
template=$(get_user_value '$DNS_TEMPLATE')
48+
is_dns_template_valid
5449

5550
if [ ! -z "$ns1" ]; then
56-
ns1=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g')
51+
ns1=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g')
5752
validate_format 'ns1'
5853
fi
5954
if [ ! -z "$ns2" ]; then
60-
ns2=$(echo $6 | sed -e 's/\.*$//g' -e 's/^\.*//g')
55+
ns2=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g')
6156
validate_format 'ns2'
6257
fi
6358

6459
if [ ! -z "$ns3" ]; then
65-
ns3=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g')
60+
ns3=$(echo $6 | sed -e 's/\.*$//g' -e 's/^\.*//g')
6661
validate_format 'ns3'
6762
fi
6863
if [ ! -z "$ns4" ]; then
69-
ns4=$(echo $8 | sed -e 's/\.*$//g' -e 's/^\.*//g')
64+
ns4=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g')
7065
validate_format 'ns4'
7166
fi
7267

@@ -75,7 +70,7 @@ fi
7570
# Action #
7671
#----------------------------------------------------------#
7772

78-
# Defining variables
73+
# Defining NS variables
7974
if [ -z $ns2 ]; then
8075
i=1
8176
ns=$(get_user_value '$NS')
@@ -88,7 +83,6 @@ soa="$ns1"
8883
exp=$(date +%F -d "+ 1 year")
8984
ttl=14400
9085

91-
9286
# Adding zone to dns dir
9387
cat $DNSTPL/$template.tpl |\
9488
sed -e "s/%ip%/$ip/g" \

bin/v-add-dns-on-web-alias

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ else
5858
dom=$(echo "$dom_alias" | sed -e "s/^$sub.//" )
5959
if [ ! -e "$USER_DATA/dns/$dom.conf" ]; then
6060
$BIN/v-add-dns-domain \
61-
$user $dom $IP '' '' '' '' '' $restart > /dev/null
61+
$user $dom $IP '' '' '' '' $restart > /dev/null
6262

6363
if [ $? -eq 0 ]; then
6464
$BIN/v-add-dns-domain-record \

bin/v-add-domain

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ fi
5151
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
5252
$BIN/v-add-web-domain $user $domain $ip
5353
retun_code=$?
54-
if [ "$PROXY_SYSTEM" = 'nginx' ] && [ "$retun_code" -eq 0 ]; then
55-
$BIN/v-add-web-domain-nginx $user $domain
56-
fi
54+
fi
55+
56+
# Proxy support
57+
if [ ! -z "$PROXY_SYSTEM" ] && [ "$retun_code" -eq 0 ]; then
58+
$BIN/v-add-web-domain-proxy $user $domain
5759
fi
5860

5961
# DNS domain

bin/v-add-sys-ip

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ip=${1// /}
1919
mask=$2
2020
interface="${3-eth0}"
2121
user="${4-admin}"
22-
ip_status="${5-shared}" # can be dedicated as well
22+
ip_status="${5-shared}" # status can be dedicated
2323
ip_name=$6
2424
nat_ip=$7
2525

@@ -50,27 +50,64 @@ fi
5050
#----------------------------------------------------------#
5151
# Action #
5252
#----------------------------------------------------------#
53-
54-
# Get full interface name
5553
get_ip_iface
56-
57-
# Defining config paths
58-
conf='/etc/httpd/conf.d/vesta.conf'
59-
nconf='/etc/nginx/conf.d/vesta_ip.conf'
60-
iconf='/etc/sysconfig/network-scripts/ifcfg'
61-
rconf='/etc/httpd/conf.d/mod_extract_forwarded.conf'
62-
63-
# Adding ip
64-
/sbin/ifconfig "$iface" "$ip" netmask "$mask"
65-
66-
# Adding startup script
67-
create_ip_startup
54+
sys_ip_check=$(/sbin/ifconfig | grep "addr:$ip ")
55+
if [ -z "$sys_ip_check" ]; then
56+
/sbin/ifconfig "$iface" "$ip" netmask "$mask"
57+
58+
# Adding startup script
59+
sys_ip="# Added by vesta"
60+
sys_ip="$sys_ip\nDEVICE=$iface"
61+
sys_ip="$sys_ip\nBOOTPROTO=static"
62+
sys_ip="$sys_ip\nONBOOT=yes"
63+
sys_ip="$sys_ip\nIPADDR=$ip"
64+
sys_ip="$sys_ip\nNETMASK=$mask"
65+
echo -e $sys_ip > /etc/sysconfig/network-scripts/ifcfg-$iface
66+
fi
6867

6968
# Adding vesta ip
70-
create_vesta_ip
69+
echo "OWNER='$user'
70+
STATUS='$ip_status'
71+
NAME='$ip_name'
72+
U_SYS_USERS=''
73+
U_WEB_DOMAINS='0'
74+
INTERFACE='$interface'
75+
NETMASK='$mask'
76+
NAT='$nat_ip'
77+
TIME='$TIME'
78+
DATE='$DATE'" > $VESTA/data/ips/$ip
79+
chmod 660 $VESTA/data/ips/$ip
80+
81+
# WEB support
82+
web_conf="/etc/$WEB_SYSTEM/conf.d/vesta.conf"
83+
if [ "$WEB_SYSTEM" = 'httpd' ]; then
84+
conf_ins='1'
85+
conf_line=$(grep -n NameVirtual $web_conf | tail -n1 | cut -f1 -d:)
86+
if [ ! -z "$conf_line" ]; then
87+
conf_ins=$((conf_line + 1))
88+
fi
89+
if [ "$WEB_SSL" = 'mod_ssl' ]; then
90+
sed -i "$conf_ins i NameVirtualHost $ip:$WEB_SSL_PORT" $web_conf
91+
sed -i "$conf_ins i Listen $ip:$WEB_SSL_PORT" $web_conf
92+
fi
93+
sed -i "$conf_ins i NameVirtualHost $ip:$WEB_PORT" $web_conf
94+
sed -i "$conf_ins i Listen $ip:$WEB_PORT" $web_conf
95+
fi
7196

72-
# Namehosting support
73-
namehost_ip_support
97+
# Proxy support
98+
if [ ! -z "$PROXY_SYSTEM" ]; then
99+
cat $WEBTPL/$PROXY_SYSTEM/proxy_ip.tpl |\
100+
sed -e "s/%ip%/$ip/g" \
101+
-e "s/%web_port%/$WEB_PORT/g" \
102+
-e "s/%proxy_port%/$PROXY_PORT/g" \
103+
> /etc/$PROXY_SYSTEM/conf.d/$ip.conf
104+
105+
fw_conf="/etc/$WEB_SYSTEM/conf.d/mod_extract_forwarded.conf"
106+
if [ -e "$fw_conf" ]; then
107+
ips=$(grep 'MEFaccept ' $fw_conf | grep -v '#' | head -n1)
108+
sed -i "s/$ips/$ips $ip/g" $fw_conf
109+
fi
110+
fi
74111

75112

76113
#----------------------------------------------------------#
@@ -93,9 +130,8 @@ else
93130
fi
94131

95132
# Restart web server
96-
if [ "$web_restart" = 'yes' ]; then
97-
$BIN/v-restart-web "$EVENT"
98-
fi
133+
$BIN/v-restart-web
134+
$BIN/v-restart-proxy
99135

100136
# Logging
101137
log_history "added system ip address $ip" '' 'admin'

bin/v-add-web-domain

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: add web domain
3-
# options: USER DOMAIN IP [TEMPLATE] [RESTART]
3+
# options: USER DOMAIN IP [RESTART]
44
#
55
# The function adds virtual host to a server. In cases when a template is
66
# undefined in the script, the template "default" will be used. The alias of
@@ -21,8 +21,7 @@ domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')
2121
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
2222
domain_idn=$(idn -t --quiet -a "$domain")
2323
ip=$3
24-
template=$4
25-
restart=$5
24+
restart=$4
2625

2726
# Includes
2827
source $VESTA/conf/vesta.conf
@@ -35,7 +34,7 @@ source $VESTA/func/ip.sh
3534
# Verifications #
3635
#----------------------------------------------------------#
3736

38-
check_args '3' "$#" 'USER DOMAIN IP [TEMPLATE] [RESTART]'
37+
check_args '3' "$#" 'USER DOMAIN IP [RESTART]'
3938
validate_format 'user' 'domain' 'ip'
4039
is_system_enabled "$WEB_SYSTEM"
4140
is_object_valid 'user' 'USER' "$user"
@@ -44,13 +43,9 @@ is_domain_new 'web'
4443
is_ip_valid
4544
is_ip_avalable
4645
is_package_full 'WEB_DOMAINS'
47-
if [ ! -z "$template" ]; then
48-
validate_format 'template'
49-
is_apache_template_valid
50-
else
51-
template=$(get_user_value '$TEMPLATE')
52-
is_apache_template_valid
53-
fi
46+
47+
template=$(get_user_value '$WEB_TEMPLATE')
48+
is_web_template_valid
5449

5550

5651
#----------------------------------------------------------#
@@ -82,10 +77,10 @@ fi
8277
group="$user"
8378
email="$user@$domain"
8479
docroot="$HOMEDIR/$user/web/$domain/public_html"
85-
conf="$HOMEDIR/$user/conf/web/httpd.conf"
86-
tpl_file="$WEBTPL/apache/$template.tpl"
80+
tpl_file="$WEBTPL/$WEB_SYSTEM/$template.tpl"
81+
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
8782

88-
# Adding domain to the httpd.conf
83+
# Adding web config
8984
add_web_config
9085

9186
# Building directory tree
@@ -99,12 +94,13 @@ mkdir -p $HOMEDIR/$user/web/$domain \
9994
$HOMEDIR/$user/web/$domain/logs
10095

10196
# Adding domain logs
102-
touch /var/log/httpd/domains/$domain.bytes \
103-
/var/log/httpd/domains/$domain.log \
104-
/var/log/httpd/domains/$domain.error.log
97+
touch /var/log/$WEB_SYSTEM/domains/$domain.bytes \
98+
/var/log/$WEB_SYSTEM/domains/$domain.log \
99+
/var/log/$WEB_SYSTEM/domains/$domain.error.log
105100

106101
# Adding symlink for logs
107-
ln -f -s /var/log/httpd/domains/$domain.*log $HOMEDIR/$user/web/$domain/logs/
102+
ln -f -s /var/log/$WEB_SYSTEM/domains/$domain.*log \
103+
$HOMEDIR/$user/web/$domain/logs/
108104

109105
# Adding domain skeleton
110106
if [ -e "$WEBTPL/skel/public_html/" ]; then
@@ -127,11 +123,11 @@ done
127123

128124
# Changing file owner
129125
chown -R $user:$user $HOMEDIR/$user/web/$domain
130-
chown root:$user /var/log/httpd/domains/$domain.*
131-
chown root:apache $conf
126+
chown root:$user /var/log/$WEB_SYSTEM/domains/$domain.*
127+
chown root:$user $conf
132128

133129
# Changing file permissions
134-
chmod 660 $conf
130+
chmod 640 $conf
135131
chmod 551 $HOMEDIR/$user/web/$domain
136132
chmod 751 $HOMEDIR/$user/web/$domain/private
137133
chmod 751 $HOMEDIR/$user/web/$domain/cgi-bin
@@ -143,18 +139,17 @@ chmod -f -R 665 $HOMEDIR/$user/web/$domain/public_html/*
143139
chmod -f -R 665 $HOMEDIR/$user/web/$domain/document_errors/*
144140
chmod 551 $HOMEDIR/$user/web/$domain/stats
145141
chmod 551 $HOMEDIR/$user/web/$domain/logs
146-
chmod 640 /var/log/httpd/domains/$domain.*
142+
chmod 640 /var/log/$WEB_SYSTEM/domains/$domain.*
147143

148144
# Running template trigger
149-
if [ -x $WEBTPL/apache/$template.sh ]; then
150-
$WEBTPL/apache/$template.sh $user $domain $ip $HOMEDIR $docroot
145+
if [ -x $WEBTPL/$WEB_SYSTEM/$template.sh ]; then
146+
$WEBTPL/$WEB_SYSTEM/$template.sh $user $domain $ip $HOMEDIR $docroot
151147
fi
152148

153-
# Checking main vesta httpd config
154-
main_conf='/etc/httpd/conf.d/vesta.conf'
155-
main_conf_check=$(grep "$conf" $main_conf )
156-
if [ -z "$main_conf_check" ]; then
157-
echo "Include $conf" >>$main_conf
149+
# Checking web config
150+
web_conf="/etc/$WEB_SYSTEM/conf.d/vesta.conf"
151+
if [ -z "$(grep $conf $web_conf)" ]; then
152+
echo "Include $conf" >> $web_conf
158153
fi
159154

160155

@@ -170,7 +165,7 @@ increase_user_value "$user" '$U_WEB_ALIASES'
170165
# Defining domain variables
171166
str="DOMAIN='$domain' IP='$IP' IP6='' ALIAS='$aliases' TPL='$template'"
172167
str="$str SSL='no' SSL_HOME='same' FTP_USER='' FTP_MD5=''"
173-
str="$str NGINX='' NGINX_EXT='' STATS='' STATS_USER=''"
168+
str="$str PROXY='' PROXY_EXT='' STATS='' STATS_USER=''"
174169
str="$str STATS_CRYPT='' U_DISK='0' U_BANDWIDTH='0' SUSPENDED='no'"
175170
str="$str TIME='$TIME' DATE='$DATE'"
176171

@@ -180,7 +175,7 @@ chmod 660 $USER_DATA/web.conf
180175

181176
# Restart web server
182177
if [ "$restart" != 'no' ]; then
183-
$BIN/v-restart-web "$EVENT"
178+
$BIN/v-restart-web
184179
fi
185180

186181
# Logging

0 commit comments

Comments
 (0)