1234567891011121314151617181920212223242526272829303132333435363738 |
- #!/usr/bin/fish
- echo 'Deploy website through FTP'
- function require
- set var $argv[1]
- if not set -q $var; or test -z "$var"
- echo "Please provide a value for $var"
- echo "Did you run the command source against your .env.local?"
- exit
- end
- end
- require FTP_HOST
- require FTP_USER
- require FTP_DEST
- require DIST_DIR
- set make_dirs (find $DIST_DIR -type d -printf "mkdir $FTP_DEST/%P\n")
- set files (find $DIST_DIR -type f)
- echo 'Directories to be created :'
- echo $make_dirs
- echo 'Files to be sent :'
- printf %s\n $files
- echo "FTP to $FTP_HOST"
- read --prompt-str "[deploy] password for $FTP_USER: " --silent password
- echo
- require password
- # ftp operation
- set ftp_connect "user $FTP_USER $password"
- set ftp_nmap "nmap $DIST_DIR/\$1 $FTP_DEST/\$1"
- set ftp_mput "mput $files"
- echo "Format whole command"
- printf %s\n "user $FTP_USER ******" $make_dirs $ftp_nmap $ftp_mput 'bye'
- echo "Forward whole command to FTP"
- printf %s\n $ftp_connect $make_dirs $ftp_nmap $ftp_mput 'bye' | ftp -pvin $FTP_HOST $FTP_PORT
|