PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, February 11, 2022

[FIXED] Scripting LAMP to be installed with predefinied root password

 February 11, 2022     bash, debconf, lamp, mysql, ubuntu     No comments   

Issue

I would like to write the following Bash Script:

When installing LAMP like this, it would ask me a root password for the MySQL installation. I would like to bash script it.

sudo apt-get install lamp-server^

Can I do it like this to pass the variable as a parameter so it would not ask me about it during installation?

rootPassword="MyRootPassword";

sudo apt-get install lamp-server^ -y $rootPassword

Solution

In order to answer debconf questions non-interactively, you will need the debconf-utils package. The debconf-set-selections command can be used to manually insert things into the debconf database that will normally be asked interactively. This can also be done at OS install time using FAI or preseeding.

export DEBIAN_FRONTEND=noninteractive
debconf-set-selections < 'mysql-server-5.1 mysql-server/root_password select PASSWORD'
debconf-set-selections < 'mysql-server-5.1 mysql-server/root_password_again select PASSWORD'

You will likely need to change the name of the mysql-server package name to the version used by your distribution. Note that the package "mysql" is a virtual package which points to the real package (which includes the version number).



Answered By - jordanm
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing