This question already has an answer here:
I have a script that checks if Java version 8 is installed on my system. If not, the script installs it. Also once it makes sure that correct java version is installed it checks if
$JAVA_HOME variable is set properly.
I am doing this by adding JAVA_HOME path to my
Everything till here works.
In the next step however, when I try to reload the
/etc/environment file using
source command, it does not load the new file.
I believe this is due to user running the script. I am running the script as root user. However I need to run
source /etc/environment as non-root user and the have rest of the commands run as root.
I have tried sudo with the -u and su with -u -c commands, however this has not worked for me. Any pointers to how this could be done would be great help. Thanks