File: pre-pkgsel

package info (click to toggle)
debian-edu-install 1.519
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,076 kB
  • ctags: 54
  • sloc: sh: 1,343; makefile: 169
file content (317 lines) | stat: -rwxr-xr-x 8,549 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
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
#!/bin/sh -e

. /usr/share/debconf/confmodule

log() {
    logger -t edu-pre-pkgsel "info: $*"
}

error() {
    logger -t edu-pre-pkgsel "error: $*"
}

setup_tasksel_overrides() {
    # Modify tasksels desktop test so the normal Debian desktop
    # profiles are not installed. Use dpkg-divert to to switch to our
    # version
    sed -e 's/if desktop_hardware/# Do not install a desktop - added by debian-edu-install\nunmark\n\n&/' \
	< /target/usr/lib/tasksel/tests/desktop \
	> /target/usr/lib/tasksel/tests/desktop.edu
    chmod 755 /target/usr/lib/tasksel/tests/desktop.edu
    chroot /target dpkg-divert --package debian-edu-install --rename --quiet \
	--add /usr/lib/tasksel/tests/desktop
    ln -s ./desktop.edu /target/usr/lib/tasksel/tests/desktop

    # And for the standard system task too
    sed -e 's/^case/# Do not install standard system task - added by debian-edu-install\nexit 3\n\n&/' \
	< /target/usr/lib/tasksel/tests/new-install \
	> /target/usr/lib/tasksel/tests/new-install.edu
    chmod 755 /target/usr/lib/tasksel/tests/new-install.edu
    chroot /target dpkg-divert --package debian-edu-install --rename --quiet \
	--add /usr/lib/tasksel/tests/new-install
    ln -s ./new-install.edu /target/usr/lib/tasksel/tests/new-install
}

configure_network() {
# Write a functional /target/etc/network/interfaces
    if [ -z "$PROFILE" ]; then
	PROFILE=Workstation
    fi

    # Default hostname is 'localhost'
    HOSTNAME=localhost

    # Default DNS server is tjener.intern
    NAMESERVER=10.0.2.2

    DNSDOMAIN=intern
    MAILNAME=postoffice.intern

    interfaces=/target/etc/network/interfaces

    # Should it get the information from the netcfg package instead?
    eth0=dhcp
    autoeth0="auto eth0"
    eth1=dhcp
    autoeth1=

    # Hm, what if both server and workstation is choosen?  Choose the
    # server config for eth0.
    for value in `echo $PROFILE |sed 's/ /-/g' | sed 's/,-/ /g'`; do
	case $value in
	    Standalone)
 	        # Leave network configuration to network-manager on Standalone
		eth0=dhcp
		autoeth0="allow-hotplug eth0"
		eth1=dhcp
		autoeth1="allow-hotplug eth1"
		RUNXSERVER=true
		DNSDOMAIN=
		MAILNAME=
		;;
	    Workstation)
   	        # Use this unless Server also was choosen.
		if [ -z "$eth0" ] ; then
		    eth0=dhcp
		    autoeth0="auto eth0"
		fi
		RUNXSERVER=true
		;;
	    Main-Server)
 	        # Override for workstations combining as servers
		eth0=10.0.2.2:255.255.254.0:10.0.3.255:10.0.2.1
		HOSTNAME=tjener.intern
		NAMESERVER=127.0.0.1
		autoeth0="auto eth0"
		;;
	    Thin-Client-Server)
 	        # Use this unless Server also was choosen.
		if [ -z "$eth0" ] ; then
		    eth0=dhcp
		    autoeth0="auto eth0"
		fi
		eth1=192.168.0.254:255.255.255.0:192.168.0.255:none
		autoeth1="auto eth1"
		RUNXSERVER=true
		;;
	esac
    done
  
    # Every host need the loopback interface
    cat > $interfaces <<EOF
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
# This file was created by debian-edu-profile during the Debian installation

# The loopback interface
auto lo
iface lo inet loopback
EOF
    if [ "$DNSDOMAIN" ] && [ "$NAMESERVER" = "127.0.0.1" ] ; then
	cat >> $interfaces <<EOF
    dns-search $DNSDOMAIN
EOF
    fi

    for interface in eth0 eth1 ; do
	eval "ifinfo=\$$interface"
	eval "ifauto=\$auto$interface"
	case $ifinfo in
	    dhcp)
		cat >> $interfaces <<EOF

$ifauto
iface $interface inet dhcp
EOF

		;;
	    [0-9]*)
	        address=`echo $ifinfo | cut -d: -f1`
		netmask=`echo $ifinfo | cut -d: -f2`
		broadcast=`echo $ifinfo | cut -d: -f3`
		gateway=`echo $ifinfo | cut -d: -f4`
		cat >> $interfaces <<EOF

auto $interface
iface $interface inet static
    address $address
    netmask $netmask
    broadcast $broadcast
EOF
		if [ none != "$gateway" ] ; then
		    cat >> $interfaces <<EOF
    gateway $gateway
EOF
		fi
		cat >> $interfaces <<EOF
# The commented lines below is to be used if a DHCP server is in use
#iface $interface inet dhcp
EOF
		;;
	    *)
	        # Nothing to do?
	        ;;
	esac
    done
    (
	echo "127.0.0.1       localhost.localdomain localhost" 
	echo "::1             localhost       ip6-localhost ip6-loopback"
	echo "fe00::0         ip6-localnet"
	echo "ff00::0         ip6-mcastprefix"
	echo "ff02::1         ip6-allnodes"
	echo "ff02::2         ip6-allrouters"
	echo "ff02::3         ip6-allhosts"
    ) > /target/etc/hosts

    echo "$HOSTNAME" > /target/etc/hostname
    in-target /etc/init.d/hostname.sh start

    # Update hostname based on reverse DNS entry of current IP, unless
    # installing main-server.
    if echo $PROFILE | grep -q Main-Server ; then
	:
    else
	in-target /etc/init.d/update-hostname start
    fi

    # Avoid hardcoding entries on the clients, to make sure IP address
    # range can be changed on the clients by changing DHCP
    # configuration on the server.
    if [ "tjener.intern" = "$HOSTNAME" ] ; then
	(
	    echo
	    echo "10.0.2.2        tjener.intern tjener" 
	) >> /target/etc/hosts
    fi

    # Set /etc/mailname if it is missing
    if [ "$MAILNAME" ] && [ ! -f /target/etc/mailname ] ; then
	echo "$MAILNAME" > /target/etc/mailname
    fi

    # Make sure that the interfaces are there for the cfengine run if
    # network isn't already configured
    if route | grep -q default ; then
	log "Not restarting network, as it seem to be up already."
    else
	log "Restarting network to prepare for cfengine run."
	# Redirecting fd 3 as a workaround for skolelinux bug #1229.
	# make sure the redirecting happen inside the chroot, as
	# in-target need to talk to debconf.
	in-target /bin/sh -c "/etc/init.d/networking start 3> /dev/null" || true
    fi

    # Update hostname based on DHCP/DNS if enabled
    if [ -x /etc/init.d/update-hostname ] ; then
	in-target /etc/init.d/update-hostname start || true
    fi
}

set_kerberos_masterpwd() {
    if db_get passwd/root-password-crypted && [ "$RET" ] ; then
	log "No clear text root password, unable to pass it on as kerberos master"
    else
	db_get passwd/root-password
	file=/tmp/kerberos-masterpwd-preseed
	cat > $file <<EOF
debian-edu-config debian-edu-config/kdc-password password $RET
debian-edu-config debian-edu-config/kdc-password-again password $RET
EOF
	debconf-set-selections $file
	rm $file
    fi
}

db_get mirror/protocol || true
PROTOCOL="$RET"
if [ "$PROTOCOL" = "http" ]; then
    db_get mirror/http/proxy
    http_proxy="$RET" || true
    if [ "$http_proxy" ]; then
	export http_proxy
    fi
fi

db_get debian-edu-install/profile
PROFILE="$RET"

db_get debian-installer/language
LANGCODE="$RET"

db_get debian-installer/locale
LOCALE="$RET"

if [ ! -d /target/etc/debian-edu ] ; then
    if mkdir /target/etc/debian-edu ; then
        :
    else
        error "unable to create /target/etc/debian-edu"
    fi
fi

set_kerberos_masterpwd || true

# For the stable etch release, use '3.0r0 terra' as the version number
VERSION="$(cat /usr/lib/debian-edu-install/version || true)"
if [ -z "$VERSION" ] ; then
    error "missing /usr/lib/debian-edu-install/version, incomplete /etc/debian-edu/config created."
fi

(
    echo "# Generated by debian-edu-profile-udeb"
    echo "VERSION=\"$VERSION\""
    echo "PROFILE=\"$PROFILE\""
    echo "LANGCODE=\"$LANGCODE\""
    echo "LOCALE=\"$LOCALE\""
) >> /target/etc/debian-edu/config

if edu-is-testinstall ; then
    echo "TESTINSTALL=\"true\"" >> /target/etc/debian-edu/config
fi

edu-etcvcs commit

log "asking for a few extra packages to be installed"
# debian-edu-archive-keyring - our local archive keyring
# education-tasks            - education tasksel tasks
# debian-edu-install         - the debian-edu preseeding files
failed=""
for p in debian-edu-archive-keyring education-tasks debian-edu-install
do
    if apt-install $p ; then
	:
    else
	template=debian-edu-install/errors-pkg-installation
	db_subst $template PACKAGES "$p"
	db_fset $template seen false
	db_capb "" # Disable "Go Back" button
	db_settitle $template-title
	db_input critical $template || [ $? -eq 30 ]
	db_go
	db_capb backup
	reboot
    fi
done

edu-etcvcs commit

# Clean up file added in base-installer-late, now that
# debian-edu-config is installed (pulled in via debian-edu-install).
rm -f /target/etc/apt/apt.conf.d/90squid-di

setup_tasksel_overrides

edu-etcvcs commit

# Configure network also on DVDs to make sure cfengine find a working
# network.
configure_network

edu-etcvcs commit

hook=/target/usr/share/debian-edu-config/d-i/pre-pkgsel
if [ -x $hook ] ; then
    log "Running debian-edu-config pre-pkgsel hook"
    $hook
fi

exit 0