share-link 642 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env bash
  2. ssh_server="bryanroessler.com"
  3. ssh_files_path="/var/www/repos.bryanroessler.com/files"
  4. www_files_path="https://repos.bryanroessler.com/files"
  5. if [[ "$#" -lt 1 ]]; then
  6. echo "You must provide at least one argument"
  7. exit 1
  8. fi
  9. for file in "$@"; do
  10. fname="${file##*/}"
  11. random32=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 32 | head -n 1)
  12. rsync -a "${file}" "${ssh_server}:${ssh_files_path}/${random32}/"
  13. links_array+=("$www_files_path/${random32}/$fname")
  14. done
  15. if [[ "${#links_array[@]}" == 1 ]]; then
  16. printf '%s' "${links_array[@]}" | wl-copy
  17. else
  18. printf '%s\n' "${links_array[@]}" | wl-copy
  19. fi
  20. exit $?