SUMMARY: postremove question

From: Christopher L. Barnard <>
Date: Mon Jan 29 2007 - 16:54:40 EST
I asked:

> I want to query the user after a pkg has been removed whether or not to
> execute a certain command.  I created a postremove file:
> ---------
> echo ""
> echo "foobar pkg removed.  Remove it from the manifest?  (y/[n]) \c"
> read ans
> if [ "x${ans}x" = "xyx" ]; then
>   echo "Now disabling foobar \c"
>   /usr/sbin/svcadm disable site/foobar
>   echo "and removing it."
>   /usr/sbin/svccfg delete -f site/foobar
> else
>   echo "Nothing done.  The service is still running, although the underlying"
>   echo "binary no longer exists."
> fi
> --------
> The script runs after a pkgrm, but it does not wait for user input.  How
> do I get pkgrm to query the user for a y/n?

The answer:

I can't, really.  From a backline engineer at Sun:
The only place you can ask for input is in request.  It is in place
so that all packages are guaranteed to be able to be installed
non-interactively (you can pre-supply the answers to the questions).

You can ask a question in request pre-emptively, such as "If I find a
name service, should I shut it down and remove it from the manifest?".

Then you can export the variable there in the request script:

echo "MANIFEST_REMOVAL=${my_value}" >> $1

This $1 is read later on by the other scripts.

In postinstall, you can then check the value of the variable:

if [ "$MANIFEST_REMOVAL" = y ]; then ....

That's the only way I know how to do it. The disadvantage here is you
might not know what questions to ask until later.

Also note that you can supply default values for whatever custom
variables you'd like in you pkginfo file.

Thanks to:


| Christopher L. Barnard         O     When I was a boy I was told that |
|         / \    anybody could become president.  |
| (312) 347-4901               O---O   Now I'm beginning to believe it. |
|                --Clarence Darrow |
+----------PGP public key available via finger or PGP keyserver---------+
sunmanagers mailing list
Received on Mon Jan 29 16:55:35 2007

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:44:04 EST