[CentOS] SOT: Best strategy for automatize a flow that need user interaction

Fri Jan 29 14:09:31 UTC 2016
reynierpm at gmail.com <reynierpm at gmail.com>

I am working in a Dockerfile but there is a "secure" MariaDB server script
I need to run which is interactive and I don't know how to deal with this.

Basically this is the flow I have follow on the script at test environment
and is the same I want to achieve in the Dockerfile without user
interaction by just answering as you seen on the flow below:

    # /usr/bin/mysql_secure_installation

    Enter current password for root (enter for none): [ENTER] // because
there is no password
    OK, successfully used password, moving on...

    Set root password? [Y/n] n
     ... skipping.

    Remove anonymous users? [Y/n] Y
     ... Success!

    Disallow root login remotely? [Y/n] n
     ... skipping.

    Remove test database and access to it? [Y/n] Y
     - Dropping test database...
     ... Success!
     - Removing privileges on test database...
     ... Success!

    Reloading the privilege tables will ensure that all changes made so far
    will take effect immediately.

    Reload privilege tables now? [Y/n] Y
     ... Success!

    Cleaning up...

So I need to write a bash script or something else that could handle this
automatically but has not idea, how would you take care of this?