Re: Using debconf to notify of serious postinst problems
Colin Turner <email@example.com> writes:
> 2. Using debconf to notify in postinst
> Part of the install is to create a database with given credentials and
> import a schema. I have debconf prompting for values and I'm
> successfully using these in the postinst script.
> My problem/worry is this. I am asking for the root MySQL password - if
> it is known - and letting the user know I'll purge this value straight
> after database creation and so on.
> Then, in postinst, I try to test the credentials before I go further
> if [ "$have_password" = "yes" ]
> set +e
> # try a trivial query, logging in as MySQL root
> command_result=`echo "SELECT VERSION()" | mysql -h $data_hostname -u
> root --password=$root_db_password 2>&1`
> if [ "$?" -ne 0 ]
> # We don't have valid root credentials
> # Warn the user it's all gone fubar - but this makes lintian mad,
> remove for now
> echo "WARNING! Invalid MySQL root credentials ..."
> #db_input high opus/invalid_root_password || true
> The problem is, as indicated in the comments, I wanted to use a "note"
> template to warn / email the user if the credentials were wrong, before
> trying to do what I could. Adding the input causes a lintian warning.
Other people have given you good suggestions, but I did want to mention
that the lintian warning is just because lintian can't easily tell the
difference between valid uses of debconf in postinst and prompting in
postinst instead of config. For cases where one is intentionally
prompting in postinst on the basis of information that isn't available
before that point, a lintian override is appropriate.
Russ Allbery (firstname.lastname@example.org) <http://www.eyrie.org/~eagle/>