14 lines
328 B
Plaintext
14 lines
328 B
Plaintext
|
#!/usr/bin/env bash
|
||
|
# 2018 Luke Shumaker
|
||
|
{
|
||
|
set -euE
|
||
|
image=$1
|
||
|
src=$(realpath -ms -- "$2")
|
||
|
dst=$3
|
||
|
|
||
|
mountpoint=$(mktemp -dt -- "${0##*/}.XXXXXXXXXX")
|
||
|
trap "rmdir -- ${mountpoint@Q}" EXIT
|
||
|
|
||
|
sudo unshare --mount sh -c "mount --make-rslave / && mount ${image@Q} ${mountpoint@Q} && cp -aT -- ${mountpoint@Q}/${src@Q} ${dst@Q}"
|
||
|
}
|