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

Contents of /resolvconf/trunk/debian/postinst

Parent Directory Parent Directory | Revision Log Revision Log


Revision 58 - (show annotations) (download)
Mon Dec 31 20:04:43 2007 UTC (5 years, 5 months ago) by rekt-guest
File size: 5181 byte(s)
use /lib/init/rw instead of /dev/shm (tested and applied patch from Roger Leigh for #431181)
1 #!/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 report_info() { report "Info: $*" >&2 ; }
12
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 elif [ "$RUN_CANONICALPATH" = "/dev/shm/resolvconf" ] && \
27 [ -d /lib/init/rw ] \
28 && [ -w /lib/init/rw ] \
29 && [ -r /proc/mounts ] \
30 && grep -qs "^tmpfs[[:space:]]\+/lib/init/rw[[:space:]]\+tmpfs[[:space:]]\+\([^[:space:]]\+,\)\?rw" /proc/mounts \
31 && { [ -d /lib/init/rw/resolvconf ] || mkdir -v /lib/init/rw/resolvconf ; } \
32 && { [ -d /lib/init/rw/resolvconf/interface ] || mkdir -v /lib/init/rw/resolvconf/interface ; }
33 then
34 report_info "Migrating /dev/shm/resolvconf to /lib/init/rw/resolvconf"
35 cp -a /dev/shm/resolvconf/* /lib/init/rw/resolvconf
36 rm -f /etc/resolvconf/run
37 ln -s /lib/init/rw/resolvconf /etc/resolvconf/run
38 fi
39 fi
40 # Delete it if it isn't a directory or a link to one
41 if [ -e /etc/resolvconf/run ] && [ ! -d /etc/resolvconf/run ] ; then
42 report_err "Deleting /etc/resolvconf/run which isn't a directory"
43 rm -f /etc/resolvconf/run
44 fi
45 # Now /etc/resolvconf/run is either
46 # * a directory, or
47 # * a symlink to a directory, or
48 # * a nonexistent (if you'll pardon the expression), or
49 # * a dangling but canonicalizable symlink
50 if [ -d /etc/resolvconf/run ] ; then
51 # It's a directory or a symlink to one
52 [ -d /etc/resolvconf/run/interface ] || mkdir -v /etc/resolvconf/run/interface
53 elif [ -L /etc/resolvconf/run ] ; then
54 # It's a dangling but canonicalizable symlink
55 mkdir -v "$RUN_CANONICALPATH"
56 mkdir -v "${RUN_CANONICALPATH}/interface"
57 else
58 # It's a nonexistent
59 # Use /lib/init/rw if possible
60 if \
61 [ -d /lib/init/rw ] \
62 && [ -w /lib/init/rw ] \
63 && [ -r /proc/mounts ] \
64 && grep -qs "^tmpfs[[:space:]]\+/lib/init/rw[[:space:]]\+tmpfs[[:space:]]\+\([^[:space:]]\+,\)\?rw" /proc/mounts \
65 && { [ -d /lib/init/rw/resolvconf ] || mkdir -v /lib/init/rw/resolvconf ; } \
66 && { [ -d /lib/init/rw/resolvconf/interface ] || mkdir -v /lib/init/rw/resolvconf/interface ; }
67 then
68 ln -s /lib/init/rw/resolvconf /etc/resolvconf/run
69 else
70 mkdir -v /etc/resolvconf/run
71 mkdir -v /etc/resolvconf/run/interface
72 fi
73 fi
74 ;;
75 # *)
76 # In other modes we don't need to do anything
77 # because we didn't take any action in the prerm
78 esac
79
80
81 case "$1" in
82 configure|reconfigure)
83 # Deleting the old runlevel config is unavoidable
84 # because there is currently no way in Debian
85 # to update the config iff it is still the factory default
86 update-rc.d -f resolvconf remove > /dev/null 2>&1
87 ;;
88 esac
89
90 # We use dh_installinit with --no-start
91 #DEBHELPER#
92
93 ### Link tail to original if appropriate ###
94 TIME_TO_CHANGE_TAIL_LINK=no
95 case "$1" in
96 configure|reconfigure)
97 TIME_TO_CHANGE_TAIL_LINK=yes
98 ;;
99 # *)
100 # In other modes we don't need to do anything
101 # because we didn't take any action in the prerm
102 esac
103
104 if [ "$TIME_TO_CHANGE_TAIL_LINK" = yes ] ; then
105 if [ ! -e /etc/resolvconf/resolv.conf.d/tail ] ; then
106 db_get resolvconf/link-tail-to-original
107 if [ "$RET" = "true" ] ; then
108 ln -nsf original /etc/resolvconf/resolv.conf.d/tail
109 else
110 : > /etc/resolvconf/resolv.conf.d/tail
111 fi
112 fi
113 fi
114
115 ### Linkify /etc/resolv.conf if appropriate ###
116 TIME_TO_CHANGE_LINKIFICATION=no
117 case "$1" in
118 configure|reconfigure)
119 TIME_TO_CHANGE_LINKIFICATION=yes
120 ;;
121 # *)
122 # In other modes we don't need to do anything
123 # because we didn't take any action in the prerm
124 esac
125
126 if [ "$TIME_TO_CHANGE_LINKIFICATION" = yes ] ; then
127 db_get resolvconf/linkify-resolvconf
128 if [ "$RET" = "true" ] ; then
129 # Back up
130 if \
131 [ -f /etc/resolv.conf ] \
132 && { \
133 [ ! -L /etc/resolv.conf ] \
134 || [ ! "$(readlink /etc/resolv.conf)" = "/etc/resolvconf/run/resolv.conf" ] ; \
135 }
136 then
137 if [ ! -e /etc/resolvconf/resolv.conf.d/original ] ; then
138 cp -a /etc/resolv.conf /etc/resolvconf/resolv.conf.d/original
139 else
140 cp -a /etc/resolv.conf /etc/resolv.conf.dpkg-old
141 fi
142 # Before creating the link, make sure that the original file is
143 # at the target of the link. /sbin/resolvconf will overwrite
144 # this when it runs, of course.
145 if [ ! -e /etc/resolvconf/run/resolv.conf ] ; then
146 cp -a /etc/resolv.conf /etc/resolvconf/run/resolv.conf
147 fi
148 fi
149
150 # Create the link
151 ln -nsf /etc/resolvconf/run/resolv.conf /etc/resolv.conf
152
153 fi
154 fi
155
156 db_stop
157
158 ### Enable updates ###
159 if [ -x "/etc/init.d/resolvconf" ] ; then
160 if which invoke-rc.d >/dev/null 2>&1 ; then
161 invoke-rc.d resolvconf enable-updates || :
162 else
163 /etc/init.d/resolvconf enable-updates
164 fi
165 fi

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5