home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / ucf / examples / postinst next >
Encoding:
Text File  |  2006-04-11  |  4.7 KB  |  154 lines

  1. #! /bin/sh
  2. # postinst.skeleton
  3. # Skeleton maintainer script showing all the possible cases.
  4. # Written by Charles Briscoe-Smith, March-June 1998.  Public Domain.
  5.  
  6. # Abort if any command returns an error value
  7. set -e
  8.  
  9. # This script is called as the last step of the installation of the
  10. # package.  All the package's files are in place, dpkg has already done
  11. # its automatic conffile handling, and all the packages we depend of
  12. # are already fully installed and configured.
  13.  
  14. # The following idempotent stuff doesn't generally need protecting
  15. # against being run in the abort-* cases.
  16.  
  17. # Install info files into the dir file
  18. : install-info --quiet --section "section pattern" "Section Title" \
  19. :              --description="Name of the document" /usr/info/foo.info
  20.  
  21. # Create stub directories under /usr/local
  22. : if test ! -d /usr/local/lib/foo; then
  23. :   if test ! -d /usr/local/lib; then
  24. :     if mkdir /usr/local/lib; then
  25. :       chown root.staff /usr/local/lib || true
  26. :       chmod 2775 /usr/local/lib || true
  27. :     fi
  28. :   fi
  29. :   if mkdir /usr/local/lib/foo; then
  30. :     chown root.staff /usr/local/lib/foo || true
  31. :     chmod 2775 /usr/local/lib/foo || true
  32. :   fi
  33. : fi
  34.  
  35. # Ensure the menu system is updated
  36. : [ ! -x /usr/bin/update-menus ] || /usr/bin/update-menus
  37.  
  38. # Arrange for a daemon to be started at system boot time
  39. : update-rc.d foo default >/dev/null
  40.  
  41. case "$1" in
  42.   configure)
  43.     # Configure this package.  If the package must prompt the user for
  44.     # information, do it here.
  45.     :
  46.  
  47.     # Activate menu-methods script
  48.     : chmod a+x /etc/menu-methods/foo
  49.  
  50.     # Update ld.so cache
  51.     : ldconfig
  52.  
  53.     # Make our version of a program available
  54.     : update-alternatives \
  55.     :       --install /usr/bin/program program /usr/bin/alternative 50 \
  56.     :       --slave /usr/share/man/man1/program.1.gz program.1.gz \
  57.     :               /usr/share/man/man1/alternative.1.gz
  58.  
  59.     # Tell ucf that the file in /usr/share/foo is the latest
  60.     # maintainer version, and let it handle how to manage the real
  61.     # confuguration file in /etc. This is how a static configuration
  62.     # file can be handled:
  63.     ucf /usr/share/foo/configuration /etc/foo.conf
  64.     ucfr foo /etc/foo.conf
  65.  
  66.     ### We could also do this on the fly. The following is from Tore
  67.     ### Anderson:
  68.     
  69.     #. /usr/share/debconf/confmodule
  70.  
  71.     ### find out what the user answered.
  72.     #  db_get foo/run_on_boot
  73.     #  run_on_boot=$RET
  74.     #  db_stop
  75.  
  76.     ### safely create a temporary file to generate our suggested
  77.     ### configuration file.
  78.     #    tempfile=`tempfile`
  79.     #    cat << _eof > $tempfile
  80.     ### Configuration file for Foo.
  81.  
  82.     ### this was answered by you, the user in a debconf dialogue
  83.     #  RUNONBOOT=$run_on_boot
  84.  
  85.     ### this was not, as it has a sane default value.
  86.     #  COLOUROFSKY=blue
  87.  
  88.     #_eof
  89.  
  90.     ### Note that some versions of debconf do not release stdin, so
  91.     ### the following invocation of ucf may not work, since the stdin
  92.     ### is never coneected to ucfr.
  93.  
  94.     ### now, invoke ucf, which will take care of the rest, and ask
  95.     ### the user if he wants to update his file, if it is modified.
  96.     #ucf $tempfile /etc/foo.conf
  97.  
  98.     ### done! now we'll just clear up our cruft.
  99.     #rm -f $tempfile
  100.  
  101.  
  102.     # There are three sub-cases:
  103.     if test "${2+set}" != set; then
  104.       # We're being installed by an ancient dpkg which doesn't remember
  105.       # which version was most recently configured, or even whether
  106.       # there is a most recently configured version.
  107.       :
  108.  
  109.     elif test -z "$2" -o "$2" = "<unknown>"; then
  110.       # The package has not ever been configured on this system, or was
  111.       # purged since it was last configured.
  112.       :
  113.  
  114.     else
  115.       # Version $2 is the most recently configured version of this
  116.       # package.
  117.       :
  118.  
  119.     fi ;;
  120.   abort-upgrade)
  121.     # Back out of an attempt to upgrade this package FROM THIS VERSION
  122.     # to version $2.  Undo the effects of "prerm upgrade $2".
  123.     :
  124.  
  125.     ;;
  126.   abort-remove)
  127.     if test "$2" != in-favour; then
  128.       echo "$0: undocumented call to \`postinst $*'" 1>&2
  129.       exit 0
  130.     fi
  131.     # Back out of an attempt to remove this package, which was due to
  132.     # a conflict with package $3 (version $4).  Undo the effects of
  133.     # "prerm remove in-favour $3 $4".
  134.     :
  135.  
  136.     ;;
  137.   abort-deconfigure)
  138.     if test "$2" != in-favour -o "$5" != removing; then
  139.       echo "$0: undocumented call to \`postinst $*'" 1>&2
  140.       exit 0
  141.     fi
  142.     # Back out of an attempt to deconfigure this package, which was
  143.     # due to package $6 (version $7) which we depend on being removed
  144.     # to make way for package $3 (version $4).  Undo the effects of
  145.     # "prerm deconfigure in-favour $3 $4 removing $6 $7".
  146.     :
  147.  
  148.     ;;
  149.   *) echo "$0: didn't understand being called with \`$1'" 1>&2
  150.      exit 0;;
  151. esac
  152.  
  153. exit 0
  154.