0

i have a ubuntu server where i'm trying to install mysql-server (as well as other software) with python-apt

the problem is that at some point is needed to interact with the installer (providing a password). Is it possible to interact with the installer using python-apt?

Example:

import apt
cache = apt.cache.Cache()
cache.update()
pkg = cache['mysql-server']
pkg.mark_install()
cache.commit()

it stalls waitting for user input

r3v3r53
  • 142
  • 1
  • 1
  • 10

1 Answers1

0

(edited) managed to make it work following this post

from subprocess import check_call
command = "debconf-set-selections <<< \"mysql-server mysql-server/root_password password your_password\""
check_call(command, shell=True, executable="bash")
command = "debconf-set-selections <<< \"mysql-server mysql-server/root_password_again password your_password\""
check_call(command, shell=True, executable="bash")
command = "apt install mysql-server"
check_call(command, shell=True, executable="bash")
r3v3r53
  • 142
  • 1
  • 1
  • 10