SUMMARY: postremove question



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:

1-800-USA-4SUN.

+-----------------------------------------------------------------------+
| Christopher L. Barnard O When I was a boy I was told that |
| cbarnard@xxxxxxxxxxxx / \ anybody could become president. |
| (312) 347-4901 O---O Now I'm beginning to believe it. |
| http://www.cs.uchicago.edu/~cbarnard --Clarence Darrow |
+----------PGP public key available via finger or PGP keyserver---------+
_______________________________________________
sunmanagers mailing list
sunmanagers@xxxxxxxxxxxxxxx
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



Relevant Pages

  • Re: [Full-disclosure] reduction of brute force login attempts via SSHthrough iptables --
    ... Anyhow its no problem at all to modify, so if you dont like it, just dont use it. ... on a lame script like this as long as it WORKS and is not insecure. ... echo "~ sorting out ip by ip" ... # echo "not enough failed logins, probably no attack from: ...
    (Full-Disclosure)
  • Ripping Tapes with Linux--How To
    ... the full script is located in the BASH ... My tape player is a portable style journalist's recorder from the ... The most irritating part of the recording process was setting the ... echo Starting de-noise procedure to file $TMP1 ...
    (comp.os.linux.misc)
  • Re: Linux Backup with Modification Date Filter?
    ... I wrote a bash script that acts as a wrapper to rsnapshot which first ... generates a modification-date filter, ...
    (comp.os.linux.misc)
  • Re: Command Script variable value lost during execution
    ... The value of RC_ver is numeric but ECHO would return it numeric or not... ... I checked ERRORLEVEL at the end of the script and it was 0 but again ... ECHO RoboCopy version xxx%RC_Ver%yyy ... CALL:GetRCVer RoboCopy.exe /Path ...
    (microsoft.public.windows.server.scripting)
  • Re: Bit Twister: Is this the dhclient-exit-hooks you were talking about?
    ... If you are running the dhclient then all you have to do is ... create the hooks script with YOUR CODE. ... DNS server with my wgets and then restart my firewall. ... You can put an echo statement on commands to show you what will happen ...
    (alt.os.linux)