mirror of
https://github.com/ben-grande/qusal.git
synced 2024-10-01 02:35:49 -04:00
bdd4c789c1
Echo can interpret operand as an option and checking every variable to be echoed is troublesome while with printf, if the format specifier is present before the operand, printing as string can be enforced.
30 lines
882 B
Bash
Executable File
30 lines
882 B
Bash
Executable File
#!/bin/sh
|
|
|
|
# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <ben.grande.b@gmail.com>
|
|
#
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
## Copy a file from an DomU to Dom0. Script has to be run in Dom0
|
|
set -eu
|
|
|
|
usage(){
|
|
printf '%s\n' "usage: ${0##*/} <QUBE> <FILE> <FILE2...>
|
|
note: disk quota is capped and can be controlled via environment variables:
|
|
note: UPDATES_MAX_BYTES (default: 4GiB)
|
|
note: UPDATES_MAX_FILES (default: 2048)" >&2
|
|
exit 1
|
|
}
|
|
|
|
test -n "${2-}" || usage
|
|
qube="${1}"
|
|
shift
|
|
|
|
dir="${HOME}/QubesIncoming/${qube}"
|
|
user="$(qvm-prefs --get -- "${qube}" default_user)"
|
|
max_bytes="${UPDATES_MAX_BYTES:-4GiB}"
|
|
max_files="${UPDATES_MAX_FILES:-2048}"
|
|
qvm-run --pass-io --localcmd="
|
|
UPDATES_MAX_BYTES=\"${max_bytes}\" UPDATES_MAX_FILES=\"${max_files}\"
|
|
/usr/libexec/qubes/qfile-dom0-unpacker \"${user}\" \"${dir}\"" \
|
|
"${qube}" /usr/lib/qubes/qfile-agent "${@}"
|