qvm-copy-to-vm 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/sh
  2. set -e
  3. #
  4. # The Qubes OS Project, http://www.qubes-os.org
  5. #
  6. # Copyright (C) 2010 Rafal Wojtczuk <rafal@invisiblethingslab.com>
  7. #
  8. # This program is free software; you can redistribute it and/or
  9. # modify it under the terms of the GNU General Public License
  10. # as published by the Free Software Foundation; either version 2
  11. # of the License, or (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  21. #
  22. #
  23. if [ $# -lt 2 ] ; then
  24. if [ "${0##*/}" = "qvm-move-to-vm" ] || [ "${0##*/}" = "qvm-copy-to-vm" ]; then
  25. echo "usage: $0 [--without-progress] destination_qube_name FILE [FILE ...]"
  26. else
  27. echo "usage: $0 [--without-progress] FILE [FILE ...]"
  28. fi
  29. echo
  30. if [ "${0##*/}" = "qvm-move-to-vm" ] || [ "${0##*/}" = "qvm-move" ] ; then
  31. echo "Move FILE to ~/QubesIncoming/[THIS QUBE'S NAME]/ in the destination qube."
  32. else
  33. echo "Copy FILE to ~/QubesIncoming/[THIS QUBE'S NAME]/ in the destination qube."
  34. fi
  35. echo
  36. echo "You will be prompted to select the destination qube. If FILE is a directory, it will be copied recursively."
  37. exit 1
  38. fi
  39. if [ "$1" = "--without-progress" ] ; then
  40. export PROGRESS_TYPE=none
  41. shift
  42. else
  43. export PROGRESS_TYPE=console
  44. fi
  45. VM="$1"
  46. shift
  47. if [ $PROGRESS_TYPE = console ] ; then
  48. FILECOPY_TOTAL_SIZE=$(du --apparent-size -c -- "$@" 2> /dev/null | tail -1 | cut -f 1)
  49. export FILECOPY_TOTAL_SIZE
  50. fi
  51. if [ "$VM" != \$default ]; then
  52. echo "qvm-copy-to-vm/qvm-move-to-vm tools are deprecated," >&2
  53. echo "use qvm-copy/qvm-move to avoid typing target qube name twice" >&2
  54. fi
  55. /usr/lib/qubes/qrexec-client-vm "$VM" qubes.Filecopy /usr/lib/qubes/qfile-agent "$@"
  56. if [ "${0##*/}" = "qvm-move-to-vm" ] || [ "${0##*/}" = "qvm-move" ] ; then
  57. rm -rf -- "$@"
  58. fi