Check for non-interactive mode in Debian package maintainer scripts
If I’m writing a Debian package maintainer script (such as a pre-install script) for a package I create, how can I make the script determine if it is supposed to be running in non-interactive mode (e.g. if apt-get install
was invoked with -y
, and things like that)?
If your maintainer scripts need to interact with the user running the installation, the recommended way to proceed is to use debconf
; see Conditional file and directory installation in Debian Packages for pointers. This might seem complicated but it does bring a number of benefits — not only does debconf
handle non-interactive setups (with an explicit DEBIAN_FRONTEND=noninteractive
invocation, or because there is no way to interact with a user), it also supports various frontends, and settings managed by debconf
can be set ahead of installation (using “pre-seeding”). This might not be relevant in your case but debconf
also supports prompts in various languages.
Note that apt-get
flags are separate from maintainer script interactivity; see Is DEBIAN_FRONTEND=noninteractive redundant with apt-get -yqq?