deploy-to-ovh.fish 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/fish
  2. echo 'Deploy website through FTP'
  3. function require
  4. set var $argv[1]
  5. if not set -q $var; or test -z "$var"
  6. echo "Please provide a value for $var"
  7. echo "Did you run the command source against your .env.local?"
  8. exit
  9. end
  10. end
  11. require FTP_HOST
  12. require FTP_USER
  13. require FTP_DEST
  14. require DIST_DIR
  15. set make_dirs (find $DIST_DIR -type d -printf "mkdir $FTP_DEST/%P\n")
  16. set files (find $DIST_DIR -type f)
  17. echo 'Directories to be created :'
  18. echo $make_dirs
  19. echo 'Files to be sent :'
  20. printf %s\n $files
  21. echo "FTP to $FTP_HOST"
  22. read --prompt-str "[deploy] password for $FTP_USER: " --silent password
  23. echo
  24. require password
  25. # ftp operation
  26. set ftp_connect "user $FTP_USER $password"
  27. set ftp_nmap "nmap $DIST_DIR/\$1 $FTP_DEST/\$1"
  28. set ftp_mput "mput $files"
  29. echo "Format whole command"
  30. printf %s\n "user $FTP_USER ******" $make_dirs $ftp_nmap $ftp_mput 'bye'
  31. echo "Forward whole command to FTP"
  32. printf %s\n $ftp_connect $make_dirs $ftp_nmap $ftp_mput 'bye' | ftp -pvin $FTP_HOST $FTP_PORT