Hello,
I am writing a script to automatically install and configure some programs (in a jail). For most packages that is no problem.
- pkg install -y <package name>
- automatically editing config files etc, can be done as well
- pkg install -y <package name next package>
- etc
However there are packages which needs answers after starting
Tja and there I have the problem. I would like to finish the mysql installation ^unattended^ so the minimal things I have to do is:
- Enter the password (which is just <CR>)
^CR^
- than enter the mysql shell, I need to provide there the (temporarily) root password, with a command like
^ALTER USER 'root' IDENTIFIED BY 'MySQLRootPW';<CR>^
- than I have to leave the mysql shell
^exit<CR>
And then the shell (in my case zsh) should continue installing the next package^
This kind of problem, is of cause not specific for mysql, but will occur in other cases as well.
I have been looking around for all kind of solutions:
- using ^yes^
- using echo <the answer> | <the actual script> (permission denied, and is it a good idea any how)
- considered the use of ^expect^ but I do not know how to use that in combination with pkg
(and also not in combination with the overall install script).
- perl ???
- some other tool??
Hopefully there are decend / clean methods. Suggestion and examples whould be highly appreciated!
Louis
I am writing a script to automatically install and configure some programs (in a jail). For most packages that is no problem.
- pkg install -y <package name>
- automatically editing config files etc, can be done as well
- pkg install -y <package name next package>
- etc
However there are packages which needs answers after starting
pkg install -y <that package>
. As example
Code:
# pkg install -y mysql80-server
# lot of text .. followed by.
# Starting mysql
# mysql is running as pid 3748.
# Enter password:
- Enter the password (which is just <CR>)
^CR^
- than enter the mysql shell, I need to provide there the (temporarily) root password, with a command like
^ALTER USER 'root' IDENTIFIED BY 'MySQLRootPW';<CR>^
- than I have to leave the mysql shell
^exit<CR>
And then the shell (in my case zsh) should continue installing the next package^
Code:
# pkg install -y nano (as example)
# etc
I have been looking around for all kind of solutions:
- using ^yes^
- using echo <the answer> | <the actual script> (permission denied, and is it a good idea any how)
- considered the use of ^expect^ but I do not know how to use that in combination with pkg
(and also not in combination with the overall install script).
- perl ???
- some other tool??
Hopefully there are decend / clean methods. Suggestion and examples whould be highly appreciated!
Louis