|
@@ -29,6 +29,8 @@ arch=$(arch)
|
|
|
source /etc/hestiacp/hestia.conf
|
|
source /etc/hestiacp/hestia.conf
|
|
|
# shellcheck source=/usr/local/hestia/func/main.sh
|
|
# shellcheck source=/usr/local/hestia/func/main.sh
|
|
|
source $HESTIA/func/main.sh
|
|
source $HESTIA/func/main.sh
|
|
|
|
|
+# shellcheck source=/usr/local/hestia/func/backup.sh
|
|
|
|
|
+source $HESTIA/func/backup.sh
|
|
|
# load config file
|
|
# load config file
|
|
|
source_conf "$HESTIA/conf/hestia.conf"
|
|
source_conf "$HESTIA/conf/hestia.conf"
|
|
|
# Fetch current verison B2 CLI tool
|
|
# Fetch current verison B2 CLI tool
|
|
@@ -38,123 +40,6 @@ source_conf "$HESTIA/install/upgrade/upgrade.conf"
|
|
|
b2cli="/usr/local/bin/b2"
|
|
b2cli="/usr/local/bin/b2"
|
|
|
b2lnk="https://github.com/Backblaze/B2_Command_Line_Tool/releases/download/v$b2_v/b2-linux"
|
|
b2lnk="https://github.com/Backblaze/B2_Command_Line_Tool/releases/download/v$b2_v/b2-linux"
|
|
|
|
|
|
|
|
-# Defining ftp command function
|
|
|
|
|
-ftpc() {
|
|
|
|
|
- ftp -p -n $host $port << EOF
|
|
|
|
|
- quote USER $user
|
|
|
|
|
- quote PASS $password
|
|
|
|
|
- binary
|
|
|
|
|
- $1
|
|
|
|
|
- $2
|
|
|
|
|
- $3
|
|
|
|
|
- quit
|
|
|
|
|
-EOF
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-# Defining sftp command function
|
|
|
|
|
-sftpc() {
|
|
|
|
|
- if [ "$privatekey" != "yes" ]; then
|
|
|
|
|
- expect -f "-" "$@" << EOF
|
|
|
|
|
- set count 0
|
|
|
|
|
- spawn /usr/bin/sftp -o StrictHostKeyChecking=no -o Port=$port $user@$host
|
|
|
|
|
- expect {
|
|
|
|
|
- -nocase "password:" {
|
|
|
|
|
- send "$password\r"
|
|
|
|
|
- exp_continue
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- -re "Password for (.*)@(.*)" {
|
|
|
|
|
- send "$password\r"
|
|
|
|
|
- exp_continue
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- -re "Couldn't|(.*)disconnect|(.*)stalled|(.*)not found" {
|
|
|
|
|
- set count \$argc
|
|
|
|
|
- set output "Disconnected."
|
|
|
|
|
- set rc $E_FTP
|
|
|
|
|
- exp_continue
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- -re ".*denied.*(publickey|password)." {
|
|
|
|
|
- set output "Permission denied, wrong publickey or password."
|
|
|
|
|
- set rc $E_CONNECT
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- "sftp>" {
|
|
|
|
|
- if {\$count < \$argc} {
|
|
|
|
|
- set arg [lindex \$argv \$count]
|
|
|
|
|
- send "\$arg\r"
|
|
|
|
|
- incr count
|
|
|
|
|
- } else {
|
|
|
|
|
- send "exit\r"
|
|
|
|
|
- set output "Disconnected."
|
|
|
|
|
- if {[info exists rc] != 1} {
|
|
|
|
|
- set rc $OK
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- exp_continue
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- timeout {
|
|
|
|
|
- set output "Connection timeout."
|
|
|
|
|
- set rc $E_CONNECT
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if {[info exists output] == 1} {
|
|
|
|
|
- puts "\$output"
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- exit \$rc
|
|
|
|
|
-EOF
|
|
|
|
|
- else
|
|
|
|
|
- expect -f "-" "$@" << EOF
|
|
|
|
|
- set count 0
|
|
|
|
|
- spawn /usr/bin/sftp -o StrictHostKeyChecking=no -o Port=$port -i $raw_password $user@$host
|
|
|
|
|
- expect {
|
|
|
|
|
-
|
|
|
|
|
- -re "Couldn't|(.*)disconnect|(.*)stalled|(.*)not found" {
|
|
|
|
|
- set count \$argc
|
|
|
|
|
- set output "Disconnected."
|
|
|
|
|
- set rc $E_FTP
|
|
|
|
|
- exp_continue
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- -re ".*denied.*(publickey|password)." {
|
|
|
|
|
- set output "Permission denied, wrong publickey or password."
|
|
|
|
|
- set rc $E_CONNECT
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- "sftp>" {
|
|
|
|
|
- if {\$count < \$argc} {
|
|
|
|
|
- set arg [lindex \$argv \$count]
|
|
|
|
|
- send "\$arg\r"
|
|
|
|
|
- incr count
|
|
|
|
|
- } else {
|
|
|
|
|
- send "exit\r"
|
|
|
|
|
- set output "Disconnected."
|
|
|
|
|
- if {[info exists rc] != 1} {
|
|
|
|
|
- set rc $OK
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- exp_continue
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- timeout {
|
|
|
|
|
- set output "Connection timeout."
|
|
|
|
|
- set rc $E_CONNECT
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if {[info exists output] == 1} {
|
|
|
|
|
- puts "\$output"
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- exit \$rc
|
|
|
|
|
-EOF
|
|
|
|
|
- fi
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
#----------------------------------------------------------#
|
|
#----------------------------------------------------------#
|
|
|
# Verifications #
|
|
# Verifications #
|
|
|
#----------------------------------------------------------#
|
|
#----------------------------------------------------------#
|
|
@@ -201,6 +86,12 @@ if [ "$type" = 'ftp' ]; then
|
|
|
if [ -z $port ]; then
|
|
if [ -z $port ]; then
|
|
|
port=21
|
|
port=21
|
|
|
fi
|
|
fi
|
|
|
|
|
+ PORT=$port
|
|
|
|
|
+ USERNAME=$user
|
|
|
|
|
+ PASSWORD=$password
|
|
|
|
|
+ HOST=$host
|
|
|
|
|
+ PRIVATEKEY=$privatekey
|
|
|
|
|
+
|
|
|
fconn=$(ftpc 2>&1)
|
|
fconn=$(ftpc 2>&1)
|
|
|
ferror=$(echo $fconn \
|
|
ferror=$(echo $fconn \
|
|
|
| grep -i -e failed -e error -e "can't" -e "not conn" -e "incorrect")
|
|
| grep -i -e failed -e error -e "can't" -e "not conn" -e "incorrect")
|
|
@@ -231,6 +122,10 @@ if [ "$type" = 'sftp' ]; then
|
|
|
if [ -z $port ]; then
|
|
if [ -z $port ]; then
|
|
|
port=22
|
|
port=22
|
|
|
fi
|
|
fi
|
|
|
|
|
+ PORT=$port
|
|
|
|
|
+ USERNAME=$user
|
|
|
|
|
+ PASSWORD=$password
|
|
|
|
|
+ HOST=$host
|
|
|
if [ -z $path ]; then
|
|
if [ -z $path ]; then
|
|
|
sftmpdir="vst.bK76A9SUkt"
|
|
sftmpdir="vst.bK76A9SUkt"
|
|
|
sftpc "mkdir $sftmpdir" "rmdir $sftmpdir" > /dev/null 2>&1
|
|
sftpc "mkdir $sftmpdir" "rmdir $sftmpdir" > /dev/null 2>&1
|