Skip to content

Commit 2d12f47

Browse files
committed
add web domain
1 parent c48a1a9 commit 2d12f47

File tree

18 files changed

+559
-29
lines changed

18 files changed

+559
-29
lines changed

bin/v_add_dns_on_web_alias

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
# info: add dns domain or dns record based on web domain alias
3+
# options: user domain
4+
#
5+
# The function adds dns domain or dns record based on web domain alias.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
user=$1
14+
domain=$(idn -t --quiet -u "$2" )
15+
domain_idn=$(idn -t --quiet -a "$domain")
16+
17+
# Includes
18+
source $VESTA/conf/vesta.conf
19+
source $VESTA/func/main.sh
20+
source $VESTA/func/domain.sh
21+
22+
23+
#----------------------------------------------------------#
24+
# Verifications #
25+
#----------------------------------------------------------#
26+
27+
check_args '2' "$#" 'user domain'
28+
validate_format 'user' 'domain'
29+
is_system_enabled "$WEB_SYSTEM"
30+
is_system_enabled "$DNS_SYSTEM"
31+
is_object_valid 'user' 'USER' "$user"
32+
is_object_unsuspended 'user' 'USER' "$user"
33+
is_object_valid 'web' 'DOMAIN' "$domain"
34+
is_object_unsuspended 'web' 'DOMAIN' "$domain"
35+
36+
37+
#----------------------------------------------------------#
38+
# Action #
39+
#----------------------------------------------------------#
40+
41+
# Parsing domain values
42+
get_domain_values 'web'
43+
44+
OLD_IFS=$IFS
45+
IFS=','
46+
for web_alias in $ALIAS; do
47+
# Check if parent dns domain exist
48+
sub_domain=$(echo $web_alias | cut -f1 -d .)
49+
pr_domain=$(echo $web_alias | sed -e "s/^$sub_domain.//" )
50+
check_parent=$(grep "DOMAIN='$pr_domain'" $USER_DATA/dns.conf)
51+
if [ -z "$check_parent" ]; then
52+
check_dom=$(grep "DOMAIN='$web_alias'" $USER_DATA/dns.conf)
53+
if [ -z "$check_dom" ]; then
54+
$BIN/v_add_dns_domain $user $web_alias $IP
55+
fi
56+
else
57+
check_rec=$(grep "RECORD='$sub_domain'" $USER_DATA/dns/$pr_domain.conf)
58+
if [ -z "$check_rec" ]; then
59+
$BIN/v_add_dns_domain_record $user $pr_domain $sub_domain A $IP
60+
fi
61+
fi
62+
done
63+
64+
65+
#----------------------------------------------------------#
66+
# Vesta #
67+
#----------------------------------------------------------#
68+
69+
# Restart web server
70+
$BIN/v_restart_dns "$EVENT"
71+
72+
# Logging
73+
log_history "$EVENT"
74+
log_event "$OK" "$EVENT"
75+
76+
exit

bin/v_add_web_domain

Lines changed: 6 additions & 3 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]
3+
# options: user domain ip [template] [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,6 +21,7 @@ domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
2121
domain_idn=$(idn -t --quiet -a "$domain")
2222
ip=$3
2323
template=${4-default}
24+
restart=$5
2425

2526
# Includes
2627
source $VESTA/conf/vesta.conf
@@ -33,7 +34,7 @@ source $VESTA/func/ip.sh
3334
# Verifications #
3435
#----------------------------------------------------------#
3536

36-
check_args '3' "$#" 'user domain ip [template]'
37+
check_args '3' "$#" 'user domain ip [template] [restart]'
3738
validate_format 'user' 'domain' 'ip' 'template'
3839
is_system_enabled "$WEB_SYSTEM"
3940
is_object_valid 'user' 'USER' "$user"
@@ -190,7 +191,9 @@ echo "$str" >> $USER_DATA/web.conf
190191
chmod 660 $USER_DATA/web.conf
191192

192193
# Restart web server
193-
$BIN/v_restart_web "$EVENT"
194+
if [ "$restart" != 'no' ]; then
195+
$BIN/v_restart_web "$EVENT"
196+
fi
194197

195198
# Logging
196199
log_history "$EVENT"

bin/v_add_web_domain_alias

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: add web domain alias
3-
# options: user domain alias
3+
# options: user domain alias [restart]
44
#
55
# The call is intended for adding aliases to a domain (it is also called
66
# "domain parking"). The function supports wildcards *.domain.tpl.
@@ -18,6 +18,7 @@ domain_idn=$(idn -t --quiet -a "$domain")
1818
dom_alias=$(idn -t --quiet -u "$3" )
1919
dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]')
2020
dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
21+
restart="$4"
2122

2223
# Includes
2324
source $VESTA/conf/vesta.conf
@@ -29,7 +30,7 @@ source $VESTA/func/domain.sh
2930
# Verifications #
3031
#----------------------------------------------------------#
3132

32-
check_args '3' "$#" 'user domain dom_alias'
33+
check_args '3' "$#" 'user domain dom_alias [restart]'
3334
validate_format 'user' 'domain' 'dom_alias'
3435
is_system_enabled "$WEB_SYSTEM"
3536
is_object_valid 'user' 'USER' "$user"
@@ -98,7 +99,9 @@ update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS"
9899
increase_user_value "$user" '$U_WEB_ALIASES'
99100

100101
# Adding task to the vesta pipe
101-
$BIN/v_restart_web "$EVENT"
102+
if [ "$restart" != 'no' ]; then
103+
$BIN/v_restart_web "$EVENT"
104+
fi
102105

103106
log_history "$EVENT"
104107
log_event "$OK" "$EVENT"

bin/v_add_web_domain_elog

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: add error logging for domain
3-
# options: user domain
3+
# options: user domain [restart]
44
#
55
# The function enables a separate ErrorLog file for a domain, accessible for
66
# reading by users.
@@ -14,6 +14,7 @@
1414
user=$1
1515
domain=$(idn -t --quiet -u "$2" )
1616
domain_idn=$(idn -t --quiet -a "$domain")
17+
restart="$3"
1718

1819
# Includes
1920
source $VESTA/conf/vesta.conf
@@ -25,14 +26,13 @@ source $VESTA/func/domain.sh
2526
# Verifications #
2627
#----------------------------------------------------------#
2728

28-
check_args '2' "$#" 'user domain'
29+
check_args '2' "$#" 'user domain [restart]'
2930
validate_format 'user' 'domain'
3031
is_system_enabled "$WEB_SYSTEM"
3132
is_object_valid 'user' 'USER' "$user"
3233
is_object_unsuspended 'user' 'USER' "$user"
3334
is_object_valid 'web' 'DOMAIN' "$domain"
3435
is_object_unsuspended 'web' 'DOMAIN' "$domain"
35-
is_object_value_empty 'web' 'DOMAIN' "$domain" '$ELOG'
3636

3737

3838
#----------------------------------------------------------#
@@ -41,6 +41,10 @@ is_object_value_empty 'web' 'DOMAIN' "$domain" '$ELOG'
4141

4242
# Parsing domain values
4343
get_domain_values 'web'
44+
if [ $ELOG == 'yes' ]; then
45+
exit 0
46+
fi
47+
4448
tpl_file="$WEBTPL/apache_$TPL.tpl"
4549
conf="$HOMEDIR/$user/conf/web/httpd.conf"
4650
ELOG='yes'
@@ -85,7 +89,9 @@ fi
8589
update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'yes'
8690

8791
# Adding task to the vesta pipe
88-
$BIN/v_restart_web "$EVENT"
92+
if [ "$restart" != 'no' ]; then
93+
$BIN/v_restart_web "$EVENT"
94+
fi
8995

9096
# Logging
9197
log_history "$EVENT"

bin/v_add_web_domain_nginx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: add webdomain nginx support
3-
# options: user domain
3+
# options: user domain [template] [extentions] [restart]
44
#
55
# The function enables nginx support for a domain. It can significantly improve
66
# website speed.
@@ -18,6 +18,7 @@ template=${3-default}
1818
default_extentions="jpg,jpeg,gif,png,ico,css,zip,tgz,gz,rar,bz2,doc,xls,exe,\
1919
pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg,html,htm"
2020
extentions=${4-$default_extentions}
21+
restart="$5"
2122

2223
# Includes
2324
source $VESTA/conf/vesta.conf
@@ -29,7 +30,7 @@ source $VESTA/func/domain.sh
2930
# Verifications #
3031
#----------------------------------------------------------#
3132

32-
check_args '2' "$#" 'user domain [template] [extentions]'
33+
check_args '2' "$#" 'user domain [template] [extentions] [restart]'
3334
validate_format 'user' 'domain' 'template' 'extentions'
3435
is_system_enabled "$PROXY_SYSTEM"
3536
is_object_valid 'user' 'USER' "$user"
@@ -94,7 +95,9 @@ update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' "$NGINX"
9495
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' "$extentions"
9596

9697
# Restart web server
97-
$BIN/v_restart_web "$EVENT"
98+
if [ "$restart" != 'no' ]; then
99+
$BIN/v_restart_web "$EVENT"
100+
fi
98101

99102
log_history "$EVENT"
100103
log_event "$OK" "$EVENT"

bin/v_add_web_domain_ssl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: adding ssl for domain
3-
# options: user domain ssl_dir [ssl_home]
3+
# options: user domain ssl_dir [ssl_home] [restart]
44
#
55
# The function turns on SSL support for a domain. Parameter ssl_dir is a path
66
# to directory where 2 or 3 ssl files can be found. Certificate file
@@ -19,7 +19,8 @@ user=$1
1919
domain=$(idn -t --quiet -u "$2" )
2020
domain_idn=$(idn -t --quiet -a "$domain")
2121
ssl_dir=$3
22-
ssl_home=${4-single}
22+
ssl_home=${4-same}
23+
restart="$5"
2324

2425
# Includes
2526
source $VESTA/conf/vesta.conf
@@ -32,7 +33,7 @@ source $VESTA/func/ip.sh
3233
# Verifications #
3334
#----------------------------------------------------------#
3435

35-
check_args '3' "$#" 'user domain ssl_dir [ssl_home]'
36+
check_args '3' "$#" 'user domain ssl_dir [ssl_home] [restart]'
3637
validate_format 'user' 'domain' 'ssl_dir'
3738
is_system_enabled "$WEB_SYSTEM"
3839
is_object_valid 'user' 'USER' "$user"
@@ -124,7 +125,9 @@ update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME"
124125
update_object_value 'web' 'DOMAIN' "$domain" '$SSL' "yes"
125126

126127
# Restart web server
127-
$BIN/v_restart_web "$EVENT"
128+
if [ "$restart" != 'no' ]; then
129+
$BIN/v_restart_web "$EVENT"
130+
fi
128131

129132
# Logging
130133
log_history "$EVENT"

bin/v_list_web_stats

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
# info: list web statistics
3+
# options: [format]
4+
#
5+
# The function for obtaining the list of system shells.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
format=${1-shell}
14+
15+
# Includes
16+
source $VESTA/func/main.sh
17+
source $VESTA/conf/vesta.conf
18+
19+
# Json function
20+
json_list_st() {
21+
stats=$(echo "${STATS_SYSTEM//,/ } none")
22+
st_counter=$(echo "$stats" | wc -w)
23+
i=1
24+
echo '['
25+
for st in $stats; do
26+
if [ "$i" -lt "$st_counter" ]; then
27+
echo -e "\t\"$st\","
28+
else
29+
echo -e "\t\"$st\""
30+
fi
31+
(( ++i))
32+
done
33+
echo "]"
34+
}
35+
36+
# Shell function
37+
shell_list_st() {
38+
stats=$(echo "none ${STATS_SYSTEM//,/ }")
39+
if [ -z "$nohead" ]; then
40+
echo "STATS"
41+
echo "----------"
42+
fi
43+
for st in $stats; do
44+
echo "$st"
45+
done
46+
}
47+
48+
49+
#----------------------------------------------------------#
50+
# Action #
51+
#----------------------------------------------------------#
52+
53+
# Listing domains
54+
case $format in
55+
json) json_list_st ;;
56+
plain) nohead=1; shell_list_st ;;
57+
shell) shell_list_st ;;
58+
*) check_args '1' '0' '[format]' ;;
59+
esac
60+
61+
62+
#----------------------------------------------------------#
63+
# Vesta #
64+
#----------------------------------------------------------#
65+
66+
exit

web/add/user/index.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
$TAB = 'USER';
77
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
88

9+
if (empty($_SESSION['user'])) {
10+
header("Location: /login/");
11+
}
12+
913
// Header
1014
include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
1115

0 commit comments

Comments
 (0)