Improved ssh uri recognition

pull/36/head
deajan 9 years ago
parent 583998272d
commit c472b47a73

@ -31,6 +31,7 @@ UNDER WORK
RECENT CHANGES
--------------
- Improved ssh uri recognition (thanks to onovy)
- Fixed #21 by adding portable shell readlink / realpath from https://github.com/mkropat/sh-realpath
- Added detection of osync.sh script in osync-batch.sh to overcome mising path in crontab
- Fixed osync-batch.sh script when osync is in executable path like /usr/local/bin

@ -1741,11 +1741,12 @@ function Init
# remove leadng 'ssh://'
uri=${SLAVE_SYNC_DIR#ssh://*}
# remove everything after '@'
REMOTE_USER=${uri%@*}
if [ "$REMOTE_USER" == "" ]
if [[ "$uri" == *"@"* ]]
then
REMOTE_USER=$LOCAL_USER
# remove everything after '@'
REMOTE_USER=${uri%@*}
else
REMOTE_USER=$LOCAL_USER
fi
if [ "$SSH_RSA_PRIVATE_KEY" == "" ]
@ -1757,13 +1758,14 @@ function Init
_hosturiandpath=${uri#*@}
# remove everything after first '/'
_hosturi=${_hosturiandpath%%/*}
# remove last part if no port defined
REMOTE_HOST=${_hosturi%%:*}
REMOTE_PORT=${_hosturi##*:}
if [ "$REMOTE_PORT" == "" ]
if [[ "$_hosturi" == *":"* ]]
then
REMOTE_PORT=${_hosturi##*:}
else
REMOTE_PORT=22
fi
REMOTE_HOST=${_hosturi%%:*}
# remove everything before first '/'
SLAVE_SYNC_DIR=${_hosturiandpath#*/}
fi

Loading…
Cancel
Save