Skip to content

Instantly share code, notes, and snippets.

@xentec
Created September 12, 2017 11:31
Show Gist options
  • Save xentec/d1de83a382416f2b513aaa479e91a5bc to your computer and use it in GitHub Desktop.
Save xentec/d1de83a382416f2b513aaa479e91a5bc to your computer and use it in GitHub Desktop.
#!/bin/sh -e
for DEV; do true; done # get last argument
TMPDIR="$(mktemp -d "/mnt/$(basename "$DEV").XXXX")"
mount $* "$TMPDIR"
echo "Mounting $DEV on $TMPDIR"
(cd "$TMPDIR" && su "$SUDO_USER")
echo "Deleting $TMPDIR"
umount "$TMPDIR"
rm -r "$TMPDIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment