osi-tools/osi-extract

17 lines
367 B
Plaintext
Raw Normal View History

2018-08-10 00:22:41 +00:00
#!/usr/bin/env bash
# 2018 Luke Shumaker
{
set -euE
2018-08-11 18:57:24 +00:00
source "${BASH_SOURCE[0]%/*}/lib/osi.sh"
2018-08-11 21:15:13 +00:00
become_sudo "$@"
2018-08-11 18:57:24 +00:00
arg_image=$1
arg_src=$(realpath -ms -- "$2")
arg_dst=$3
2018-08-10 00:22:41 +00:00
mountpoint=$(mktemp -dt -- "${0##*/}.XXXXXXXXXX")
trap "rmdir -- ${mountpoint@Q}" EXIT
2018-08-11 21:15:13 +00:00
with_mount "$arg_image" "$mountpoint" sudo -u "#${SUDO_UID}" -- cp -aT -- "$mountpoint/$src" "$dst"
2018-08-10 00:22:41 +00:00
}