在 Debian/Ubuntu 上强制进行非交互式安装

在 Debian/Ubuntu 上强制进行非交互式安装

我正在使用 packer 更新我维护的 RStudio 镜像(https://marketplace.digitalocean.com/apps/rstudio),这是我为社区做的事情。管道中的第一个脚本以以下代码开头:

#!/bin/bash

# non-interactive install
DEBIAN_FRONTEND=noninteractive

# Add a swap file to prevent build time OOM errors
fallocate -l 8G /swapfile
mkswap /swapfile
swapon /swapfile

# add CRAN to apt sources
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
printf '\n#CRAN mirror\ndeb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/\n' | tee -a /etc/apt/sources.list

# update apt
apt-get -qqy -o Dpkg::Options::=--force-confdef update
apt-get -qqy -o Dpkg::Options::=--force-confdef upgrade

但是,当我运行packer build conf.json该过程时,由于 openssh-server 忽略了非交互式配置,所以失败了,脚本在这里停止了:

digitalocean: A new version (/tmp/fileVGUVsU) of configuration file /etc/ssh/sshd_config is
    digitalocean: available, but the version installed currently has been locally modified.
    digitalocean:
    digitalocean:   1. install the package maintainer's version
    digitalocean:   2. keep the local version currently installed
    digitalocean:   3. show the differences between the versions
    digitalocean:   4. show a side-by-side difference between the versions
    digitalocean:   5. show a 3-way difference between available versions
    digitalocean:   6. do a 3-way merge between available versions
    digitalocean:   7. start a new shell to examine the situation

我怎么才能始终选择第一个选项?我已经阅读了所有能找到的相关帖子。

相关内容