Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##
- # Uploads multiple files via FTP using the LFTP command
- #
- # @usage
- # send_files john john123456 20 ftp.foo.com /home/john/remote/dir /tmp/a /tmp/b /tmp/c
- # send_files john john123456 20 ftp.foo.com /home/john/remote/dir $file_list
- #
- # @param $1 Usuário FTP
- # @param $2 Senha FTP
- # @param $3 Porta FTP
- # @param $4 Host FTP
- # @param $5 Remote destination directory
- # @param $6 Files to upload
- function ftp_send_files(){
- # we use the 'shift' command to trim up all
- # of the parameters until the last one (files)
- # so that we could use it as a variadic trailing argument
- local user="$1"; shift
- local password="$1"; shift
- local port="$1"; shift
- local host="$1"; shift
- local remote_dir="$1"; shift
- local files="$@"
- local ftp_cmd="set ftp:ssl-allow true"
- ftp_cmd+=" && set ftp:ssl-force true "
- ftp_cmd+=" && set ftp:ssl-protect-data true "
- ftp_cmd+=" && set ftp:ssl-protect-list true "
- ftp_cmd+=" && set ssl:verify-certificate false "
- ftp_cmd+=" && open -u $user,$password -p $port $host "
- ftp_cmd+=" && mput -O $remote_dir $files "
- lftp -c "$ftp_cmd"
- }
- ##
- # Mirrors a remote FTP directory to a local directory
- # the using LFTP command. In other words, it downloads
- # all files from a remote FTP directory to a local directory.
- #
- # @usage
- # send_files john john123456 20 ftp.foo.com /home/john/remote/dir /tmp/john-sync
- #
- # @param $1 Usuário FTP
- # @param $2 Senha FTP
- # @param $3 Porta FTP
- # @param $4 Host FTP
- # @param $5 Remote origin directory
- # @param $6 Local destination directory
- function ftp_mirror_directory(){
- local user="$1"
- local password="$2"
- local port="$3"
- local host="$4"
- local remote_dir="$5"
- local local_dir="$6"
- local ftp_cmd="set ftp:ssl-allow true"
- ftp_cmd+=" && set ftp:ssl-force true "
- ftp_cmd+=" && set ftp:ssl-protect-data true "
- ftp_cmd+=" && set ftp:ssl-protect-list true "
- ftp_cmd+=" && set ssl:verify-certificate false "
- ftp_cmd+=" && open -u $user,$password -p $port $host "
- ftp_cmd+=" && mirror -c --parallel=3 $remote_dir $local_dir "
- lftp -c "$ftp_cmd"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement