I am writing a RHEL kickstart script, and in my %post, I need to install a JRE.
Basically, the current setup involves me needing to manually go in after first boot and set the newly installed JRE as the default using the alternatives --config
command. Is there a way for me to pass arguments to alternatives
so I don't have to manually pick the correct JRE?
Does your version have
--set
?You can use
alternatives --auto <name>
to automatically select the highest priority option.An example:
Would select the higher priority version (20)
/usr/java/latest/bin/javac
Use
grep
:or
You may use the script below.
You should configure the path for java "/bin" directory and a number for each version according to your system.
If you save the script with name "update-java", then set the executable permission, you will be able to run like below.