informative errors + sftp_path fix

This commit is contained in:
Serghey Rodin 2015-06-03 02:22:43 +03:00
commit 8f2baae014

View file

@ -96,16 +96,18 @@ EOF
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '4' "$#" "TYPE HOST USERNAME PASSWORD [PATH] [PORT]" if [ "$type" != 'local' ];then
validate_format 'host' 'user' check_args '4' "$#" "TYPE HOST USERNAME PASSWORD [PATH] [PORT]"
is_password_valid validate_format 'host' 'user'
if [ "$type" = 'sftp' ]; then is_password_valid
if [ "$type" = 'sftp' ]; then
which expect >/dev/null 2>&1 which expect >/dev/null 2>&1
if [ $? -ne 0 ];then if [ $? -ne 0 ];then
echo "Error: expect utility not found" echo "Error: expect utility not found"
log_event "$E_NOTEXIST" "$EVENT" log_event "$E_NOTEXIST" "$EVENT"
exit $E_NOTEXIST exit $E_NOTEXIST
fi fi
fi
fi fi
@ -122,7 +124,7 @@ if [ "$type" = 'ftp' ]; then
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")
if [ ! -z "$ferror" ]; then if [ ! -z "$ferror" ]; then
echo "Error: can't login to ftp server" echo "Error: can't login to ftp $user@$host"
log_event "$E_CONNECT" "$EVENT" log_event "$E_CONNECT" "$EVENT"
exit $E_CONNECT exit $E_CONNECT
fi fi
@ -143,12 +145,12 @@ if [ "$type" = 'sftp' ]; then
if [ -z $port ]; then if [ -z $port ]; then
port=22 port=22
fi fi
sftmpdir="$sftp_path/vst.bK76A9SUkt" sftmpdir="$path/vst.bK76A9SUkt"
sftpc "mkdir $sftmpdir" "rmdir $sftmpdir" > /dev/null 2>&1 sftpc "mkdir $sftmpdir" "rmdir $sftmpdir" > /dev/null 2>&1
rc=$? rc=$?
if [[ "$rc" != 0 ]]; then if [[ "$rc" != 0 ]]; then
case $rc in case $rc in
$E_CONNECT) echo "Error: can't login to sftp host";; $E_CONNECT) echo "Error: can't login to sftp $user@$host";;
$E_FTP) echo "Error: can't create temp folder on the sftp host";; $E_FTP) echo "Error: can't create temp folder on the sftp host";;
esac esac
log_event "$rc" "$EVENT" log_event "$rc" "$EVENT"