diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2018-08-11 14:57:24 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2018-08-11 15:00:27 -0400 |
commit | ae58deb68af6c7f147b7e96b27444599e0f364bc (patch) | |
tree | f3e16a2decddcfc7c7bbacec9745ed16e30180bd /osi-extract | |
parent | eca51a2f1745041eb366cc72e92154f825d2717c (diff) |
pull some things in to a library
Diffstat (limited to 'osi-extract')
-rwxr-xr-x | osi-extract | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/osi-extract b/osi-extract index b978a51..0030f80 100755 --- a/osi-extract +++ b/osi-extract @@ -2,12 +2,15 @@ # 2018 Luke Shumaker { set -euE - image=$1 - src=$(realpath -ms -- "$2") - dst=$3 + source "${BASH_SOURCE[0]%/*}/lib/osi.sh" + + arg_image=$1 + arg_src=$(realpath -ms -- "$2") + arg_dst=$3 + needs_sudo 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}" + with_mount "$arg_image" "$mountpoint" sudo -u "#${SUDI_UID}" -- cp -aT -- "$mountpoint/$src" "$dst" } |