Make sftp access compatible with Synology DSM and apply some general optimization

This commit is contained in:
Janek Bevendorff 2014-10-05 23:52:40 +02:00
parent b81371afca
commit 66e3839f55
1 changed files with 9 additions and 9 deletions

View File

@ -27,17 +27,17 @@
## ##
home_dir=$1 home_dir=$1
OS="$(/usr/bin/rs-detect-distribution)"
if [[ "Synology" == "$OS" ]]; then if $(echo "${SSH_ORIGINAL_COMMAND}" | grep -q "^\(internal-sftp\|/usr/lib/ssh/sftp-server\)"); then
export PATH="/opt/bin:/opt/sbin/:$PATH" export HOME="${home_dir}/files"
fi cd $HOME
[ -x /usr/lib/ssh/sftp-server ] && exec /usr/lib/ssh/sftp-server -R
if [ "${SSH_ORIGINAL_COMMAND}" == "internal-sftp" ] || [ "${SSH_ORIGINAL_COMMAND}" == "/usr/lib/ssh/sftp-server" ]; then [ -x /usr/libexec/sftp-server ] && exec /usr/libexec/sftp-server -R
cd "${home_dir}/files" [ -x /opt/libexec/sftp-server ] && exec /opt/libexec/sftp-server -R
exec /usr/lib/ssh/sftp-server -R
else else
exec `which rsync` --server --daemon --config="${home_dir}/rsync.conf" . RSYNC=/usr/bin/rsync
[ ! -x $RSYNC ] && [ -x /opt/bin/rsync ] && RSYNC=/opt/bin/rsync
exec $RSYNC --server --daemon --config="${home_dir}/rsync.conf"
fi fi
echo "Session failed." >&2 echo "Session failed." >&2