by Andrew Johnstone
This is something I commonly have to run and always seem to forget. In order to run unattended.
add-apt-repository "deb http://archive.canonical.com/ $(lsb_release -s -c) partner" apt-get update echo "sun-java6-jdk shared/accepted-sun-dlj-v1-1 select true" | debconf-set-selections echo "sun-java6-jre shared/accepted-sun-dlj-v1-1 select true" | debconf-set-selections DEBIAN_FRONTEND=noninteractive aptitude install -y -f sun-java6-jre sun-java6-bin sun-java6-jdk
# Simply add non-free on your main sources list cat > /etc/apt/sources.list.d/bytemark.list <<-EOD deb http://mirror.bytemark.co.uk/debian/ squeeze main contrib non-free deb-src http://mirror.bytemark.co.uk/debian/ squeeze main contrib non-free deb http://security.debian.org/ squeeze/updates main contrib non-free deb-src http://security.debian.org/ squeeze/updates main contrib non-free deb http://mirror.bytemark.co.uk/debian/ squeeze-updates main contrib non-free deb-src http://mirror.bytemark.co.uk/debian/ squeeze-updates main contrib non-free EOD echo "sun-java6-jdk shared/accepted-sun-dlj-v1-1 select true" | debconf-set-selections echo "sun-java6-jre shared/accepted-sun-dlj-v1-1 select true" | debconf-set-selections apt-get update DEBIAN_FRONTEND=noninteractive aptitude install -y -f sun-java6-jre sun-java6-bin sun-java6-jdk
Will install mysql without a password
#!/bin/bash
INSTALLER_LOG=/var/log/non-interactive-installer.log
installnoninteractive(){
sudo bash -c "DEBIAN_FRONTEND=noninteractive aptitude install -q -y $* >> $INSTALLER_LOG"
}
installnoninteractive mysql-server
# Alternatively you can set the mysql password with debconf-set-selections
apt-get install -f -y pwgen >/dev/null;
MYSQL_PASS=$(pwgen -s 12 1);
mysql -uroot -e "UPDATE mysql.user SET password=PASSWORD('${MYSQL_PASS}') WHERE user='root'; FLUSH PRIVILEGES;";
echo "MySQL Password set to '${MYSQL_PASS}'. Remember to delete ~/.mysql.passwd" | tee ~/.mysql.passwd;
apt-get install -f -y pwgen >/dev/null;
MYSQL_PASS=$(pwgen -s 12 1);
cat <<MYSQL_PRESEED | debconf-set-selections
mysql-server-5.1 mysql-server/root_password password $MYSQL_PASS
mysql-server-5.1 mysql-server/root_password_again password $MYSQL_PASS
mysql-server-5.1 mysql-server/start_on_boot boolean true
MYSQL_PRESEED
sudo DEBIAN_FRONTEND=noninteractive apt-get install -f -y mysql-server
echo "MySQL Password set to '${MYSQL_PASS}'. Remember to delete ~/.mysql.passwd" | tee ~/.mysql.passwd;
Additional notes after install:
# Place on a public interface sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf sudo service mysql restart
Reference:
scripted installation java ubuntu
Andrew Johnstone is a software engineer / lead developer working at Everlution Software.
2 Responses to Installing Java & MySQL – unattended/non-interactive installation
Vagrant – Automating PHP Installation with bash/slack for continuous deployment | Development, Analysis And Research
December 11th, 2011 at 2:22 am
[...] More examples of installing MySQL unattended can be found at Installing Java & MySQL – unattended/non-interactive installation [...]
apt-get unattended / non-interactive installation | Development, Analysis And Research
January 19th, 2012 at 11:01 pm
[...] previously wrote about “Installing Java & MySQL – unattended/non-interactive installation”. Whilst using slack, I have been running apt-get during postinstall rather than preinstall. Files [...]