mirror of
https://github.com/gaschz/dotfiles.git
synced 2025-06-06 18:08:31 +02:00
feat: use qfile-dom0-unpacker to copy to dom0
This commit is contained in:
parent
932dab7bfc
commit
87499f76ad
@ -8,43 +8,25 @@
|
|||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
usage(){
|
usage(){
|
||||||
echo "usage: ${0##*/} <QUBE> <FILE> <FILE2...>" >&2
|
echo "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
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
run_qube(){
|
|
||||||
qvm-run -p "${qube}" "${1}"
|
|
||||||
}
|
|
||||||
|
|
||||||
main(){
|
main(){
|
||||||
qube_file="${1}"
|
file="${1}"
|
||||||
qube_dir="${qube_file%/*}"
|
dir="${HOME}/QubesIncoming/${qube}"
|
||||||
qube_base="${qube_file##*/}"
|
user="$(qvm-prefs --get -- "${qube}" default_user)"
|
||||||
|
max_bytes="${UPDATES_MAX_BYTES:-4GiB}"
|
||||||
incoming_dir="/home/user/QubesIncoming/${qube}"
|
max_files="${UPDATES_MAX_FILES:-2048}"
|
||||||
mkdir -p -- "${incoming_dir}"
|
qvm-run --pass-io --localcmd="
|
||||||
incoming_file="${incoming_dir}/${qube_base}"
|
UPDATES_MAX_BYTES=\"${max_bytes}\" UPDATES_MAX_FILES=\"${max_files}\"
|
||||||
incoming_base="${qube_base}"
|
/usr/libexec/qubes/qfile-dom0-unpacker \"${user}\" \"${dir}\"" \
|
||||||
|
"${qube}" /usr/lib/qubes/qfile-agent "${file}"
|
||||||
if test -e "${incoming_file}"; then
|
|
||||||
echo "Error: destination already exists: ${incoming_file}" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! run_qube "test -e ${qube_file}"; then
|
|
||||||
echo "Error: Qube ${qube} does not contain file ${qube_file}" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if run_qube "test -d \"${qube_file}\""; then
|
|
||||||
run_qube "tar -cC \"${qube_dir}\" \"${qube_base}\" " \
|
|
||||||
| tar -xC "${incoming_dir}" "${incoming_base}"
|
|
||||||
else
|
|
||||||
run_qube "cat -- \"${qube_file}\"" > "${incoming_file}"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
test -n "${2-}" || usage
|
test -n "${2-}" || usage
|
||||||
qube="${1}"
|
qube="${1}"
|
||||||
shift
|
shift
|
||||||
|
Loading…
x
Reference in New Issue
Block a user