osi-tools/osi-extract

14 lines
328 B
Plaintext
Raw Normal View History

2018-08-10 00:22:41 +00:00
#!/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}"
}