Skip to content

Commit 20acf12

Browse files
Merge branch 'master' of github.com:serghey-rodin/vesta
2 parents af249b5 + c9b2590 commit 20acf12

Some content is hidden

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

53 files changed

+1850
-494
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[Vesta Control Panel](http://vestacp.com/)
22
==================================================
33

4+
[![Join the chat at https://gitter.im/vesta-cp/Lobby](https://badges.gitter.im/vesta-cp/Lobby.svg)](https://gitter.im/vesta-cp/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5+
46
* Vesta is an open source hosting control panel.
57
* Vesta has a clean and focused interface without the clutter.
68
* Vesta has the latest of very innovative technologies.

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-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-deactivate-vesta-license

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# info: deactivate vesta license
33
# options: MODULE LICENSE
44
#
5-
# The function activates and register vesta license
5+
# The function deactivates vesta license
66

77

88
#----------------------------------------------------------#

bin/v-delete-sys-sftp-jail

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# info: delete system sftp jail
33
# options: NONE
44
#
5-
# The script enables sftp jailed environment
5+
# The script disables sftp jailed environment
66

77

88
#----------------------------------------------------------#

bin/v-delete-user-sftp-jail

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# info: delete user sftp jail
33
# options: USER
44
#
5-
# The script enables sftp jailed environment
5+
# The script disables sftp jailed environment for USER
66

77

88
#----------------------------------------------------------#

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

0 commit comments

Comments
 (0)