Remote Scripted Installation of Sun/Oracle JRE

Posted by chrisbunney on Server Fault See other posts from Server Fault or by chrisbunney
Published on 2011-11-04T20:22:02Z Indexed on 2011/11/13 1:54 UTC
Read the original article Hit count: 621

I'm attempting to automate the installation of a Debian server (debian 6.0 squeeze 64bit).

Part of the installation requires the Sun JRE package to be installed.

This package has a licence agreement, which has to be accepted. I have a script which uses the following lines to accept and install the JRE:

echo "sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean true" | debconf-set-selections
apt-get install -y sun-java6-jre

This works fine when executing the script locally. However, I need to execute the script remotely using the ssh command, e.g.:

ssh -i keyFile root@hostname './myScript'

This doesn't work.

In particular, it fails on apt-get install -y sun-java6-jre. It would seem that in spite of me setting the licence agreement to accepted, when run remotely in this manner it is ignored.

Despite setting the value to true, I still get prompted to manually accept the agreement when I run this command:

ssh -i keyFile root@hostname 'apt-get install -y sun-java6-jre'

I suspect it is something to do with environment that is taken care of when running a proper terminal session, but have no idea what to try next to fix it.

So, what do I have to do to get this command (and hence my deployment script) to run correctly when executing it remotely?

Or is there an alternative way that allows me to install the JRE remotely by another means?

Edit 0: I have compared the output of env when executed remotely via ssh and when executed via a local terminal session. The only difference between the outputs is that the local terminal session has the additional value TERM=xterm.

© Server Fault or respective owner

Related posts about ssh

Related posts about scripting