Skip to content

Commit c58a200

Browse files
committed
Merge remote-tracking branch 'refs/remotes/serghey-rodin/master'
2 parents e314999 + a16af0e commit c58a200

File tree

184 files changed

+1670
-799
lines changed

Some content is hidden

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

184 files changed

+1670
-799
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.tar
2+
*.zip
3+
*.gzip
File renamed without changes.

bin/v-activate-vesta-license

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
# info: activate vesta license
3+
# options: MODULE LICENSE
4+
#
5+
# The function activates and register vesta license
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
module=$(echo $1 | tr '[:lower:]' '[:upper:]')
14+
license=$2
15+
16+
# Importing system enviroment
17+
source /etc/profile
18+
19+
# Includes
20+
source $VESTA/func/main.sh
21+
source $VESTA/conf/vesta.conf
22+
23+
24+
#----------------------------------------------------------#
25+
# Verifications #
26+
#----------------------------------------------------------#
27+
28+
# Checking arg number
29+
check_args '2' "$#" 'MODULE LICENSE'
30+
31+
32+
#----------------------------------------------------------#
33+
# Action #
34+
#----------------------------------------------------------#
35+
36+
# Activating license
37+
v_host='https://vestacp.com/checkout'
38+
answer=$(curl -s $v_host/activate.php?licence_key=$license&module=$module)
39+
check_result $? "cant' connect to vestacp.com " $E_CONNECT
40+
41+
# Checking server answer
42+
if [[ "$answer" != '0' ]]; then
43+
echo "Error: $module license $license is invalid"
44+
exit $E_INVALID
45+
fi
46+
47+
48+
#----------------------------------------------------------#
49+
# Vesta #
50+
#----------------------------------------------------------#
51+
52+
# Updating vesta.conf
53+
if [ -z "$(grep "${module}_KEY" $VESTA/conf/vesta.conf)" ]; then
54+
echo "${module}_KEY='$license'" >> $VESTA/conf/vesta.conf
55+
else
56+
sed -i "s/${module}_KEY=.*/${module}_KEY='$license'/g" $VESTA/conf/vesta.conf
57+
fi
58+
59+
# Activating sftpjail
60+
if [ "$module" = 'SFTPJAIL' ]; then
61+
setsid $BIN/v-add-sys-sftp-jail 2>/dev/null
62+
fi
63+
64+
# Logging
65+
log_event "$OK" "$EVENT"
66+
67+
exit

bin/v-add-fs-archive

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
#!/bin/bash
22
# info: archive directory
3-
# options: USER ARCHIVE DIRECTORY [DIRECTORY_N]
3+
# options: USER ARCHIVE SOURCE
44
#
55
# The function creates tar archive
66

77
user=$1
88
archive=$2
9-
src1=$3
10-
src2=$4
11-
src3=$5
12-
src4=$6
13-
src5=$7
14-
src6=$8
15-
src7=$9
9+
src=$3
1610

1711
# Checking arguments
18-
if [ -z "$src1" ]; then
19-
echo "Usage: USER ARCHIVE DIRECTORY [DIRECTORY_N]"
12+
if [ -z "$src" ]; then
13+
echo "Usage: USER ARCHIVE SOURCE"
2014
exit 1
2115
fi
2216

@@ -40,19 +34,22 @@ if [ -e "$archive.tar.gz" ]; then
4034
fi
4135

4236
# Checking source path
43-
for src_path in $src1 $src2 $src3 $src4 $src5 $src6 $src7; do
44-
rpath=$(readlink -f "$src_path")
45-
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
46-
echo "Error: invalid source path $src_path"
47-
exit 1
48-
fi
49-
done
37+
rpath=$(readlink -f "$src")
38+
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
39+
echo "Error: invalid source path $src"
40+
exit 1
41+
fi
42+
43+
# Parsing current directory
44+
d=$(dirname "$src")
45+
46+
# Removing leading file path
47+
f=$(echo "$src" |sed -e "s|$d/||")
5048

5149
# Creating tar.gz archive
52-
sudo -u $user tar -czf "$archive.tar.gz" \
53-
$src1 $src2 $src3 $src4 $src5 $src6 $src7 > /dev/null 2>&1
50+
sudo -u $user tar -czf "$archive.tar.gz" -C $d $f >/dev/null 2>&1
5451
if [ "$?" -ne 0 ]; then
55-
# echo "Error: archive $archive.tar.gz was not created"
52+
echo "Error: archive $archive.tar.gz was not created"
5653
exit 3
5754
fi
5855

bin/v-add-remote-dns-domain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ remote_dns_health_check
4444
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf 2>/dev/null)
4545
if [ -z "$str" ]; then
4646
pipe="$VESTA/data/queue/dns-cluster.pipe"
47-
queue_str=$(grep -n "$SCRIPT $1 $2 no$" $pipe |cut -f1 -d: |head -n1)
47+
queue_str=$(grep -n "$SCRIPT $1 $2 " $pipe |cut -f1 -d: |head -n1)
4848
if [ ! -z "$queue_str" ]; then
4949
sed -i "$queue_str d" $pipe
5050
fi

bin/v-add-sys-firewall

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
# info: add system firewall
3+
# opions: NONE
4+
#
5+
# The script enables firewall
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Includes
13+
source $VESTA/func/main.sh
14+
source $VESTA/conf/vesta.conf
15+
16+
17+
#----------------------------------------------------------#
18+
# Verifications #
19+
#----------------------------------------------------------#
20+
21+
if [ "$FIREWALL_SYSTEM" = 'iptables' ]; then
22+
exit
23+
fi
24+
25+
26+
#----------------------------------------------------------#
27+
# Action #
28+
#----------------------------------------------------------#
29+
30+
# Adding firewall directory
31+
mkdir -p $VESTA/data/firewall/
32+
33+
# Adding default ruleset
34+
if [ ! -e "$VESTA/data/firewall/rules.conf" ]; then
35+
cp $VESTA/install/rhel/7/* $VESTA/data/firewall/
36+
fi
37+
38+
# Updating FIREWAL_SYSTEM value
39+
if [ -z "$(grep FIREWALL_SYSTEM $VESTA/conf/vesta.conf)" ]; then
40+
echo "FIREWALL_SYSTEM='iptables'" >> $VESTA/conf/vesta.conf
41+
else
42+
sed -i "s/FIREWALL_SYSTEM.*/FIREWALL_SYSTEM='iptables'/g" \
43+
$VESTA/conf/vesta.conf
44+
fi
45+
46+
# Updating firewall rules
47+
$BIN/v-update-firewall
48+
49+
50+
#----------------------------------------------------------#
51+
# Vesta #
52+
#----------------------------------------------------------#
53+
54+
# Logging
55+
log_event "$OK" "$EVENT"
56+
57+
exit

bin/v-add-web-domain

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ if [ ! -z "$WEB_BACKEND" ]; then
7575
fi
7676
get_domain_backend_values
7777
backend=$(get_user_value '$BACKEND_TEMPLATE')
78+
if [ -z "$backend" ]; then
79+
backend='default'
80+
fi
7881
fi
7982

8083
# Defining variables for add_config function

bin/v-add-web-domain-backend

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
user=$1
1414
domain=$2
1515
domain_idn=$(idn -t --quiet -a "$domain")
16-
template=$3
16+
template=${3-default}
1717

1818
# Includes
1919
source $VESTA/func/main.sh

bin/v-backup-users

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ source $VESTA/conf/vesta.conf
2222
# Action #
2323
#----------------------------------------------------------#
2424

25+
$BIN/v-check-vesta-license >/dev/null
26+
2527
if [ -z "$BACKUP_SYSTEM" ]; then
2628
exit
2729
fi

bin/v-check-fs-permission

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
# The function opens/reads files on the file system
66

77
user=$1
8-
src_file=$2
8+
src=$2
99

1010
# Checking arguments
11-
if [ -z "$src_file" ]; then
11+
if [ -z "$src" ]; then
1212
echo "Usage: USER FILE"
1313
exit 1
1414
fi
@@ -27,27 +27,19 @@ if [ -z $homedir ]; then
2727
fi
2828

2929
# Checking path
30-
if [ ! -z "$src_file" ]; then
31-
rpath=$(readlink -f "$src_file")
30+
if [ ! -z "$src" ]; then
31+
rpath=$(readlink -f "$src")
3232
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
33-
echo "Error: invalid source path $src_file"
33+
echo "Error: invalid source path $user $src"
3434
exit 2
3535
fi
3636
fi
3737

38-
# Reading file
39-
#sudo -u $user cat "$src_file" 2>/dev/null
40-
#if [ $? -ne 0 ]; then
41-
# echo "Error: file $src_file was not opened"
42-
# exit 3
43-
#fi
44-
4538
# Checking if file has readable permission
46-
if [[ ! -r $src_file ]]
47-
then
48-
# echo "File is readable"
49-
#else
50-
echo "Cannot read file"
39+
sudo -u $user ls "$src" > /dev/null 2>&1
40+
if [ $? -ne 0 ]; then
41+
echo "Error: can't read $src"
42+
exit 1
5143
fi
5244

5345
# Exiting

0 commit comments

Comments
 (0)