Skip to content

Commit e314999

Browse files
committed
Merge remote-tracking branch 'refs/remotes/serghey-rodin/master'
2 parents 408f8f3 + 8ce221c commit e314999

File tree

2,234 files changed

+105237
-18248
lines changed

Some content is hidden

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

2,234 files changed

+105237
-18248
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@ Connect to your server as root via SSH
1313
ssh root@your.server
1414
```
1515

16-
Download the installation script
16+
Download the installation script, and run it:
1717
```bash
18-
curl -O http://vestacp.com/pub/vst-install.sh
18+
curl http://vestacp.com/pub/vst-install.sh | bash
1919
```
2020

21-
Run it
21+
If the above example does not work, try this 2 step method:
22+
23+
Download the installation script:
24+
```bash
25+
curl -O http://vestacp.com/pub/vst-install.sh
26+
```
27+
Then run it:
2228
```bash
2329
bash vst-install.sh
2430
```
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
# info: update user notification
3+
# options: USER NOTIFICATION
4+
#
5+
# The function updates user notification.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
user=$1
14+
nid=$2
15+
16+
# Includes
17+
source $VESTA/func/main.sh
18+
source $VESTA/conf/vesta.conf
19+
20+
21+
#----------------------------------------------------------#
22+
# Verifications #
23+
#----------------------------------------------------------#
24+
25+
check_args '2' "$#" 'USER NOTIFICATION'
26+
validate_format 'user' 'nid'
27+
is_object_valid 'user' 'USER' "$user"
28+
29+
30+
#----------------------------------------------------------#
31+
# Action #
32+
#----------------------------------------------------------#
33+
34+
# Updating notification
35+
update_object_value 'notifications' 'NID' "$nid" '$ACK' 'yes' 2>/dev/null
36+
37+
# Checking last notification
38+
if [ -e "$USER_DATA/notifications.conf" ]; then
39+
if [ -z "$(grep NID= $USER_DATA/notifications.conf)" ]; then
40+
notice='no'
41+
fi
42+
if [ -z "$(grep "ACK='no'" $USER_DATA/notifications.conf)" ]; then
43+
notice='no'
44+
fi
45+
else
46+
notice='no'
47+
fi
48+
49+
50+
#----------------------------------------------------------#
51+
# Vesta #
52+
#----------------------------------------------------------#
53+
54+
# Updating notification counter
55+
if [ "$notice" = 'no' ]; then
56+
if [ -z "$(grep NOTIFICATIONS $USER_DATA/user.conf)" ]; then
57+
sed -i "s/^TIME/NOTIFICATIONS='no'\nTIME/g" $USER_DATA/user.conf
58+
else
59+
update_user_value "$user" '$NOTIFICATIONS' "no"
60+
fi
61+
fi
62+
63+
# Logging
64+
log_event "$OK" "$EVENT"
65+
66+
exit

bin/v-add-backup-ftp-host

Lines changed: 0 additions & 101 deletions
This file was deleted.

bin/v-add-backup-host

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
#!/bin/bash
2+
# info: add backup host
3+
# options: TYPE HOST USERNAME PASSWORD [PATH] [PORT]
4+
#
5+
# The function adds backup host
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
type=$1
14+
host=$2
15+
user=$3
16+
password=$4; HIDE=4
17+
path=${5-/backup}
18+
port=$6
19+
20+
# Includes
21+
source $VESTA/func/main.sh
22+
source $VESTA/conf/vesta.conf
23+
24+
# Defining ftp command function
25+
ftpc() {
26+
ftp -p -n $host $port <<EOF
27+
quote USER $user
28+
quote PASS $password
29+
binary
30+
$1
31+
$2
32+
$3
33+
quit
34+
EOF
35+
}
36+
37+
# Defining sftp command function
38+
sftpc() {
39+
expect -f "-" <<EOF "$@"
40+
set count 0
41+
spawn /usr/bin/sftp -o StrictHostKeyChecking=no -o \
42+
Port=$port $user@$host
43+
expect {
44+
"password:" {
45+
send "$password\r"
46+
exp_continue
47+
}
48+
49+
-re "Couldn't|(.*)disconnect|(.*)stalled|(.*)not found" {
50+
set count \$argc
51+
set output "Disconnected."
52+
set rc $E_FTP
53+
exp_continue
54+
}
55+
56+
-re ".*denied.*(publickey|password)." {
57+
set output "Permission denied, wrong publickey or password."
58+
set rc $E_CONNECT
59+
}
60+
61+
"sftp>" {
62+
if {\$count < \$argc} {
63+
set arg [lindex \$argv \$count]
64+
send "\$arg\r"
65+
incr count
66+
} else {
67+
send "exit\r"
68+
set output "Disconnected."
69+
if {[info exists rc] != 1} {
70+
set rc $OK
71+
}
72+
}
73+
exp_continue
74+
}
75+
76+
timeout {
77+
set output "Connection timeout."
78+
set rc $E_CONNECT
79+
}
80+
}
81+
82+
if {[info exists output] == 1} {
83+
puts "\$output"
84+
}
85+
86+
exit \$rc
87+
EOF
88+
}
89+
90+
91+
#----------------------------------------------------------#
92+
# Verifications #
93+
#----------------------------------------------------------#
94+
95+
if [ "$type" != 'local' ];then
96+
check_args '4' "$#" "TYPE HOST USERNAME PASSWORD [PATH] [PORT]"
97+
validate_format 'host'
98+
is_password_valid
99+
if [ "$type" = 'sftp' ]; then
100+
which expect >/dev/null 2>&1
101+
check_result $? "expect command not found" $E_NOTEXIST
102+
fi
103+
fi
104+
105+
106+
#----------------------------------------------------------#
107+
# Action #
108+
#----------------------------------------------------------#
109+
110+
# Checking network connection
111+
if [ "$type" = 'ftp' ]; then
112+
if [ -z $port ]; then
113+
port=21
114+
fi
115+
fconn=$(ftpc 2>&1)
116+
ferror=$(echo $fconn |\
117+
grep -i -e failed -e error -e "can't" -e "not conn" -e "incorrect")
118+
if [ ! -z "$ferror" ]; then
119+
echo "Error: can't login to ftp $user@$host"
120+
log_event "$E_CONNECT" "$EVENT"
121+
exit $E_CONNECT
122+
fi
123+
124+
# Checking write permissions
125+
ftpc "mkdir $path" > /dev/null 2>&1
126+
ftmpdir="$path/vst.bK76A9SUkt"
127+
ftp_result=$(ftpc "mkdir $ftmpdir" "rm $ftmpdir"|grep -v Trying)
128+
if [ ! -z "$ftp_result" ] ; then
129+
echo "$ftp_result"
130+
rm -rf $tmpdir
131+
echo "Error: can't create $ftmpdir folder on the ftp"
132+
log_event "$E_FTP" "$EVENT"
133+
exit $E_FTP
134+
fi
135+
fi
136+
if [ "$type" = 'sftp' ]; then
137+
if [ -z $port ]; then
138+
port=22
139+
fi
140+
sftmpdir="$path/vst.bK76A9SUkt"
141+
sftpc "mkdir $sftmpdir" "rmdir $sftmpdir" > /dev/null 2>&1
142+
rc=$?
143+
if [[ "$rc" != 0 ]]; then
144+
case $rc in
145+
$E_CONNECT) echo "Error: can't login to sftp $user@$host";;
146+
$E_FTP) echo "Error: can't create temp folder on the sftp host";;
147+
esac
148+
log_event "$rc" "$EVENT"
149+
exit "$rc"
150+
fi
151+
fi
152+
153+
154+
# Adding backup host
155+
if [ $type != 'local' ]; then
156+
echo "HOST='$host'
157+
USERNAME='$user'
158+
PASSWORD='$password'
159+
BPATH='$path'
160+
PORT='$port'
161+
TIME='$TIME'
162+
DATE='$DATE'" > $VESTA/conf/$type.backup.conf
163+
chmod 660 $VESTA/conf/$type.backup.conf
164+
fi
165+
166+
167+
#----------------------------------------------------------#
168+
# Vesta #
169+
#----------------------------------------------------------#
170+
171+
# Update vesta.conf
172+
if [ -z "$(grep BACKUP_SYSTEM $VESTA/conf/vesta.conf)" ]; then
173+
echo "BACKUP_SYSTEM='$type'" >> $VESTA/conf/vesta.conf
174+
else
175+
bckp=$(echo "$BACKUP_SYSTEM,$type" |\
176+
sed "s/,/\n/g"|\
177+
sort -r -u |\
178+
sed "/^$/d"|\
179+
sed ':a;N;$!ba;s/\n/,/g')
180+
sed -i "s/BACKUP_SYSTEM=.*/BACKUP_SYSTEM='$bckp'/g" $VESTA/conf/vesta.conf
181+
fi
182+
183+
# Logging
184+
log_event "$OK" "$EVENT"
185+
186+
exit

bin/v-add-cron-job

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,9 @@ sync_cron_jobs
7272
# Increasing cron value
7373
increase_user_value $user '$U_CRON_JOBS'
7474

75-
# Restart crond
75+
# Restarting crond
7676
$BIN/v-restart-cron
77-
if [ $? -ne 0 ]; then
78-
exit $E_RESTART
79-
fi
77+
check_result $? "Cron restart failed" >/dev/null
8078

8179
# Logging
8280
log_history "added cron job $job"

0 commit comments

Comments
 (0)