me and my hair-brained ideas again…
i am building a mailserver install script and i have hit on something i want to ask before i do just to cover my bases. i know how to use php with the shell_exec command and proc_open commands to run shell commands like sudo and apt-get but what i do not know is how do i do an install that asks for user input? my example is part of the installation calls for mysql server and when you install it via the command line it asks for the password of the admin user for mysql to be set. i have my script get that info from the user in a form and can pass the data along to other pages but how do i do pass it to the shell?
What i know how to do:
$mySql_password = $_POST['mysql_password'];
$output = shell_exec("apt-get -y install <package-id>");
or even:
$mySql_password = $_POST['mysql_password'];
$output = shell_exec("apt-get --force-yes install <package-id>");
how would i go about passing the password to it after i have it set as a variable?
keep in mind that this script is going to be run from the desktop of the server(if they have a desktop) or via a web browser and the script will have a self destruct mode at the end to erase the install script to prevent someone from forgetting about it. ssl is also going to be recommended as pre-install checklist.
After looking around a bit (google “Unattended MySQL Install” or something among these lines), something that should help you is
DEBIAN_FRONTEND=noninteractive.Try this to install without password and set it afterwards :
Alternatively,
debconf-set-selectionsshould allow you to set a default password so mysql is directly installed with it.