Defina o ambiente dentro de 'nsenter / bin / bash'

3

Estou inserindo um namespace com nsenter -m -u -i -n -p -t $PID /bin/bash . No entanto, printenv dentro deste namespace não tem tudo de que preciso. Gostaria de enviar essas variáveis, mas gostaria de evitar o prefixo do meu comando bash como KEY=VALUE KEY2=VALUE2 /bin/bash .

Existe uma maneira melhor de fazer isso?

    
por Dane O'Connor 16.04.2014 / 19:37

1 resposta

1

Não posso fazer muito mais agora, mas parece que você pode usar opções como --rc-file ou --profile, etc.

man bash

...

If bash is invoked with the name sh, it tries to mimic the startup behavior of historical versions of sh as closely as possible, while conforming to the POSIX standard as well. When invoked as an interactive login shell, or a non-interac‐ tive shell with the --login option, it first attempts to read and execute com‐ mands from /etc/profile and ~/.profile, in that order. The --noprofile option may be used to inhibit this behavior. When invoked as an interactive shell with the name sh, bash looks for the variable ENV, expands its value if it is defined, and uses the expanded value as the name of a file to read and execute. Since a shell invoked as sh does not attempt to read and execute commands from any other startup files, the --rcfile option has no effect. A non-interactive shell invoked with the name sh does not attempt to read any other startup files. When invoked as sh, bash enters posix mode after the startup files are read.

When bash is started in posix mode, as with the --posix command line option, it follows the POSIX standard for startup files. In this mode, interactive shells expand the ENV variable and commands are read and executed from the file whose name is the expanded value. No other startup files are read.

    
por 16.04.2014 / 22:49