So I am trying to make a standard shellscript to install some standard software which are useful for me like net-tools, OpenSSH, Omada Controller and so on. As the standard .deb for the TP Link Omada Controller software needs some extra commands to configure correctly for it to start. One of them is the command
update-alternatives --config java
This gives me a prompt with three options, 0, 1 and 2. The answer needs to be 2. Always, or at least in the version that is out now.
This is what I have in my script now for the controller and I plan to put them all in a 'while'-statement to prompt if user wants to install instead of installing it automatically. The printf could be removed if it all works like I would like.
#install omada controller
cd /tmp
apt -y install gdebi-core
apt -y install openjdk-8-jdk
printf ${RED}"----------------------------\n\nPress 2 in this next prompt\n\n----------------------------\n"${NC}
update-alternatives --config java
wget https://static.tp-link.com/2020/202012/20201211/omada_v4.2.8_linux_x64.deb
export JAVA_HOME=/usr/lib/jvm/default-java
echo $JAVA_HOME
gdebi omada_v4.2.8_linux_x64.deb
Is there a way to put this into the Shell script? I have seen ways to specify answers in the same line as where the script is executed in the CLI but this is not what I want. I'd like to make it fully automated with only the prompts that are already in some installation processes and prompting to install the mentioned package.
printf "$RED--…--\n$NC"
andecho "$JAVA_HOME"
. And it’s somewhat safer to useprintf '%s\n'
text …
. You probably don’t need the{
…}
braces.