sftp.sh 774 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. # Prerequisites
  3. # Environment Variables:
  4. # UPLOAD_USER - user to upload to sftp server
  5. # KEY is assumed to be path to a ssh key for UPLOAD_USER
  6. DIR=$1
  7. shift
  8. KEY=$1
  9. shift
  10. FILES=$*
  11. source $(dirname $0)/../common/util.sh
  12. set_pr_id
  13. set_branch
  14. if [ ! -z ${PR_ID+x} ] || [ $current_branch != "master" ]; then
  15. DIR=${DIR}/branches
  16. fi
  17. if [ -s $KEY ]; then
  18. for i in $FILES; do
  19. filepath=$(readlink -f "$i")
  20. tmpfile=$(mktemp)
  21. echo put $filepath > $tmpfile
  22. sftp -b $tmpfile -i$KEY "${UPLOAD_USER}@dl.slic3r.org:$DIR/"
  23. result=$?
  24. if [ $? -eq 1 ]; then
  25. echo "Error with SFTP"
  26. exit $result;
  27. fi
  28. done
  29. else
  30. echo "$KEY is not available, not deploying."
  31. fi
  32. exit $result