home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / var / lib / dpkg / info / udev.postinst < prev    next >
Encoding:
Text File  |  2006-08-23  |  3.4 KB  |  151 lines

  1. #!/bin/sh -e
  2. # This script can be called in the following ways:
  3. #
  4. # After the package was installed:
  5. #    <postinst> configure <old-version>
  6. #
  7. #
  8. # If prerm fails during upgrade or fails on failed upgrade:
  9. #    <old-postinst> abort-upgrade <new-version>
  10. #
  11. # If prerm fails during deconfiguration of a package:
  12. #    <postinst> abort-deconfigure in-favour <new-package> <version>
  13. #               removing <old-package> <version>
  14. #
  15. # If prerm fails during replacement due to conflict:
  16. #    <postinst> abort-remove in-favour <new-package> <version>
  17.  
  18.  
  19. # Remove a no-longer used conffile
  20. rm_conffile()
  21. {
  22.     CONFFILE="$1"
  23.  
  24.     if [ -e "$CONFFILE" ]; then
  25.     echo "Removing obsolete conffile $CONFFILE"
  26.     rm -f "$CONFFILE"
  27.     fi
  28. }
  29.  
  30. # Remove a conffile directory if it's not empty
  31. rm_confdir()
  32. {
  33.     CONFDIR="$1"
  34.  
  35.     if [ -d "$CONFDIR" ]; then
  36.     rmdir "$CONFDIR" 2>/dev/null \
  37.         || echo "Unable to remove $CONFDIR, not empty"
  38.     fi
  39. }
  40.  
  41. # Move a conffile without triggering a dpkg question
  42. mv_conffile() {
  43.     OLDCONFFILE="$1"
  44.     NEWCONFFILE="$2"
  45.  
  46.     if [ -e "$OLDCONFFILE" ]; then
  47.         echo "Preserving user changes to $NEWCONFFILE"
  48.         mv -f "$NEWCONFFILE" "$NEWCONFFILE".dpkg-new
  49.         mv -f "$OLDCONFFILE" "$NEWCONFFILE"
  50.     elif [ -e "$OLDCONFFILE".dpkg-bak ]; then
  51.     rm -f "$OLDCONFFILE".dpkg-bak
  52.     fi
  53. }
  54.  
  55.  
  56. # Construct the initial device tree (things udev doesn't provide)
  57. create_devices()
  58. {
  59.     rm -f /lib/udev/devices/fd
  60.     ln -sn /proc/self/fd   /lib/udev/devices/fd
  61.  
  62.     rm -f /lib/udev/devices/stdin
  63.     ln -sn /proc/self/fd/0 /lib/udev/devices/stdin
  64.  
  65.     rm -f /lib/udev/devices/stdout
  66.     ln -sn /proc/self/fd/1 /lib/udev/devices/stdout
  67.  
  68.     rm -f /lib/udev/devices/stderr
  69.     ln -sn /proc/self/fd/2 /lib/udev/devices/stderr
  70.  
  71.     rm -f /lib/udev/devices/core
  72.     ln -sn /proc/kcore     /lib/udev/devices/core
  73.  
  74.     rm -f /lib/udev/devices/sndstat
  75.     ln -sn /proc/asound/oss/sndstat /lib/udev/devices/sndstat
  76.  
  77.     rm -f /lib/udev/devices/MAKEDEV
  78.     ln -sn /sbin/MAKEDEV   /lib/udev/devices/MAKEDEV
  79.  
  80.     rm -f /lib/udev/devices/ppp
  81.     mknod -m 600 /lib/udev/devices/ppp c 108 0
  82.  
  83.     rm -f /lib/udev/devices/loop0
  84.     mknod -m 600 /lib/udev/devices/loop0 b 7 0
  85.  
  86.     rm -f /lib/udev/devices/net/tun
  87.     mknod -m 600 /lib/udev/devices/net/tun c 10 200
  88.  
  89.     rm -f /lib/udev/devices/kmem
  90.     mknod -m 640 /lib/udev/devices/kmem c 1 2
  91.     chgrp kmem /lib/udev/devices/kmem
  92.  
  93.     # Add devices we need to start udevd itself
  94.     rm -f /lib/udev/devices/console
  95.     mknod -m 600 /lib/udev/devices/console c 5 1
  96.  
  97.     rm -f /lib/udev/devices/null
  98.     mknod -m 600 /lib/udev/devices/null c 1 3
  99.  
  100. }
  101.  
  102. # Notify the user that a reboot is required
  103. reboot_required()
  104. {
  105.     if [ -x /usr/share/update-notifier/notify-reboot-required ]; then
  106.     /usr/share/update-notifier/notify-reboot-required
  107.     fi
  108. }
  109.  
  110. # Update the initramfs
  111. update_initramfs()
  112. {
  113.     update-initramfs -u
  114. }
  115.  
  116. # Rename the persistent-disk.rules file
  117. mv_persistent_disk_rules()
  118. {
  119.     mv_conffile /etc/udev/rules.d/65-persistent-disk.rules \
  120.             /etc/udev/rules.d/65-persistent-storage.rules
  121. }
  122.  
  123.  
  124. case "$1" in
  125.     configure)
  126.     # Upgrade from dapper
  127.     if dpkg --compare-versions "$2" lt "093-0ubuntu1"; then
  128.         mv_persistent_disk_rules
  129.     fi
  130.  
  131.     create_devices
  132.     update_initramfs
  133.     ;;
  134.  
  135.     abort-upgrade|abort-deconfigure|abort-remove)
  136.     ;;
  137.  
  138.     *)
  139.     echo "$0 called with unknown argument \`$1'" 1>&2
  140.     exit 1
  141.     ;;
  142. esac
  143.  
  144. # Automatically added by dh_installinit
  145. if [ -x "/etc/init.d/udev" ]; then
  146.     update-rc.d udev start 10 S . >/dev/null || exit $?
  147. fi
  148. # End automatically added section
  149.  
  150. exit 0
  151.