sftp-symlink.sh 993 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. EXT=$1
  11. shift
  12. FILES=$*
  13. source $(dirname $0)/../common/util.sh
  14. set_pr_id
  15. set_branch
  16. if [ ! -z ${PR_ID+x} ] || [ $current_branch != "master" ]; then
  17. DIR=${DIR}/branches
  18. fi
  19. if [ -s $KEY ]; then
  20. for i in $FILES; do
  21. filepath=$(readlink -f "$i")
  22. filepath=$(basename $filepath)
  23. tmpfile=$(mktemp)
  24. echo "rm Slic3r-${current_branch}-latest.${EXT}" | sftp -i$KEY "${UPLOAD_USER}@dl.slic3r.org:$DIR/"
  25. echo "symlink $filepath Slic3r-${current_branch}-latest.${EXT} " > $tmpfile
  26. sftp -b $tmpfile -i$KEY "${UPLOAD_USER}@dl.slic3r.org:$DIR/"
  27. result=$?
  28. if [ $? -eq 1 ]; then
  29. echo "Error with SFTP symlink"
  30. exit $result;
  31. fi
  32. done
  33. else
  34. echo "$KEY is not available, not symlinking."
  35. fi
  36. exit $result