| 1 |
jdthood-guest |
3 |
#!/bin/bash |
| 2 |
|
|
# Bash required because /usr/share/debconf/confmodule uses "local" (#252094) |
| 3 |
|
|
|
| 4 |
|
|
set -e |
| 5 |
|
|
|
| 6 |
|
|
. /usr/share/debconf/confmodule |
| 7 |
|
|
|
| 8 |
|
|
MYNAME=resolvconf.postinst |
| 9 |
|
|
report() { echo "${MYNAME}: $*" ; } |
| 10 |
|
|
report_err() { report "Error: $*" >&2 ; } |
| 11 |
rekt-guest |
58 |
report_info() { report "Info: $*" >&2 ; } |
| 12 |
jdthood-guest |
3 |
|
| 13 |
|
|
### Create /etc/resolvconf/run ### |
| 14 |
|
|
case "$1" in |
| 15 |
|
|
configure|reconfigure) |
| 16 |
|
|
# Unfortunately we can't keep state files in /var/run/ because |
| 17 |
|
|
# resolvconf, as it must, initializes before networking does and |
| 18 |
|
|
# /var/ can be on the network. |
| 19 |
|
|
# |
| 20 |
|
|
# Only use an existing symlink if it is canonicalizable |
| 21 |
|
|
if [ -L /etc/resolvconf/run ] ; then |
| 22 |
|
|
RUN_CANONICALPATH="$(readlink -f /etc/resolvconf/run || :)" |
| 23 |
|
|
if [ -z "$RUN_CANONICALPATH" ] ; then |
| 24 |
|
|
report_err "Deleting /etc/resolvconf/run symlink whose canonical path could not be determined" |
| 25 |
|
|
rm -f /etc/resolvconf/run |
| 26 |
jdthood-guest |
59 |
elif \ |
| 27 |
|
|
[ "$RUN_CANONICALPATH" = "/dev/shm/resolvconf" ] \ |
| 28 |
|
|
&& [ -d /lib/init/rw ] \ |
| 29 |
rekt-guest |
58 |
&& [ -w /lib/init/rw ] \ |
| 30 |
|
|
&& [ -r /proc/mounts ] \ |
| 31 |
|
|
&& grep -qs "^tmpfs[[:space:]]\+/lib/init/rw[[:space:]]\+tmpfs[[:space:]]\+\([^[:space:]]\+,\)\?rw" /proc/mounts \ |
| 32 |
|
|
&& { [ -d /lib/init/rw/resolvconf ] || mkdir -v /lib/init/rw/resolvconf ; } \ |
| 33 |
|
|
&& { [ -d /lib/init/rw/resolvconf/interface ] || mkdir -v /lib/init/rw/resolvconf/interface ; } |
| 34 |
jdthood-guest |
59 |
then |
| 35 |
rekt-guest |
58 |
report_info "Migrating /dev/shm/resolvconf to /lib/init/rw/resolvconf" |
| 36 |
jdthood-guest |
73 |
F="$(echo /dev/shm/resolvconf/*)" |
| 37 |
|
|
[ "$F" ] && [ "$F" != '/dev/shm/resolvconf/*' ] && cp -a /dev/shm/resolvconf/* /lib/init/rw/resolvconf |
| 38 |
jdthood-guest |
86 |
ln -nsf /lib/init/rw/resolvconf /etc/resolvconf/run |
| 39 |
jdthood-guest |
3 |
fi |
| 40 |
|
|
fi |
| 41 |
|
|
# Delete it if it isn't a directory or a link to one |
| 42 |
|
|
if [ -e /etc/resolvconf/run ] && [ ! -d /etc/resolvconf/run ] ; then |
| 43 |
|
|
report_err "Deleting /etc/resolvconf/run which isn't a directory" |
| 44 |
|
|
rm -f /etc/resolvconf/run |
| 45 |
|
|
fi |
| 46 |
|
|
# Now /etc/resolvconf/run is either |
| 47 |
|
|
# * a directory, or |
| 48 |
|
|
# * a symlink to a directory, or |
| 49 |
|
|
# * a nonexistent (if you'll pardon the expression), or |
| 50 |
|
|
# * a dangling but canonicalizable symlink |
| 51 |
|
|
if [ -d /etc/resolvconf/run ] ; then |
| 52 |
|
|
# It's a directory or a symlink to one |
| 53 |
|
|
[ -d /etc/resolvconf/run/interface ] || mkdir -v /etc/resolvconf/run/interface |
| 54 |
|
|
elif [ -L /etc/resolvconf/run ] ; then |
| 55 |
|
|
# It's a dangling but canonicalizable symlink |
| 56 |
|
|
mkdir -v "$RUN_CANONICALPATH" |
| 57 |
|
|
mkdir -v "${RUN_CANONICALPATH}/interface" |
| 58 |
|
|
else |
| 59 |
|
|
# It's a nonexistent |
| 60 |
rekt-guest |
58 |
# Use /lib/init/rw if possible |
| 61 |
jdthood-guest |
3 |
if \ |
| 62 |
rekt-guest |
58 |
[ -d /lib/init/rw ] \ |
| 63 |
|
|
&& [ -w /lib/init/rw ] \ |
| 64 |
jdthood-guest |
3 |
&& [ -r /proc/mounts ] \ |
| 65 |
rekt-guest |
58 |
&& grep -qs "^tmpfs[[:space:]]\+/lib/init/rw[[:space:]]\+tmpfs[[:space:]]\+\([^[:space:]]\+,\)\?rw" /proc/mounts \ |
| 66 |
|
|
&& { [ -d /lib/init/rw/resolvconf ] || mkdir -v /lib/init/rw/resolvconf ; } \ |
| 67 |
|
|
&& { [ -d /lib/init/rw/resolvconf/interface ] || mkdir -v /lib/init/rw/resolvconf/interface ; } |
| 68 |
jdthood-guest |
3 |
then |
| 69 |
rekt-guest |
58 |
ln -s /lib/init/rw/resolvconf /etc/resolvconf/run |
| 70 |
jdthood-guest |
3 |
else |
| 71 |
|
|
mkdir -v /etc/resolvconf/run |
| 72 |
|
|
mkdir -v /etc/resolvconf/run/interface |
| 73 |
|
|
fi |
| 74 |
|
|
fi |
| 75 |
|
|
;; |
| 76 |
|
|
# *) |
| 77 |
|
|
# In other modes we don't need to do anything |
| 78 |
|
|
# because we didn't take any action in the prerm |
| 79 |
|
|
esac |
| 80 |
|
|
|
| 81 |
|
|
|
| 82 |
|
|
case "$1" in |
| 83 |
|
|
configure|reconfigure) |
| 84 |
|
|
# Deleting the old runlevel config is unavoidable |
| 85 |
|
|
# because there is currently no way in Debian |
| 86 |
|
|
# to update the config iff it is still the factory default |
| 87 |
|
|
update-rc.d -f resolvconf remove > /dev/null 2>&1 |
| 88 |
|
|
;; |
| 89 |
|
|
esac |
| 90 |
|
|
|
| 91 |
|
|
# We use dh_installinit with --no-start |
| 92 |
|
|
#DEBHELPER# |
| 93 |
|
|
|
| 94 |
|
|
### Link tail to original if appropriate ### |
| 95 |
|
|
TIME_TO_CHANGE_TAIL_LINK=no |
| 96 |
|
|
case "$1" in |
| 97 |
|
|
configure|reconfigure) |
| 98 |
|
|
TIME_TO_CHANGE_TAIL_LINK=yes |
| 99 |
|
|
;; |
| 100 |
|
|
# *) |
| 101 |
|
|
# In other modes we don't need to do anything |
| 102 |
|
|
# because we didn't take any action in the prerm |
| 103 |
|
|
esac |
| 104 |
|
|
|
| 105 |
|
|
if [ "$TIME_TO_CHANGE_TAIL_LINK" = yes ] ; then |
| 106 |
|
|
if [ ! -e /etc/resolvconf/resolv.conf.d/tail ] ; then |
| 107 |
|
|
db_get resolvconf/link-tail-to-original |
| 108 |
|
|
if [ "$RET" = "true" ] ; then |
| 109 |
|
|
ln -nsf original /etc/resolvconf/resolv.conf.d/tail |
| 110 |
|
|
else |
| 111 |
|
|
: > /etc/resolvconf/resolv.conf.d/tail |
| 112 |
|
|
fi |
| 113 |
|
|
fi |
| 114 |
|
|
fi |
| 115 |
|
|
|
| 116 |
|
|
### Linkify /etc/resolv.conf if appropriate ### |
| 117 |
|
|
TIME_TO_CHANGE_LINKIFICATION=no |
| 118 |
|
|
case "$1" in |
| 119 |
|
|
configure|reconfigure) |
| 120 |
|
|
TIME_TO_CHANGE_LINKIFICATION=yes |
| 121 |
|
|
;; |
| 122 |
|
|
# *) |
| 123 |
|
|
# In other modes we don't need to do anything |
| 124 |
|
|
# because we didn't take any action in the prerm |
| 125 |
|
|
esac |
| 126 |
|
|
|
| 127 |
|
|
if [ "$TIME_TO_CHANGE_LINKIFICATION" = yes ] ; then |
| 128 |
|
|
db_get resolvconf/linkify-resolvconf |
| 129 |
|
|
if [ "$RET" = "true" ] ; then |
| 130 |
|
|
# Back up |
| 131 |
|
|
if \ |
| 132 |
|
|
[ -f /etc/resolv.conf ] \ |
| 133 |
|
|
&& { \ |
| 134 |
|
|
[ ! -L /etc/resolv.conf ] \ |
| 135 |
|
|
|| [ ! "$(readlink /etc/resolv.conf)" = "/etc/resolvconf/run/resolv.conf" ] ; \ |
| 136 |
|
|
} |
| 137 |
|
|
then |
| 138 |
|
|
if [ ! -e /etc/resolvconf/resolv.conf.d/original ] ; then |
| 139 |
|
|
cp -a /etc/resolv.conf /etc/resolvconf/resolv.conf.d/original |
| 140 |
|
|
else |
| 141 |
|
|
cp -a /etc/resolv.conf /etc/resolv.conf.dpkg-old |
| 142 |
|
|
fi |
| 143 |
|
|
# Before creating the link, make sure that the original file is |
| 144 |
|
|
# at the target of the link. /sbin/resolvconf will overwrite |
| 145 |
|
|
# this when it runs, of course. |
| 146 |
|
|
if [ ! -e /etc/resolvconf/run/resolv.conf ] ; then |
| 147 |
|
|
cp -a /etc/resolv.conf /etc/resolvconf/run/resolv.conf |
| 148 |
|
|
fi |
| 149 |
|
|
fi |
| 150 |
|
|
|
| 151 |
|
|
# Create the link |
| 152 |
|
|
ln -nsf /etc/resolvconf/run/resolv.conf /etc/resolv.conf |
| 153 |
|
|
|
| 154 |
|
|
fi |
| 155 |
|
|
fi |
| 156 |
jdthood-guest |
39 |
|
| 157 |
|
|
db_stop |
| 158 |
jdthood-guest |
3 |
|
| 159 |
|
|
### Enable updates ### |
| 160 |
jdthood-guest |
39 |
if [ -x "/etc/init.d/resolvconf" ] ; then |
| 161 |
|
|
if which invoke-rc.d >/dev/null 2>&1 ; then |
| 162 |
|
|
invoke-rc.d resolvconf enable-updates || : |
| 163 |
|
|
else |
| 164 |
|
|
/etc/init.d/resolvconf enable-updates |
| 165 |
|
|
fi |
| 166 |
|
|
fi |