0

I am automating dpkg-sig installation for one of my project purpose. Now I want to install it noninteractive way.

I have added the following in a file inside /etc/sudoers.d/

Cmnd_Alias DPKGSIG_INSTALL = /usr/bin/apt install -y dpkg-sig, \
                            /bin/apt install -y dpkg-sig
abc ALL=(root) NOPASSWD: DPKGSIG_INSTALL
Defaults:abc !requiretty

I am trying to install dpkg-sig using my golang code like this:

installDpkgSig := "/usr/bin/sudo DEBIAN_FRONTEND=noninteractive apt install -o Dpkg::Options::=--force-confold -y dpkg-sig"
executor.cmd = *exec.Command("bash", "-c", installDpkgSig)

It is not able to install it. Getting the following error:

sudo: sorry, you are not allowed to set the following environment variables: DEBIAN_FRONTEND

But when I remove DEBIAN_FRONTEND=noninteractive part from the installation command, it is working fine. How can run the installation noninteractive way?

1 Answer 1

1

Finally able to fix this problem. It doesn't require any changes on the /etc/sudoers.d/ file.

Modified the above code like the following and it worked.

installDpkgSig := "export DEBIAN_FRONTEND=noninteractive && /usr/bin/sudo apt install -o Dpkg::Options::=--force-confold -y dpkg-sig"
executor.cmd = *exec.Command("bash", "-c", installDpkgSig)

And as the bash session finishes DEBIAN_FRONTEND will be set to default.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .