File: postinst

package info (click to toggle)
bind 1%3A8.1.2-3
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 5,072 kB
  • ctags: 7,956
  • sloc: ansic: 54,480; sh: 6,937; makefile: 2,900; yacc: 1,223; perl: 315; lex: 221; awk: 45; sed: 15
file content (225 lines) | stat: -rw-r--r-- 4,625 bytes parent folder | download
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
#!/bin/sh -e
#
# Debian package postinst
# Version 1.2
#
# Robert Leslie <rob@mars.org>

case "$1" in
    configure)
	# continue below
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
	exit 0
    ;;

    *)
	echo "postinst called with unknown argument \`$1'" >&2
	exit 0
    ;;
esac

# Make sure we're running a kernel >= 1.3.56
set -- $(uname -r | sed -e 's/\./ /g' -e 's/-.*$//')
if [ `expr $1 '*' 100000 + $2 '*' 1000 + $3` -lt 103056 ]
then
    echo "Warning: BIND requires kernel 1.3.56 or later."
    echo "You will probably encounter problems unless or until you upgrade."
    echo -n "Press [ENTER] "
    read line
fi

umask 022

update-rc.d bind defaults 19 >/dev/null

# Make sure we have a good /etc/named.boot

test ! -L /etc/named.boot || rm -f /etc/named.boot

if [ -e /etc/named.boot ]
then
    echo "Moving your /etc/named.boot to /var/named and leaving a symlink ..."
    mv -vi /etc/named.boot /var/named/named.boot.old
fi

ln -s ../var/named/named.boot /etc/named.boot

# Handle named.boot configuration

cd /var/named

# Ensure a named.boot file exists

test -e named.boot || cat >named.boot <<EOF
;
; Boot file for name server
;

directory /var/named

; type		domain			source		file
cache		.					named.root

; Zone boot information and daemon options are kept in other files

include boot.zones
include boot.options
EOF

if [ -f named.boot.old ]
then
    cat <<EOF

This version of the Debian bind package uses a special arrangement of files
in /var/named that makes it easy to modify your configuration using the
included \`bindconfig' utility. Would you like your existing files to be
EOF
    echo -n "automatically converted to use the new arrangement? [Y] "
    read yn
    test -n "$yn" || yn="Y"

    case "$yn" in
	[Nn]*)
	    echo ""
	    echo "Okay, leaving your named.boot in place."  \
		"You will not be able to use"
	    echo "\`bindconfig' to adjust your configuration."

	    mv -f named.boot.old named.boot
	;;

	*)
	    cat <<EOT

Your named.boot file is being restructured as follows:

  /var/named/named.boot.old   - your original named.boot
  /var/named/named.boot       - new file; should not be modified
  /var/named/boot.options     - named options file; you may modify some
  /var/named/boot.zones       - named zone configurations; you may modify all
EOT

	    (
		echo "; Please run \`bindconfig' to configure this file" >&4
		echo "" >&4

		while read line
		do
		    set -- `echo "$line" | tr A-Z a-z`
		    test $# -gt 0 || { echo "" >&3; continue; }

		    case "$1" in
			directory|cache)
			    continue
			;;

			primary)
			    if [ "localhost" = "$2" -o  \
				"0.0.127.in-addr.arpa" = "$2" -o  \
				"127.in-addr.arpa" = "$2" ]
			    then
				echo "$line" >&4
			    else
				echo "$line" >&3
			    fi
			;;

			\;*|secondary)
			    echo "$line" >&3
			;;

			*)
			    echo "$line" >&4
			;;
		    esac
		done

		echo "" >&4
		echo ";; Custom configurations may appear below"  \
		    "(will be preserved)" >&4
	    ) <named.boot.old 3>boot.zones 4>boot.options

#	    mv -f named.boot.old named.boot.old

	    bindconfig --no-reload
	;;
    esac
elif [ -f boot.options ]
then
    if grep -qi '0\.0\.127\.in-addr\.arpa' boot.options
    then
	sed -e '/primary.*named\.rev-local/s/0\.0\.127/127/'  \
	    boot.options > boot.options.new
	mv -f boot.options.new boot.options
    fi

    echo -n "Examine or modify your existing BIND configuration? [N] "
    read yn
    test -n "$yn" || yn="N"

    case "$yn" in
	[Yy]*)
	    bindconfig --no-reload
	;;
    esac
else
    bindconfig --no-reload
fi

# Verify /etc/resolv.conf contains a local resolver

if [ -f /etc/resolv.conf ] &&  \
    ! grep -q 'nameserver.*127\.0\.0\.1' /etc/resolv.conf
then
    cat <<EOF

To be most effective, /etc/resolv.conf should list the IP address of your
local machine (127.0.0.1) as a nameserver. It currently does not.

EOF

    echo -n "Would you like this to be added? [Y] "
    read yn
    test -n "$yn" || yn="Y"

    case "$yn" in
	[Yy]*)
	    trap "rm -f /etc/resolv.conf.new" 0
	    exec 3>/etc/resolv.conf.new
	    echo "nameserver 127.0.0.1" >&3
	    cat /etc/resolv.conf >&3
	    exec 3>&-
	    mv -f /etc/resolv.conf.new /etc/resolv.conf
	    trap - 0
	;;
    esac
fi

# Create /etc/named.conf from named.boot, if none exists...

if [ ! -f /etc/named.conf ]
then
    named-bootconf
fi

# Start server

echo -n "Start nameserver daemon now? [Y] "
read yn
test -n "$yn" || yn="Y"

case "$yn" in
    [Nn]*)
	echo "Not started; to start later, do: /etc/init.d/bind start"
	echo -n "Press [ENTER] "
	read line
    ;;

    *)
	/etc/init.d/bind start
    ;;
esac

exit 0