Variável de ambiente DEBIAN_FRONTEND

Variável de ambiente DEBIAN_FRONTEND

Meu potencial provedor de hospedagemsugerepara executar um comando no terminal para tornar mínima a imagem do sistema operacional do servidor baseado em KVM. Como seus modelos KVM vêm com pacotes que não precisarei, pensei em usar o mesmo comando para remover pacotes indesejados.

Esse comando começa com DEBIAN_FRONTEND=noninteractivee, em seguida, invoca apt-get removeda seguinte forma:

DEBIAN_FRONTEND=noninteractive apt-get remove --purge -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" package-1 package-2 ... package-n; apt-get -y autoremove; apt-get clean all 

É a primeira vez que encontro a DEBIAN_FRONTENDvariável de ambiente e não consegui encontrar informações úteis até agora. Então eu me pergunto o que fazer com essa configuração noninteractivee se é aconselhável, porque suponho que esse valor ( noninteractive) persistiria.

Responder1

Simplesmente acrescentar um aptcomando com DEBIAN_FRONTEND=somethingnão persiste após o único comando ao qual é aplicado.

As DEBIAN_FRONTENDopções estão documentadas nas páginas de manual da Seção 7 debconf(talvez seja necessário instalar o debconf-docpacote para disponibilizá-las em seu sistema). De man 7 debconf:

Frontends
   One of debconf's unique features is that the interface it  presents  to
   you is only one of many, that can be swapped in at will. There are many
   debconf frontends available:

   dialog The default frontend, this uses  the  whiptail(1)  or  dialog(1)
          programs to display questions to you. It works in text mode.

   readline
          The  most  traditional frontend, this looks quite similar to how
          Debian configuration always has been:  a  series  of  questions,
          printed  out  at  the console using plain text, and prompts done
          using the readline library. It even supports tab completion. The
          libterm-readline-gnu-perl package is strongly recommended if you
          chose to use this frontend; the default readline module does not
          support  prompting  with default values.  At the minimum, you'll
          need the perl-modules package installed to use this frontend.

          This frontend has some special hotkeys. Pageup (or ctrl-u)  will
          go  back  to  the previous question (if that is supported by the
          package that is using debconf), and pagedown  (or  ctrl-v)  will
          skip forward to the next question.

          This is the best frontend for remote admin work over a slow con‐
          nection, or for those who are comfortable with unix.

   noninteractive
          This is the anti-frontend. It never interacts with you  at  all,
          and  makes  the  default  answers  be used for all questions. It
          might mail error messages to root, but that's it;  otherwise  it
          is  completely  silent  and  unobtrusive, a perfect frontend for
          automatic installs. If you are using this front-end, and require
          non-default  answers  to questions, you will need to preseed the
          debconf database; see the section below  on  Unattended  Package
          Installation for more details.

Também observa que:

   You can change the default frontend debconf uses by reconfiguring  deb‐
   conf.  On the other hand, if you just want to change the frontend for a
   minute, you can set the DEBIAN_FRONTEND  environment  variable  to  the
   name of the frontend to use. For example:

     DEBIAN_FRONTEND=readline apt-get install slrn

   The  dpkg-reconfigure(8) and dpkg-preconfigure(8) commands also let you
   pass --frontend= to them, followed by the frontend  you  want  them  to
   use.

   Note  that not all frontends will work in all circumstances. If a fron‐
   tend fails to start up for some reason, debconf will print out  a  mes‐
   sage explaining why, and fall back to the next-most similar frontend.

Responder2

Ao escrever scripts autônomos (incluindo Dockerfiles), ao usar apt install -ymassem DEBIAN_FRONTEND=noninteractive, às vezes a instalação travará em um prompt interativo.

insira a descrição da imagem aqui

Ao executar o comando de instalação com DEBIAN_FRONTEND=noninteractiveesses xprompts interativos são desabilitados.

informação relacionada