Skip to content

Commit 09e1238

Browse files
committed
Merge branch 'master' into feature/800
Conflicts: web/edit/web/index.php
2 parents c85967f + 7eb7a81 commit 09e1238

File tree

542 files changed

+5342
-709
lines changed

Some content is hidden

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

542 files changed

+5342
-709
lines changed

bin/v-add-user

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ fi
7474

7575
if [ ! -z "$MAIL_SYSTEM" ]; then
7676
mkdir $HOMEDIR/$user/conf/mail $HOMEDIR/$user/mail
77-
chmod 751 $HOMEDIR/$user/mail $HOMEDIR/$user/conf/mail
77+
chmod 751 $HOMEDIR/$user/mail
78+
chmod 755 $HOMEDIR/$user/conf/mail
7879
fi
7980

8081
if [ ! -z "$DNS_SYSTEM" ]; then

bin/v-add-web-domain-ftp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,8 @@ is_password_valid
5151
get_domain_values 'web'
5252

5353
# Defining ftp user shell
54-
if [ -z "$FTP_SHELL" ]; then
55-
shell='/sbin/nologin'
56-
if [ -e "/usr/bin/rssh" ]; then
57-
shell='/usr/bin/rssh'
58-
fi
59-
else
54+
shell='/sbin/nologin'
55+
if [ ! -z "$FTP_SHELL" ]; then
6056
shell=$FTP_SHELL
6157
fi
6258

bin/v-add-web-domain-stats-user

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# Argument definition
1313
user=$1
14-
domain=$(idn -t --quiet -u "$2" )
14+
domain=$2
1515
stats_user=$3
1616
password=$4; HIDE=4
1717

@@ -43,23 +43,29 @@ is_password_valid
4343
stats_dir="$HOMEDIR/$user/web/$domain/stats"
4444

4545
# Adding htaccess file
46-
echo "AuthUserFile $stats_dir/.htpasswd
47-
AuthName \"Web Statistics\"
48-
AuthType Basic
49-
Require valid-user" > $stats_dir/.htaccess
46+
if [ "$WEB_SYSTEM" = 'nginx' ]; then
47+
echo "auth_basic \"Web Statistics\";" > $stats_dir/auth.conf
48+
echo "auth_basic_user_file $stats_dir/.htpasswd;" >> $stats_dir/auth.conf
49+
else
50+
echo "AuthUserFile $stats_dir/.htpasswd" > $stats_dir/.htaccess
51+
echo "AuthName \"Web Statistics\"" >> $stats_dir/.htaccess
52+
echo "AuthType Basic" >> $stats_dir/.htaccess
53+
echo "Require valid-user" >> $stats_dir/.htaccess
54+
fi
5055

5156
# Generating htaccess user and password
52-
rm -f $stats_dir/.htpasswd
53-
htpasswd -bc $stats_dir/.htpasswd "$stats_user" "$password" &>/dev/null
54-
stats_crypt=$(grep $stats_user: $stats_dir/.htpasswd |cut -f 2 -d :)
57+
salt=$(generate_password "$PW_MATRIX" "8")
58+
stats_pass=$($BIN/v-generate-password-hash md5 $salt $password)
59+
echo "$stats_user:$stats_pass" > $stats_dir/.htpasswd
60+
5561

5662
#----------------------------------------------------------#
5763
# Vesta #
5864
#----------------------------------------------------------#
5965

6066
# Adding stats user in config
6167
update_object_value 'web' 'DOMAIN' "$domain" '$STATS_USER' "$stats_user"
62-
update_object_value 'web' 'DOMAIN' "$domain" '$STATS_CRYPT' "$stats_crypt"
68+
update_object_value 'web' 'DOMAIN' "$domain" '$STATS_CRYPT' "$stats_pass"
6369

6470
# Logging
6571
log_history "added password protection for web stats on $domain"

bin/v-backup-user

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,46 @@ sftp_backup() {
747747
fi
748748
}
749749

750+
google_backup() {
751+
752+
# Defining google settings
753+
source $VESTA/conf/google.backup.conf
754+
gsutil="$VESTA/3rdparty/gsutil/gsutil"
755+
export BOTO_CONFIG="$VESTA/conf/.google.backup.boto"
756+
757+
# Debug info
758+
echo -e "$(date "+%F %T") Remote: gs://$BUCKET/$BPATH/$user.$date.tar"
759+
760+
# Checking retention
761+
backup_list=$(${gsutil} ls gs://$BUCKET/$BPATH/$user.* 2>/dev/null)
762+
backups_count=$(echo "$backup_list" |wc -l)
763+
if [ "$backups_count" -ge "$BACKUPS" ]; then
764+
backups_rm_number=$((backups_count - BACKUPS + 1))
765+
for backup in $(echo "$backup_list" |head -n $backups_rm_number); do
766+
echo -e "$(date "+%F %T") Roated gcp backup: $backup"
767+
$gsutil rm $backup > /dev/null 2>&1
768+
done
769+
fi
770+
771+
# Uploading backup archive
772+
echo -e "$(date "+%F %T") Uploading $user.$date.tar ..."
773+
if [ "$localbackup" = 'yes' ]; then
774+
cd $BACKUP
775+
${gsutil} cp $user.$date.tar gs://$BUCKET/$BPATH/ > /dev/null 2>&1
776+
else
777+
cd $tmpdir
778+
tar -cf $BACKUP/$user.$date.tar .
779+
cd $BACKUP/
780+
${gsutil} cp $user.$date.tar gs://$BUCKET/$BPATH/ > /dev/null 2>&1
781+
rc=$?
782+
rm -f $user.$date.tar
783+
if [ "$rc" -ne 0 ]; then
784+
check_result "$E_CONNECT" "gsutil failed to upload $user.$date.tar"
785+
fi
786+
fi
787+
}
788+
789+
750790
echo -e "\n-- SUMMARY --" |tee -a $BACKUP/$user.log
751791

752792
# Switching on backup system types
@@ -755,6 +795,7 @@ for backup_type in $(echo -e "${BACKUP_SYSTEM//,/\\n}"); do
755795
local) local_backup ;;
756796
ftp) ftp_backup ;;
757797
sftp) sftp_backup ;;
798+
google) google_backup ;;
758799
esac
759800
done
760801

bin/v-change-domain-owner

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ check_args '2' "$#" 'DOMAIN USER'
2727
is_format_valid 'domain' 'user'
2828
is_object_valid 'user' 'USER' "$user"
2929
is_object_unsuspended 'user' 'USER' "$user"
30-
owner=$(v-search-domain-owner $domain)
30+
owner=$($BIN/v-search-domain-owner $domain)
3131
if [ -z "$owner" ]; then
3232
check_result $E_NOTEXIST "domain $domain doesn't exist"
3333
fi

bin/v-change-sys-vesta-ssl

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
# info: change vesta ssl certificate
3+
# options: SSL_DIR [RESTART]
4+
#
5+
# The function changes vesta SSL certificate and the key.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument definition
13+
domain='certificate'
14+
ssl_dir=$1
15+
restart=$2
16+
17+
# Includes
18+
source $VESTA/func/main.sh
19+
source $VESTA/func/domain.sh
20+
source $VESTA/conf/vesta.conf
21+
22+
23+
#----------------------------------------------------------#
24+
# Verifications #
25+
#----------------------------------------------------------#
26+
27+
check_args '1' "$#" 'SSL_DIR [RESTART]'
28+
is_format_valid 'ssl_dir'
29+
30+
31+
#----------------------------------------------------------#
32+
# Action #
33+
#----------------------------------------------------------#
34+
35+
# Checking new certificate
36+
certificate=$(cat $ssl_dir/$domain.crt |grep -n END)
37+
certificate_count=$(echo "$certificate" |wc -l)
38+
if [ "$certificate_count" -gt 1 ]; then
39+
crt_end=$(echo "$certificate" |head -n1 |cut -f 1 -d :)
40+
crt_lines=$(wc -l $ssl_dir/$domain.crt |cut -f1 -d ' ')
41+
pem_begin=$((crt_lines - crt_end))
42+
mv $ssl_dir/$domain.crt $ssl_dir/$domain.crt_full
43+
head -n $crt_end $ssl_dir/$domain.crt_full > $ssl_dir/$domain.crt
44+
tail -n $pem_begin $ssl_dir/$domain.crt_full > $ssl_dir/$domain.ca
45+
is_web_domain_cert_valid
46+
mv -f $ssl_dir/$domain.crt_full $ssl_dir/$domain.crt
47+
rm -f $ssl_dir/$domain.ca
48+
else
49+
is_web_domain_cert_valid
50+
fi
51+
52+
# Moving old certificate
53+
mv $VESTA/ssl/certificate.crt $VESTA/ssl/certificate.crt.back
54+
mv $VESTA/ssl/certificate.key $VESTA/ssl/certificate.key.back
55+
56+
# Adding new certificate
57+
cp -f $ssl_dir/certificate.crt $VESTA/ssl/certificate.crt
58+
cp -f $ssl_dir/certificate.key $VESTA/ssl/certificate.key
59+
60+
61+
#----------------------------------------------------------#
62+
# Vesta #
63+
#----------------------------------------------------------#
64+
65+
# Restarting web server
66+
if [ "$restart" != 'no' ]; then
67+
kill -HUP $(cat /var/run/vesta-nginx.pid)
68+
$BIN/v-restart-mail
69+
if [ ! -z "$IMAP_SYSTEM" ]; then
70+
v-restart-service "$IMAP_SYSTEM"
71+
fi
72+
fi
73+
74+
# Logging
75+
log_event "$OK" "$ARGUMENTS"
76+
77+
exit

bin/v-list-sys-services

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ get_srv_state() {
9999

100100
# Calculating memory usage
101101
mem=$(echo "$pids" |awk '{sum += $3} END {print sum/1024 }')
102-
mem=$(printf "%.0f\n" $mem)
102+
mem=$(echo "${mem%%.*}")
103103

104104
# Searching pid file
105105
pid_file=''

bin/v-list-sys-vesta-ssl

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#!/bin/bash
2+
# info: list vesta ssl certificate
3+
# options: [FORMAT]
4+
#
5+
# The function of obtaining vesta ssl files.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument definition
13+
format=${1-shell}
14+
15+
# Includes
16+
source $VESTA/func/main.sh
17+
18+
# JSON list function
19+
json_list() {
20+
echo '{'
21+
echo -e "\t\"VESTA\": {"
22+
echo " \"CRT\": \"$crt\","
23+
echo " \"KEY\": \"$key\","
24+
echo " \"CA\": \"$ca\","
25+
echo " \"SUBJECT\": \"$subj\","
26+
echo " \"ALIASES\": \"$alt_dns\","
27+
echo " \"NOT_BEFORE\": \"$before\","
28+
echo " \"NOT_AFTER\": \"$after\","
29+
echo " \"SIGNATURE\": \"$signature\","
30+
echo " \"PUB_KEY\": \"$pub_key\","
31+
echo " \"ISSUER\": \"$issuer\""
32+
echo -e "\t}\n}"
33+
}
34+
35+
# SHELL list function
36+
shell_list() {
37+
if [ ! -z "$crt" ]; then
38+
echo -e "$crt"
39+
fi
40+
if [ ! -z "$key" ]; then
41+
echo -e "\n$key"
42+
fi
43+
if [ ! -z "$crt" ]; then
44+
echo
45+
echo
46+
echo "SUBJECT: $subj"
47+
if [ ! -z "$alt_dns" ]; then
48+
echo "ALIASES: ${alt_dns//,/ }"
49+
fi
50+
echo "VALID FROM: $before"
51+
echo "VALID TIL: $after"
52+
echo "SIGNATURE: $signature"
53+
echo "PUB_KEY: $pub_key"
54+
echo "ISSUER: $issuer"
55+
fi
56+
}
57+
58+
# PLAIN list function
59+
plain_list() {
60+
if [ ! -z "$crt" ]; then
61+
echo -e "$crt"
62+
fi
63+
if [ ! -z "$key" ]; then
64+
echo -e "\n$key"
65+
fi
66+
if [ ! -z "$ca" ]; then
67+
echo -e "\n$ca"
68+
fi
69+
if [ ! -z "$crt" ]; then
70+
echo "$subj"
71+
echo "${alt_dns//,/ }"
72+
echo "$before"
73+
echo "$after"
74+
echo "$signature"
75+
echo "$pub_key"
76+
echo "$issuer"
77+
fi
78+
79+
}
80+
81+
# CSV list function
82+
csv_list() {
83+
echo -n "CRT,KEY,CA,SUBJECT,ALIASES,NOT_BEFORE,NOT_AFTER,SIGNATURE,"
84+
echo "PUB_KEY,ISSUER"
85+
echo -n "\"$crt\",\"$key\",\"$ca\",\"$subj\",\"${alt_dns//,/ }\","
86+
echo "\"$before\",\"$after\",\"$signature\",\"$pub_key\",\"$issuer\""
87+
}
88+
89+
90+
#----------------------------------------------------------#
91+
# Verifications #
92+
#----------------------------------------------------------#
93+
94+
95+
96+
#----------------------------------------------------------#
97+
# Action #
98+
#----------------------------------------------------------#
99+
100+
# Parsing SSL certificate
101+
crt=$(cat $VESTA/ssl/certificate.crt |sed ':a;N;$!ba;s/\n/\\n/g')
102+
key=$(cat $VESTA/ssl/certificate.crt |sed ':a;N;$!ba;s/\n/\\n/g')
103+
104+
# Parsing SSL certificate details without CA
105+
info=$(openssl x509 -text -in $VESTA/ssl/certificate.crt)
106+
subj=$(echo "$info" |grep Subject: |cut -f 2 -d =)
107+
before=$(echo "$info" |grep Before: |sed -e "s/.*Before: //")
108+
after=$(echo "$info" |grep "After :" |sed -e "s/.*After : //")
109+
signature=$(echo "$info" |grep "Algorithm:" |head -n1 )
110+
signature=$(echo "$signature"| sed -e "s/.*Algorithm: //")
111+
pub_key=$(echo "$info" |grep Public-Key: |cut -f2 -d \( | tr -d \))
112+
issuer=$(echo "$info" |grep Issuer: |sed -e "s/.*Issuer: //")
113+
alt_dns=$(echo "$info" |grep DNS |sed -e 's/DNS:/\n/g' |tr -d ',')
114+
alt_dns=$(echo "$alt_dns" |tr -d ' ' |sed -e "/^$/d")
115+
alt_dns=$(echo "$alt_dns" |sed -e ':a;N;$!ba;s/\n/,/g')
116+
117+
# Listing data
118+
case $format in
119+
json) json_list ;;
120+
plain) plain_list ;;
121+
csv) csv_list ;;
122+
shell) shell_list ;;
123+
esac
124+
125+
126+
#----------------------------------------------------------#
127+
# Vesta #
128+
#----------------------------------------------------------#
129+
130+
exit

bin/v-rebuild-web-domains

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# info: rebuild dns domains
2+
# info: rebuild web domains
33
# options: USER [RESTART]
44
#
55
# The function rebuilds web configuration files.

0 commit comments

Comments
 (0)