apt.postinst 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #! /bin/sh
  2. set -e
  3. # set the proxy based on the admin users gconf settings
  4. #
  5. set_apt_proxy_from_gconf() {
  6. admin_user=$(getent group admin|cut -d: -f4|cut -d, -f1)
  7. if [ -n "$admin_user" ] && [ -x /usr/bin/sudo ] && [ -z "$http_proxy" ] && [ -x /usr/bin/gconftool ]; then
  8. use=$(sudo -u "$admin_user" gconftool --get /system/http_proxy/use_http_proxy 2>/dev/null)
  9. host=$(sudo -u "$admin_user" gconftool --get /system/http_proxy/host 2>/dev/null)
  10. port=$(sudo -u "$admin_user" gconftool --get /system/http_proxy/port 2>/dev/null)
  11. if [ "$use" = "true" ] && [ -n "$host" ] && [ -n "$port" ]; then
  12. APT_CONF_PROXY=""
  13. eval $(apt-config shell APT_CONF_PROXY Acquire::http::proxy)
  14. if [ -z "$APT_CONF_PROXY" ]; then
  15. echo "Acquire::http::proxy \"http://$host:$port/\";" >> /etc/apt/apt.conf
  16. fi
  17. fi
  18. fi
  19. }
  20. # summary of how this script can be called:
  21. # * <postinst> `configure' <most-recently-configured-version>
  22. # * <old-postinst> `abort-upgrade' <new version>
  23. # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
  24. # <new-version>
  25. # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
  26. # <failed-install-package> <version> `removing'
  27. # <conflicting-package> <version>
  28. # for details, see http://www.debian.org/doc/debian-policy/ or
  29. # the debian-policy package
  30. case "$1" in
  31. configure)
  32. if ! test -f /etc/apt/trusted.gpg; then
  33. cp /usr/share/apt/ubuntu-archive.gpg /etc/apt/trusted.gpg
  34. fi
  35. # mvo: get gconf defaults once and write to a file, reason is
  36. # that sudo no longer honors http_proxy
  37. # this can be removed after lucid is released
  38. if dpkg --compare-versions "$2" lt-nl "0.7.25.3ubuntu2"; then
  39. set_apt_proxy_from_gconf
  40. fi
  41. ;;
  42. abort-upgrade|abort-remove|abort-deconfigure)
  43. ;;
  44. *)
  45. echo "postinst called with unknown argument \`$1'" >&2
  46. exit 1
  47. ;;
  48. esac
  49. # dh_installdeb will replace this with shell code automatically
  50. # generated by other debhelper scripts.
  51. #DEBHELPER#
  52. exit 0