I'm writing script which will be run from removable media but requires this media to be unmount during execution. It can't just do it straght because medium is busy then. Thus I've split script into 2 parts - one running before unmount which is copying second script part to ramfs and launching it, second part which is unmounting madia, doing job then self-deleting and unmounting creted ramfs. But the problem is that asynchronous script started in bash launches in foreground and I don't know how this script could bring itself programmatically foreground to get user input.
So i need something like this:
script1 does his job
script1 starts script2
script1 dies
script2 goes to foreground
script2 unmounts media with script1
script2 does his job
scirpt2 starting async command and dies
async command unmounts ramfs