
私のスクリプトは、debootstrap を使用して Debian イメージを構築しながら、chroot 内で sysvinit を systemd に置き換えます。
これは「危険な」アクションなので、apt-get は「続行するには、「はい、私の言うとおりにしてください」というフレーズを入力してください」というばかげた質問をします。
それに対する返信をスクリプトで記述するにはどうすればよいでしょうか?
編集: -y --yes --force-yes オプションをすべて試しましたが、機能しません。
答え1
不思議なことに、次のような質問もされているようです--force-yes
:
apt-get remove -y --force-yes systemd
しかし、
echo 'Yes, do as I say!' | apt-get remove systemd
きちんと動作しました。
答え2
apt-get には-y, --yes, --assume-yes
スイッチがあります:
Automatic yes to prompts; assume "yes" as answer to all prompts and
run non-interactively. If an undesirable situation, such as
changing a held package, trying to install a unauthenticated
package or removing an essential package occurs then apt-get will
abort. Configuration Item: APT::Get::Assume-Yes.
または、代わりに--force-yes
スイッチ:
Force yes; this is a dangerous option that will cause apt to
continue without prompting if it is doing something potentially
harmful. It should not be used except in very special situations.
Using force-yes can potentially destroy your system! Configuration
Item: APT::Get::force-yes
http://manpages.ubuntu.com/manpages/utopic/man8/apt-get.8.html