This file is indexed.

postinst is in resolvconf 1.79.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
#!/bin/sh
#
# This file is part of the resolvconf package.
#

set -e

. /usr/share/debconf/confmodule

MYNAME=resolvconf.postinst
report() { echo "${MYNAME}: $*" ; }
report_err() { report "Error: $*" >&2 ; }
report_warn() { report "Warning: $*" >&2 ; }
report_info() { report "$*" >&2 ; }

is_immutable_file() {
	[ "$1" ] || return 2
	[ -e "$1" ] || return 1
	[ ! -L "$1" ] || return 1
	local ATTR="$(lsattr "$1" 2>/dev/null || :)"
	[ "$ATTR" ] || return 1
	echo "$ATTR" | awk '$1 ~ /i/ { exit 0; }; { exit 1; }'
}

dnssec_trigger_is_installed() {
	which dnssec-triggerd >/dev/null 2>&1 ;
}

case "$1" in
  configure)
	### Deal with obsolete configuration files ###
	rm -f /etc/dhcp3/dhclient-enter-hooks.d/resolvconf
	[ -f /etc/resolvconf/update.d/bind ] && mv -f /etc/resolvconf/update.d/bind /etc/resolvconf/update.d/bind.dpkg-old

	### If there are "S" runlevel symlinks in runlevels 1-5 then that is bad. Delete them. ###
	G='/etc/rc[1-5].d/S??resolvconf'
	if [ "$(echo $G)" != "$G" ] ; then
		update-rc.d resolvconf remove >/dev/null || :
	fi
	;;
esac

# Automatically added by dh_systemd_enable
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask resolvconf.service >/dev/null || true

# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled resolvconf.service; then
	# Enables the unit on first installation, creates new
	# symlinks on upgrades if the unit file has changed.
	deb-systemd-helper enable resolvconf.service >/dev/null || true
else
	# Update the statefile to add new symlinks (if any), which need to be
	# cleaned up on purge. Also remove old symlinks.
	deb-systemd-helper update-state resolvconf.service >/dev/null || true
fi
# End automatically added section
# Automatically added by dh_installinit
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
	if [ -x "/etc/init.d/resolvconf" ]; then
		update-rc.d resolvconf defaults >/dev/null || exit $?
	fi
fi
# End automatically added section


### Create run-time directories and linkify ###
#
# We create the run-time directories here, in the postinst, even though
# we also do so in the preinst, because
# * the system may have rebooted since the preinst ran, causing
#   everything on tmpfses to disappear;
# * multistrap doesn't run the preinst at all.
#
case "$1" in
  configure)
	if [ -L /etc/resolvconf/run ] ; then
		# Make sure that the symlink is canonicalizable.
		RUN_CANONICALPATH="$(readlink -f /etc/resolvconf/run || :)"
		if [ -z "$RUN_CANONICALPATH" ] ; then
			# It's not canonicalizable
			report_warn "Deleting old symlink /etc/resolvconf/run, the canonical path of whose target could not be determined"
			rm -f /etc/resolvconf/run
		fi
	fi

	# /etc/resolvconf/run is not a non-canonicalizable symlink.

	if [ -d /etc/resolvconf/run ] && ! [ -L /etc/resolvconf/run ] ; then
		# It's a directory right in /etc/resolvconf
		# Move to the new standard location.
		# The initscripts package guarantees that the new standard location is available.
		if mkdir -p /run/resolvconf/interface ; then
			F="$(echo /etc/resolvconf/run/*)"
			if [ "$F" ] && [ "$F" != '/etc/resolvconf/run/*' ] ; then
				if cp -a /etc/resolvconf/run/* /run/resolvconf ; then
					report_info "Migrated resolvconf run-time data from /etc/resolvconf/run to /run/resolvconf"
					rm -rf /etc/resolvconf/run
				fi
			else
				rm -rf /etc/resolvconf/run
			fi
			ln -nsf /run/resolvconf /etc/resolvconf/run
		else
			report_err "Could not create run-time directories; aborting"
			exit 1
		fi
	fi

	# Delete /etc/resolvconf/run if it exists but is neither a directory nor a link to one
	if [ -e /etc/resolvconf/run ] && [ ! -d /etc/resolvconf/run ] ; then
		report_warn "Deleting /etc/resolvconf/run which isn't a directory"
		rm -f /etc/resolvconf/run
	fi

	# OK, now /etc/resolvconf/run is either:
	# * nonexistent, or
	# * a dangling but canonicalizable symlink, or
	# * a symlink to a directory

	# Create subdirectory
	if [ -d /etc/resolvconf/run ] ; then
		# It's a symlink to a directory
		[ -d /etc/resolvconf/run/interface ] || mkdir /etc/resolvconf/run/interface
	elif [ -L /etc/resolvconf/run ] ; then
		# It's a dangling but canonicalizable symlink
		mkdir "$RUN_CANONICALPATH" "${RUN_CANONICALPATH}/interface"
	else
		# It's nonexistent.
		# Make directory in the standard location and link to it
		if mkdir -p /run/resolvconf/interface ; then
			ln -s /run/resolvconf /etc/resolvconf/run
		else
			report_err "Could not create run-time directories; aborting"
			exit 1
		fi
	fi

	# Do linkify once again on dpkg-reconfigure
	if [ "$DEBCONF_RECONFIGURE" = 1 ] || [ "$1" = reconfigure ] ; then
		rm -f /var/lib/resolvconf/linkified
	fi

	# Link tail to original if appropriate
	if [ ! -e /etc/resolvconf/resolv.conf.d/tail ] && [ ! -e /var/lib/resolvconf/linkified ] ; then
		db_get resolvconf/link-tail-to-original
		if [ "$RET" = "true" ] ; then
			ln -nsf original /etc/resolvconf/resolv.conf.d/tail
		else
			: > /etc/resolvconf/resolv.conf.d/tail
		fi
	fi

	# Linkify /etc/resolv.conf if appropriate
	if [ ! -e /var/lib/resolvconf/linkified ] ; then
		db_get resolvconf/linkify-resolvconf
		if [ "$RET" = "true" ] ; then
			if is_immutable_file /etc/resolv.conf ; then
				if dnssec_trigger_is_installed ; then
					# dnssec-trigger sets the immutability attribute. Override it.
					# See #776778 for background.
					chattr -i /etc/resolv.conf
				else
					# Respect the admin
					report_err "Cannot replace the current /etc/resolv.conf with a symbolic link because it is immutable; to correct this problem, gain root privileges in a terminal and run 'chattr -i /etc/resolv.conf' and then 'dpkg --configure resolvconf'; aborting"
					exit 1
				fi
			else
				if
					[ -f /etc/resolv.conf ] \
					&& {
						[ ! -L /etc/resolv.conf ] \
						|| [ ! "$(readlink /etc/resolv.conf)" = "/etc/resolvconf/run/resolv.conf" ]
					}
				then
					# Back up original file
					if [ ! -e /etc/resolvconf/resolv.conf.d/original ] ; then
						cp -a /etc/resolv.conf /etc/resolvconf/resolv.conf.d/original
					else
						cp -a /etc/resolv.conf /etc/resolv.conf.dpkg-old
					fi
					# Before creating the link, make sure that the original file is
					# at the target of the link.  /sbin/resolvconf will overwrite
					# this when it does an update, of course.
					if [ ! -e /etc/resolvconf/run/resolv.conf ] ; then
						cp -a /etc/resolv.conf /etc/resolvconf/run/resolv.conf
					fi
					# Add the original file to the database so that its contents
					# are included when resolvconf updates.
					# Yes, this is an ugly workaround for the problem that some
					# interface configurers haven't added a dpkg-event.d script.
					cp -a /etc/resolv.conf /etc/resolvconf/run/interface/original.resolvconf
				fi
				# Create the link
				ln -nsf /etc/resolvconf/run/resolv.conf /etc/resolv.conf
				# Make a record that we have created it
				:> /var/lib/resolvconf/linkified
			fi
		fi
	fi
	;;
  # triggered)
	# Don't do anything here
	# ;;
  # abort-upgrade)
	# Don't do anything here since we don't do anything in the prerm on upgrade or on failed-upgrade
	# ;;
  # abort-remove)
	# Don't do anything extra here since we don't deconfigure anything in the prerm on remove
	# ;;
  # abort-deconfigure)
	# Don't do anything extra here since we don't do anything in the prerm on deconfigure
	# ;;
esac

db_stop


### Notify others of our installation ###

is_installed() {
	# Same function in preinst, postinst, postrm
	[ "$1" ] || return 1
	dpkg-query -W -f='${Status}\n' "$1" 2>/dev/null | grep -siq '^[[:alpha:]]\+ [[:alpha:]]\+ installed$' >/dev/null 2>&1
}

case "$1" in
  configure)
	if [ -f /etc/resolvconf/run/packages-to-notify ] ; then
		PACKAGES_TO_NOTIFY="$(cat /etc/resolvconf/run/packages-to-notify)"
		rm -f /etc/resolvconf/run/packages-to-notify
		for PKG in $PACKAGES_TO_NOTIFY ; do
			if is_installed "$PKG" ; then
				SCRPT="/usr/lib/resolvconf/dpkg-event.d/$PKG"
				if [ -x "$SCRPT" ] ; then
					"$SCRPT" install || :
				fi
			fi
		done
	fi
	;;
  # triggered)
	# Don't do anything
	# ;;
  # abort-upgrade)
	# Don't do anything here since we don't do anything in the prerm on upgrade or on failed-upgrade
	# ;;
  # abort-remove)
	# Don't do anything extra here since we don't deconfigure anything in the prerm on remove
	# ;;
  # abort-deconfigure)
	# Don't do anything extra here since we don't do anything in the prerm on deconfigure
	# ;;
esac


### (Trigger self to) enable updates ###

case "$1" in
  reconfigure)
		resolvconf --enable-updates
	;;
  configure)
	if [ "$DEBCONF_RECONFIGURE" = 1 ] ; then
		resolvconf --enable-updates
	else
		# Trigger self to enable updates later
		dpkg-trigger --no-await resolvconf-enable-updates || resolvconf --enable-updates
	fi
	;;
  triggered)
	# Runs after this and other packages have been configured
        for trggr in $2 ; do
		case "$trggr" in
		  resolvconf-enable-updates)
			resolvconf --enable-updates
			break
			;;
		esac
        done
	;;
  abort-remove)
	# We disable updates in the prerm on remove.
	# So, enable them again
	resolvconf --enable-updates
	;;
  # abort-upgrade)
	# Don't do anything here since we don't do anything in the prerm on upgrade or on failed-upgrade
	# ;;
  # abort-deconfigure)
	# Don't do anything extra here since we don't do anything in the prerm on deconfigure
	# ;;
esac

exit 0