/[resolvconf]/resolvconf/trunk/debian/postinst
ViewVC logotype

Contents of /resolvconf/trunk/debian/postinst

Parent Directory Parent Directory | Revision Log Revision Log


Revision 260 - (show annotations) (download)
Fri May 20 08:20:14 2011 UTC (2 years, 1 month ago) by jdthood-guest
File size: 6501 byte(s)
Improve is_installed()
1 #!/bin/sh
2
3 set -e
4
5 . /usr/share/debconf/confmodule
6
7 MYNAME=resolvconf.postinst
8 report() { echo "${MYNAME}: $*" ; }
9 report_err() { report "Error: $*" >&2 ; }
10 report_info() { report "$*" >&2 ; }
11
12 standard_run_subdirs_created() {
13 { [ -d /run/resolvconf ] || mkdir /run/resolvconf ; } \
14 && { [ -d /run/resolvconf/interface ] || mkdir /run/resolvconf/interface ; }
15 }
16
17 # We use dh_installinit with --no-start
18 #DEBHELPER#
19
20
21 ### Symlink ###
22
23 case "$1" in
24 configure)
25 if [ -L /etc/resolvconf/run ] ; then
26 # Make sure that the symlink is canonicalizable.
27 RUN_CANONICALPATH="$(readlink -f /etc/resolvconf/run || :)"
28 if [ -z "$RUN_CANONICALPATH" ] ; then
29 # It's not canonicalizable
30 report_err "Deleting old symlink /etc/resolvconf/run, the canonical path of whose target could not be determined"
31 rm -f /etc/resolvconf/run
32 fi
33 fi
34
35 # /etc/resolvconf/run is not a non-canonicalizable symlink.
36 # Attempt migration to new standard location
37 if [ -L /etc/resolvconf/run ] ; then
38 # It's a canonicalizable symlink
39 # If it's standard then try to migrate from old to new standard location.
40 # The initscripts package guarantees that the new standard location is available.
41 if
42 [ "$RUN_CANONICALPATH" = "/lib/init/rw/resolvconf" ] \
43 && standard_run_subdirs_created
44 then
45 # /etc/resolvconf/run points to the old-standard location
46 # and new-standard run directories are ready for use.
47 # Switch from the old to the new standard location.
48 F="$(echo /lib/init/rw/resolvconf/*)"
49 if [ "$F" ] && [ "$F" != '/lib/init/rw/resolvconf/*' ] ; then
50 if cp -a /lib/init/rw/resolvconf/* /run/resolvconf ; then
51 report_info "Migrated resolvconf run-time data from /lib/init/rw/resolvconf to /run/resolvconf"
52 fi
53 fi
54 ln -nsf /run/resolvconf /etc/resolvconf/run
55 fi
56 elif [ -d /etc/resolvconf/run ] ; then
57 # It's a directory right in /etc/resolvconf
58 # The initscripts package guarantees that the new standard location is available.
59 if standard_run_subdirs_created ; then
60 # /etc/resolvconf/run is a directory in /etc/resolvconf
61 # and new-standard run directories are ready for use.
62 # Switch to the new standard location.
63 F="$(echo /etc/resolvconf/run/*)"
64 if [ "$F" ] && [ "$F" != '/etc/resolvconf/run/*' ] ; then
65 if cp -a /etc/resolvconf/run/* /run/resolvconf ; then
66 report_info "Migrated resolvconf run-time data from /etc/resolvconf/run to /run/resolvconf"
67 rm -rf /etc/resolvconf/run
68 fi
69 else
70 rmdir /etc/resolvconf/run
71 fi
72 ln -nsf /run/resolvconf /etc/resolvconf/run
73 fi
74 fi
75
76 # Link tail to original if appropriate
77 if [ ! -e /etc/resolvconf/resolv.conf.d/tail ] ; then
78 db_get resolvconf/link-tail-to-original
79 if [ "$RET" = "true" ] ; then
80 ln -nsf original /etc/resolvconf/resolv.conf.d/tail
81 else
82 : > /etc/resolvconf/resolv.conf.d/tail
83 fi
84 fi
85
86 # Linkify /etc/resolv.conf if appropriate
87 db_get resolvconf/linkify-resolvconf
88 if [ "$RET" = "true" ] ; then
89 if
90 [ -f /etc/resolv.conf ] \
91 && {
92 [ ! -L /etc/resolv.conf ] \
93 || [ ! "$(readlink /etc/resolv.conf)" = "/etc/resolvconf/run/resolv.conf" ]
94 }
95 then
96 # Back up original file
97 if [ ! -e /etc/resolvconf/resolv.conf.d/original ] ; then
98 cp -a /etc/resolv.conf /etc/resolvconf/resolv.conf.d/original
99 else
100 cp -a /etc/resolv.conf /etc/resolv.conf.dpkg-old
101 fi
102 # Before creating the link, make sure that the original file is
103 # at the target of the link. /sbin/resolvconf will overwrite
104 # this when it does an update, of course.
105 if [ ! -e /etc/resolvconf/run/resolv.conf ] ; then
106 cp -a /etc/resolv.conf /etc/resolvconf/run/resolv.conf
107 fi
108 # Add the original file to the database so that its contents
109 # are included when resolvconf updates.
110 # Yes, this is an ugly workaround for the problem that there
111 # is no way to obtain nameserver information from interface
112 # configurers after they have done their configuration work.
113 cp -a /etc/resolv.conf /etc/resolvconf/run/interface/original.resolvconf
114 fi
115 # Create the link
116 ln -nsf /etc/resolvconf/run/resolv.conf /etc/resolv.conf
117 fi
118 ;;
119 # triggered)
120 # Don't do anything here
121 # ;;
122 # abort-upgrade)
123 # Don't do anything here since we don't do anything in the prerm on upgrade or on failed-upgrade
124 # ;;
125 # abort-remove)
126 # Don't do anything extra here since we don't deconfigure anything in the prerm on remove
127 # ;;
128 # abort-deconfigure)
129 # Don't do anything extra here since we don't do anything in the prerm on deconfigure
130 # ;;
131 esac
132
133 db_stop
134
135
136 ### Notify others of our installation ###
137
138 is_installed() {
139 # Same function in preinst, postinst, postrm
140 [ "$1" ] || return 1
141 dpkg-query -W -f='${Status}\n' "$1" 2>/dev/null | grep -siq '^[[:alpha:]]\+ [[:alpha:]]\+ installed$' >/dev/null 2>&1
142 }
143
144 case "$1" in
145 configure)
146 PACKAGES_TO_NOTIFY=""
147 [ -r /etc/resolvconf/run/packages-to-notify ] && PACKAGES_TO_NOTIFY="$(cat /etc/resolvconf/run/packages-to-notify)"
148 rm -f /etc/resolvconf/run/packages-to-notify
149 for PKG in $PACKAGES_TO_NOTIFY ; do
150 if is_installed "$PKG" ; then
151 SCRPT="/etc/resolvconf/install-remove.d/$PKG"
152 [ -x "$SCRPT" ] && "$SCRPT" install
153 fi
154 done
155 ;;
156 # triggered)
157 # Don't do anything
158 # ;;
159 # abort-upgrade)
160 # Don't do anything here since we don't do anything in the prerm on upgrade or on failed-upgrade
161 # ;;
162 # abort-remove)
163 # Don't do anything extra here since we don't deconfigure anything in the prerm on remove
164 # ;;
165 # abort-deconfigure)
166 # Don't do anything extra here since we don't do anything in the prerm on deconfigure
167 # ;;
168 esac
169
170
171 ### Trigger self to enable updates ###
172
173 enable_updates() {
174 if [ -x "/etc/init.d/resolvconf" ] ; then
175 if which invoke-rc.d >/dev/null 2>&1 ; then
176 invoke-rc.d resolvconf enable-updates || :
177 else
178 /etc/init.d/resolvconf enable-updates
179 fi
180 fi
181 }
182
183 case "$1" in
184 configure)
185 # Trigger self
186 dpkg-trigger resolvconf-enable-updates
187 ;;
188 triggered)
189 # Runs after this and other packages have been configured
190 for trigger in $2 ; do
191 case "$trigger" in
192 resolvconf-enable-updates)
193 if [ -x /sbin/resolvconf ] ; then
194 enable_updates
195 break
196 fi
197 ;;
198 esac
199 done
200 ;;
201 abort-remove)
202 # We disable updates in the prerm on remove.
203 # So, enable them again
204 enable_updates
205 ;;
206 # abort-upgrade)
207 # Don't do anything here since we don't do anything in the prerm on upgrade or on failed-upgrade
208 # ;;
209 # abort-deconfigure)
210 # Don't do anything extra here since we don't do anything in the prerm on deconfigure
211 # ;;
212 esac
213

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5