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

Contents of /resolvconf/trunk/debian/postinst

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (hide annotations) (download)
Tue Dec 13 09:45:09 2005 UTC (7 years, 5 months ago) by jdthood-guest
File size: 5404 byte(s)
resolvconf 1.33
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    
12     ### Disable rogue hook scripts ###
13     # This should be kept in sync with the config script
14    
15     db_get resolvconf/disable-bad-hooks
16     if [ "$RET" = "true" ] ; then
17     PERMITTED_TO_DISABLE_BAD_HOOKS=yes
18     else
19     PERMITTED_TO_DISABLE_BAD_HOOKS=""
20     fi
21    
22     is_active()
23     {
24     [ -s "$1" ] \
25     && [ -x "$1" ] \
26     && ! { \
27     [ "$(cat "$1" | wc --chars)" -lt 11 ] \
28     && [ "$(cat "$1")" = '#!/bin/sh' ] ; \
29     } \
30     && ! grep -q resolvconf "$1" > /dev/null
31     }
32    
33     case "$1" in
34     configure|reconfigure)
35     for F in /etc/ppp/ip-up.d/0dns-up \
36     /etc/ppp/ip-down.d/0dns-down \
37     /etc/ppp/ip-up.d/000usepeerdns \
38     /etc/ppp/ip-up.d/0xisp-dns \
39     /etc/ppp/ip-down.d/0xisp-dns
40     do
41     if is_active "$F" ; then
42     if [ "$PERMITTED_TO_DISABLE_BAD_HOOKS" = yes ] ; then
43     chmod ugo-x "$F"
44     else
45     report "Script $F must be disabled or deleted."
46     report "It is recommended that you do: chmod ugo-x $F"
47     fi
48     fi
49     done
50     ;;
51     # *)
52     # In other modes we don't need to do anything
53     # because we didn't take any action in the prerm
54     esac
55    
56     ### Create /etc/resolvconf/run ###
57     case "$1" in
58     configure|reconfigure)
59     # Unfortunately we can't keep state files in /var/run/ because
60     # resolvconf, as it must, initializes before networking does and
61     # /var/ can be on the network.
62     #
63     # Only use an existing symlink if it is canonicalizable
64     if [ -L /etc/resolvconf/run ] ; then
65     RUN_CANONICALPATH="$(readlink -f /etc/resolvconf/run || :)"
66     if [ -z "$RUN_CANONICALPATH" ] ; then
67     report_err "Deleting /etc/resolvconf/run symlink whose canonical path could not be determined"
68     rm -f /etc/resolvconf/run
69     fi
70     fi
71     # Delete it if it isn't a directory or a link to one
72     if [ -e /etc/resolvconf/run ] && [ ! -d /etc/resolvconf/run ] ; then
73     report_err "Deleting /etc/resolvconf/run which isn't a directory"
74     rm -f /etc/resolvconf/run
75     fi
76     # Now /etc/resolvconf/run is either
77     # * a directory, or
78     # * a symlink to a directory, or
79     # * a nonexistent (if you'll pardon the expression), or
80     # * a dangling but canonicalizable symlink
81     if [ -d /etc/resolvconf/run ] ; then
82     # It's a directory or a symlink to one
83     [ -d /etc/resolvconf/run/interface ] || mkdir -v /etc/resolvconf/run/interface
84     elif [ -L /etc/resolvconf/run ] ; then
85     # It's a dangling but canonicalizable symlink
86     mkdir -v "$RUN_CANONICALPATH"
87     mkdir -v "${RUN_CANONICALPATH}/interface"
88     else
89     # It's a nonexistent
90     # Use /dev/shm if possible
91     if \
92     [ -d /dev/shm ] \
93     && [ -w /dev/shm ] \
94     && [ -r /proc/mounts ] \
95     && grep -qs "^tmpfs[[:space:]]\+/dev/shm[[:space:]]\+tmpfs[[:space:]]\+\([^[:space:]]\+,\)\?rw" /proc/mounts \
96     && ! grep -qs '[[:space:]]/dev[[:space:]]devfs[[:space:]]' /proc/mounts \
97     && { [ -d /dev/shm/resolvconf ] || mkdir -v /dev/shm/resolvconf ; } \
98     && { [ -d /dev/shm/resolvconf/interface ] || mkdir -v /dev/shm/resolvconf/interface ; }
99     then
100     ln -s /dev/shm/resolvconf /etc/resolvconf/run
101     else
102     mkdir -v /etc/resolvconf/run
103     mkdir -v /etc/resolvconf/run/interface
104     fi
105     fi
106     ;;
107     # *)
108     # In other modes we don't need to do anything
109     # because we didn't take any action in the prerm
110     esac
111    
112    
113     case "$1" in
114     configure|reconfigure)
115     # Deleting the old runlevel config is unavoidable
116     # because there is currently no way in Debian
117     # to update the config iff it is still the factory default
118     update-rc.d -f resolvconf remove > /dev/null 2>&1
119     ;;
120     esac
121    
122     # We use dh_installinit with --no-start
123     #DEBHELPER#
124    
125     ### Link tail to original if appropriate ###
126     TIME_TO_CHANGE_TAIL_LINK=no
127     case "$1" in
128     configure|reconfigure)
129     TIME_TO_CHANGE_TAIL_LINK=yes
130     ;;
131     # *)
132     # In other modes we don't need to do anything
133     # because we didn't take any action in the prerm
134     esac
135    
136     if [ "$TIME_TO_CHANGE_TAIL_LINK" = yes ] ; then
137     if [ ! -e /etc/resolvconf/resolv.conf.d/tail ] ; then
138     db_get resolvconf/link-tail-to-original
139     if [ "$RET" = "true" ] ; then
140     ln -nsf original /etc/resolvconf/resolv.conf.d/tail
141     else
142     : > /etc/resolvconf/resolv.conf.d/tail
143     fi
144     fi
145     fi
146    
147     ### Linkify /etc/resolv.conf if appropriate ###
148     TIME_TO_CHANGE_LINKIFICATION=no
149     case "$1" in
150     configure|reconfigure)
151     TIME_TO_CHANGE_LINKIFICATION=yes
152     ;;
153     # *)
154     # In other modes we don't need to do anything
155     # because we didn't take any action in the prerm
156     esac
157    
158     if [ "$TIME_TO_CHANGE_LINKIFICATION" = yes ] ; then
159     db_get resolvconf/linkify-resolvconf
160     if [ "$RET" = "true" ] ; then
161     # Back up
162     if \
163     [ -f /etc/resolv.conf ] \
164     && { \
165     [ ! -L /etc/resolv.conf ] \
166     || [ ! "$(readlink /etc/resolv.conf)" = "/etc/resolvconf/run/resolv.conf" ] ; \
167     }
168     then
169     if [ ! -e /etc/resolvconf/resolv.conf.d/original ] ; then
170     cp -a /etc/resolv.conf /etc/resolvconf/resolv.conf.d/original
171     else
172     cp -a /etc/resolv.conf /etc/resolv.conf.dpkg-old
173     fi
174     # Before creating the link, make sure that the original file is
175     # at the target of the link. /sbin/resolvconf will overwrite
176     # this when it runs, of course.
177     if [ ! -e /etc/resolvconf/run/resolv.conf ] ; then
178     cp -a /etc/resolv.conf /etc/resolvconf/run/resolv.conf
179     fi
180     fi
181    
182     # Create the link
183     ln -nsf /etc/resolvconf/run/resolv.conf /etc/resolv.conf
184    
185     fi
186     fi
187    
188     ### Enable updates ###
189     /etc/init.d/resolvconf enable-updates
190    
191     db_stop
192    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5