CONFMODULE(3)

πŸ’– CONFMODULE(3) πŸ’–

okay bestie, so this is a page from the Library Functions Manual and it's all about confmodule β€” the lil library that lets your shell script talk to Debian's config system. no cap, this one's lowkey iconic.


✨ NAME ✨

confmodule β€” communicate with Debian configuration system FrontEnd. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#!/bin/sh -e
. /usr/share/debconf/confmodule
db_version 2.0
db_capb 'backup'
CAPB=$RET
db_input 'foo/bar' || true
db_go || true

🌸 DESCRIPTION 🌸

so basically this is a whole library of shell functions that makes talking to Debian's configuration management system way easier, fr fr. it can chat with a FrontEnd using the debconf protocol. 🫢

the design is chef's kiss: every single command in the protocol gets its own lil function in this module. the function name is exactly the same as the command, except it's prefixed with "db_" and it's lower-case. so you call the function, and you pass in any parameters you want to follow that command. simple as.

and here's the part you gotta remember: any textual return code from the FrontEnd comes back to you in the $RET variable. but the numeric return code from the FrontEnd comes back as an actual return code β€” so you must capture those or ignore them. no skipping this step, bestie. 😭


πŸ”₯ NOTES πŸ”₯

okay so the second this library gets loaded, any text you output after that goes to standard error, not standard output. and honestly? that's a good thing. because text sent to standard output gets interpreted by the FrontEnd as commands. so yeah. πŸ’€

if you actually want to send a command directly to the FrontEnd, you gotta output it to file descriptor 3, like this:

echo GET foo/bar >&3

and now the juicy part πŸ‘‘ β€” the library checks whether it's actually talking to a FrontEnd by looking at the DEBIAN_HAS_FRONTEND variable.

  • if it's set, a FrontEnd is assumed to be running.
  • if it's not set, the library turns into one itself, and runs a copy of the script that loaded the library, connected to it.
so this means: if you source this library, do it very near the top of your script. because everything before the sourcing of the library may well get run again. not me warning you twice, but yeah. πŸ™ˆ

🌈 SEE ALSO 🌈


πŸŽ€ AUTHOR πŸŽ€

Joey Hess <joeyh@debian.org> β€” the main character who wrote this, periodt. ⭐


and that's the whole vibe check bestie πŸ’œ this was CONFMODULE(3) from the Library Functions Manual, so go forth and debconf responsibly 🧚✨