I have such code:
echo 'test'
usr=$USER
sudo sh -c "exec su $usr"
echo 'test1'
And for example echo 'test'
is code where I configuring something that requirs me to relogin in new shell. But then where code is echo 'test1'
I need to continue configuring using reloaded new shell.
Is there way to do that automatically? Like start new shell in parallel or something like that?
Ubuntu 14.04, bash.
Update:
For example, I need to install virsh but after installation it requires sudo to run. My script configurs groups adding $USER to the libvirtd group. Then I need to relogin. I can do that with sudo sh -c "exec su $usr"
. After that I need the script to continue execution. Is there way to do that?
Change with
visudo
your sudoers configuration so that you are no longer asked for a password. Seeman visudo
andman sudoers
.I suggest to use a heredoc: