File: debian-edu-profile

package info (click to toggle)
debian-edu-install 1.821
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 1,164 kB
  • sloc: sh: 1,327; makefile: 101
file content (575 lines) | stat: -rwxr-xr-x 18,111 bytes parent folder | download | duplicates (2)
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
#!/bin/sh -e

. /usr/share/debconf/confmodule
. /lib/preseed/preseed.sh # for $logfile
. /lib/debian-edu-common

log() {
    logger -t debian-edu-profile "info: $*"
}

error() {
    logger -t debian-edu-profile "error: $*"
}

add_preseed() {
    owner="$1"
    template="$2"
    type="$3"
    value="$4"
    echo $owner $template $type "$value" >> $preseedfile
}

ask_can_we_erase_harddrive() {
    # ask if the user want to repartition the hard drives
    # automaticaly, if not we will skip to manual mode
    db_settitle debian-edu-install/confirm/title
    db_input critical "debian-edu-install/confirm" || true
    db_go || true
    db_get "debian-edu-install/confirm" || true
    AUTOPARTITIONING="$RET"
    if test "$RET" = true ; then
        log "User accepted wiping out the harddrive"
    else
        log "User refused wiping out the harddrive, enabling manual partitioning"
    fi
}

ask_about_popcon() {
    #ask and preseed popcon here to save the need to monitor the install
    RET=""
    db_settitle debian-edu-install/participate-popcon/title
    db_input critical "debian-edu-install/participate-popcon" || true
    log "do we want popcon?"
    db_go || true 
    db_get "debian-edu-install/participate-popcon" || true
    if test "$RET" = true ; then
	add_preseed popularity-contest popularity-contest/participate boolean true
	log "popcon: yes!"
    elif test "$RET" = false ; then
	add_preseed popularity-contest popularity-contest/participate boolean false
	log "popcon: no!"
    fi
}

check_profiles() {
    preseed=
    #if a value is unset it breaks the case esac later on
    workstation=false
    roaming=false
    ltspserver=false
    server=false
    networked=false
    standalone=false
    minimal=false

    for value in `echo $EDUPROFILE |sed 's/ /-/g' | sed 's/,-/ /g'`; do
	case $value in
	    Workstation)
		networked=true
		workstation=true
		log "Added task '$value'"
		;;
	    Roaming-Workstation)
		# Partition as Standalone, preseed as workstation
		networked=true
		workstation=true
		roaming=true
		if test "$server" = true ; then
		    error=true
		else
		    error=
		fi
		log "Added task '$value'"
		;;
	    Thin-Client-Server)
		networked=true
		workstation=true
		ltspserver=true
		log "Added task '$value'"
		;;
	    Main-Server|Server)
		networked=true
		server=true
		log "Added task '$value'"
		;;
	    Standalone)
		standalone=true
		if test "$networked" = true ; then
		    error=true
		else
		    error=
		fi
		log "Added task '$value'"
		;;
	    Minimal)
		networked=true
		minimal=true
		log "Added task '$value'"
		;;
	    *)
		error "unknown profile '$value'"
		;;
	esac
    done
}

# Return the number of non-wireless network interfaces
non_wifi_iface_count() {
    count=0
    for iface in $(ip -o link | grep '^.: eth'|cut -d: -f2) ; do
	if [ -d /sys/class/net/$iface/wireless ] ; then
	    :
	else
	    count=$(($count + 1))
	fi
    done
    echo $count
}

AUTOPARTITIONING=false

#Detect debian-edu-expert mode
#Treat an expert install as a debian-edu-expert mode
if grep -iq debian-edu-expert /proc/cmdline ; then
   expert=true
elif grep -iq 'priority=low' /proc/cmdline ; then
   expert=true
else
   expert=false
fi

template="debian-edu-install/profile"

preseedfile=/tmp/debian-edu-preseed.$$
touch $preseedfile

# Preselect based on what we can detect from the environment.  If no
# main-server is found, select main-server for non-laptops and
# standalone for laptops.  If a main-server is detected select
# workstation for non-laptops, and roaming-workstation for laptops.
# If more than one network interface is detected, preselect
# Thin-Client-Server for non-laptops.
if wget http://tjener/debian-edu-install.dat > /dev/null 2>&1 ; then
    log "main-server detected on the network"
    if laptop-detect ; then
	log "laptop detected, preselecting roaming workstation"
	defaultprofile="Roaming-Workstation"
	laptop=true
    else
	defaultprofile="Workstation"
    fi
else
    log "main-server not detected on the network"
    if laptop-detect ; then
	log "laptop detected, preselecting standalone"
	defaultprofile="Standalone"
	laptop=true
    else
	defaultprofile="Main-Server, Thin-Client-Server, Workstation"
	mainserver=true
    fi
fi

if [ true != "$mainserver" ] && [ true != "$laptop" ] \
    && [ 1 -lt $(non_wifi_iface_count) ] ; then
    log "several network cards detected, preselecting thin-client-server"
    defaultprofile="$defaultprofile, Thin-Client-Server"
fi

log "choosing profile"

# Do not load our default if the value was preseeded
if db_fget "$template" seen && [ "$RET" = "false" ]; then
    log "Setting default profile to $defaultprofile"
    db_set "$template" "$defaultprofile"
fi

#ask profile question
log "Debian-edu-expert = $expert"

RET=""
looplimit="xxx"
loopcount=""

while test -z "$RET" ; do
    db_input critical "$template"  || [ $? -eq 30 ]
    db_go || true
    db_fset "$template" seen false || true

    db_get "$template" || true
    loopcount="x$loopcount"
    if test "$loopcount" = "$looplimit" ; then
	exit 1;
    fi
done
EDUPROFILE=$RET
log "full profile is '$EDUPROFILE' loopcount='$loopcount'"


check_profiles

while test -n "$error" ; do
	db_fset "debian-edu-install/standalone_only" seen false || true
	db_input critical "debian-edu-install/standalone_only" || true
	log "Wrong selection in combination with Standalone"
	db_go || true
	if test "$expert" = true ; then
		template="debian-edu-install/profile-expert"
	else
		template"debian-edu-install/profile"
	fi
	db_fset "$template" seen false || true
    	db_input critical "$template"  || [ $? -eq 30 ]
    	db_go || true

    	db_get "$template" || true
    	loopcount="x$loopcount"
    	if test "$loopcount" = "$looplimit" ; then
    	    exit 1;
    	fi
	if test -z "$RET" ; then
		continue;
	fi
	EDUPROFILE=$RET
	log "full profile is '$EDUPROFILE' loopcount='$loopcount'"
	check_profiles
done

# Make sure the default values have this priority, with lower number
# priority overriding higher number
#  1 main-server
#  2 thin-client-server
#  3 workstation
#  4 networked (Common for non-standalone)
#  5 standalone
#  6 common

preseeds="common"

if test "$standalone" = true ; then
    preseeds="$preseeds standalone"
fi
if test "$networked" = true ; then
    preseeds="$preseeds networked"
fi
if test "$workstation" = true ; then
    preseeds="$preseeds workstation"
fi
if test "$ltspserver" = true ; then
    preseeds="$preseeds thin-client-server"
fi
if test "$server" = true ; then
    preseeds="$preseeds main-server"
fi

#
# Select partitioning template (partman recipe), based on which
# profile is selected
#

#use first available disk no matter what ?

automatic_partitioning() {
    log "Using automatic_partitioning"
    arch=$(/bin/archdetect | cut -d"/" -f1)
    subarch=$(/bin/archdetect | cut -d"/" -f2)
    log "Detected arch : $arch"
    log "Detected subarch : $subarch"

    case "$arch-$subarch" in
	    "i386-generic") #unset both use the default
		arch=
		subarch=
	;;
	    "powerpc-powermac_newworld") #set 
	    	arch=-powerpc
		subarch=-powermac_newworld
	;;
	    "powerpc-prep") #set 
	    	arch=-powerpc
		subarch=-prep
	;;
	    *)	#just in case
		arch=
		subarch=
	;;    
    esac

    case "$server-$workstation-$ltspserver-$standalone-$minimal-$roaming" in
    "true-false-false-false-false-false") # single main server
        log "Preseeding partman for Single Main-server"
        db_set "partman-auto/choose_recipe" Debian-Edu Main-Server
        db_set "partman-auto/expert_recipe_file" /lib/partman/recipes$arch$subarch/90edumain
        ;;
    "false-true-true-false-false-false") # single ltspserver
        log "Preseeding partman for Single Thin-Client-Server"
        db_set "partman-auto/choose_recipe" Debian-Edu Thin-Client-Server
        db_set "partman-auto/expert_recipe_file" /lib/partman/recipes$arch$subarch/94edultsp

        # Configure the enable-nat script from debian-edu-config to
        # enable NAT on Thin-Client-Servers but not on Combi-Servers
        add_preseed debian-edu-config debian-edu-config/enable-nat boolean true
        ;;
    "false-true-false-false-false-false") # single workstation
        log "Preseeding partman for Single Workstation"
        db_set "partman-auto/choose_recipe" Debian-Edu Workstation
        db_set "partman-auto/expert_recipe_file" /lib/partman/recipes$arch$subarch/96eduwork
        ;;
    "false-true-false-false-false-true") # roaming workstatoin
        log "Preseeding partman for Single Roaming Workstation, select 98edustandalone recipe as default."
        db_set "partman-auto/choose_recipe" Debian-Edu Standalone
        db_set "partman-auto/expert_recipe_file" /lib/partman/recipes$arch$subarch/98edustandalone
        ;;
    "true-false-true-false-false-false") #mainserver & ltspserver
        log "Preseeding partman for Combo Main-server and Thin-Client-Server"
        db_set "partman-auto/choose_recipe" Debian-Edu Main-Server and Thin-Client-Server
        db_set "partman-auto/expert_recipe_file" /lib/partman/recipes$arch$subarch/91edumain+ltsp

        # Configure slbackup here in case we have a combo server installation
        add_preseed slbackup slbackup/client_location string "/etc /skole/tjener/home0 /opt/ltsp/i386/etc /var/backups"
        ;;
    "true-true-false-false-false-false") # mainserver & workstation
        log "Preseeding partman for Combo Main-Server and Workstation"
        db_set "partman-auto/choose_recipe" Debian-Edu Main-Server and Workstation
        db_set "partman-auto/expert_recipe_file" /lib/partman/recipes$arch$subarch/92edumain+ws
        ;;
    "true-true-true-false-false-false") # mainserver & ltspserver & workstation
        log "Preseeding partman for Combo Main-server, Thin-Client-Server, and workstation"
        db_set "partman-auto/choose_recipe" Debian-Edu Main-Server and Thin-Client-Server
        db_set "partman-auto/expert_recipe_file" /lib/partman/recipes$arch$subarch/91edumain+ltsp

        ;;
    "false-false-false-true-false-false") # standalone
        log "Preseeding partman for Single Standalone, select 98edustandalone recipe as default."
        db_set "partman-auto/choose_recipe" Debian-Edu Standalone
        db_set "partman-auto/expert_recipe_file" /lib/partman/recipes$arch$subarch/98edustandalone
        ;;
    "false-false-false-false-true-false") # minimal
        log "Preseeding partman for Minimal"
        db_set "partman-auto/choose_recipe" Debian-Edu Minimal
        db_set "partman-auto/expert_recipe_file" /lib/partman/recipes$arch$subarch/97minimal
        ;;
   esac

   # set recipe selection to seen
   db_fset "partman-auto/choose_recipe" seen true || true
   db_set "partman-auto-lvm/new_vg_name" vg_system

   # we dont want to see this
   db_set "partman/choose_partition" "Finish partitioning and write changes to disk"
   db_fset "partman/choose_partition" seen true || true

   # use first available disk
   # Disable in order to not lock up the installer, untill it's
   # reliable [Ronny Aasen 20080201]
   #db_set "partman-auto/disk" /dev/discs/disc0/disc
   #and method lvm 
   db_set "partman-auto/method" lvm
   db_fset "partman-auto/method" seen true || true

   # This question is asked when there are more than one disk found.
   # Ensure the correct answer is set.
   db_set "partman-auto/init_automatically_partition" "60some_device_lvm__________lvm"
   db_fset "partman-auto/init_automatically_partition" seen true || true

   add_preseed partman-lvm partman-lvm/confirm boolean true
   add_preseed partman-lvm partman-lvm/confirm_nooverwrite boolean true

   # we do not want to see the confirm write to disk, or the purge lvm
   # questions. We have asked this already
   add_preseed partman partman/confirm_write_new_label boolean true
   add_preseed partman partman/confirm boolean true
   add_preseed partman partman/confirm_nooverwrite boolean true
   add_preseed partman-lvm partman-lvm/device_remove_lvm boolean true
}

ask_can_we_erase_harddrive

if [ true = "$AUTOPARTITIONING" ] ; then
    automatic_partitioning
fi

ask_about_popcon

# any server
case "$server" in
    "true") 
        # install exim4-daemon-heavy early. 
	db_set "base-installer/includes" "exim4-daemon-heavy"	
	;;
esac

# This code need to be executed here and pass the info found on to the
# prebaseconfig script, and not in the prebaseconfig script itself,
# because the CD is unmounted when the prebaseconfig script is running.

# Based on function from base-installer
set_mirror_info () {
    if [ -f /cdrom/.disk/base_installable ]; then
	PROTOCOL=file
	MIRROR=""
	DIRECTORY="/cdrom/"
	db_get cdrom/codename || true
	if [ "$RET" ] ; then
	    SUITE="$RET"
	else
	    SUITE=testing
	    error "Unable to find CD suite name"
	fi
    else
	mirror_error=""

	db_get mirror/protocol || mirror_error=1
	PROTOCOL="$RET"

	db_get mirror/$PROTOCOL/hostname || mirror_error=1
	MIRROR="$RET"

	db_get mirror/$PROTOCOL/directory || mirror_error=1
	DIRECTORY="$RET"

	if [ "$mirror_error" = 1 ] || [ -z "$PROTOCOL" ] || [ -z "$MIRROR" ]; then
	    error "Missing mirror settings.  Can not find DISTRIBUTION name."
	    return
	fi
    fi

    if db_get mirror/suite && [ "$RET" ] ; then
	SUITE=$RET
    fi
    # Find the distribution codename
    APTLISTDIR=/var/tmp
    mkdir -p $APTLISTDIR
    if [ file = "$PROTOCOL" ]; then
	path="/cdrom/dists/$SUITE/Release"
	cp $path $APTLISTDIR/tmp 2>/dev/null || nogetrel="$path"
    else
	path="$PROTOCOL://$MIRROR$DIRECTORY/dists/$SUITE/Release"
	wget -q "$path" -O $APTLISTDIR/tmp || nogetrel="$path"
    fi

    if [ "$nogetrel" != "" ]; then
	error "Unable to locate '$nogetrel'.  Can not find DISTRIBUTION name."
	return
    fi

    DISTRIBUTION=`grep ^Codename: $APTLISTDIR/tmp | cut -d' ' -f 2`
    rm $APTLISTDIR/tmp
    db_set mirror/distribution "$DISTRIBUTION"
    log "Setting mirror/distribution to $DISTRIBUTION"
}

load_proxy_conf
set_mirror_info

if edu-is-testinstall ; then
   de_suite="$DISTRIBUTION-test"
else
   de_suite="$DISTRIBUTION"
fi

db_register debian-installer/dummy apt-setup/local0/repository
db_register debian-installer/dummy apt-setup/local0/comment
db_register debian-installer/dummy apt-setup/local0/source
db_register debian-installer/dummy apt-setup/local0/key

archstr=$(/bin/archdetect)
if [ -f /cdrom/.disk/cd_type ] && egrep -iq 'dvd|bluray' /cdrom/.disk/cd_type; then
    #disable mirror usage if we install from dvd or the usb sticks
    db_set "apt-setup/use_mirror" false 
    db_fset "apt-setup/use_mirror" seen true || true
    log "disabling mirror selection on dvd's"
    # Make sure it is disabled
    db_set "apt-setup/local0/comment" "" || true
    db_set "apt-setup/local0/repository" "" || true
    db_set "apt-setup/local0/source" true || true

elif ! log-output wget -U "Wget, Debian Edu d-i $de_suite $archstr" -qO - http://ftp.skolelinux.org/welcome.msg ; then
    db_settitle debian-edu-install/no-network/title
    db_input critical "debian-edu-install/no-network" || true
    db_go || true
    exit 1
else
    #Enable mirrors for the rest
    log "We will have net, enable the mirrors"
    db_set "apt-setup/use_mirror" true
    db_fset "apt-setup/use_mirror" seen true || true
    #preseed  skolelinux repo active
    db_set "apt-setup/local0/comment" "Debian Edu $de_suite repository" || true
    db_set "apt-setup/local0/repository" "http://ftp.skolelinux.org/skolelinux $de_suite local" || true
    db_set "apt-setup/local0/source" true || true
    #key must be available, if not apt-setup ignores our repo. 
    db_set "apt-setup/local0/key" "http://ftp.skolelinux.org/pub/debian-edu-archive.key" || true
fi




log "Preseeding"

if [ "$EDUPROFILE" ] ; then
   log "Preseeding target with '$EDUPROFILE'"
   add_preseed debian-edu-install debian-edu-install/profile multiselect "$EDUPROFILE"
else
   log "No profile to preseed"
fi

# In order to show less questions in the rest of the installation, we
# change debconf/priority to critical if the installer is run in the
# default manner.
# Do not mess with priority if the user have defined a priority in the
# boot arguments.
if grep -iq 'priority' /proc/cmdline ; then
    return 0
else
    # Do not mess with priority if the user runs in expert mode.
    if [ false = "$expert" ] ; then
        # Check if it runs at default value, and bump if it does. 
        if db_get debconf/priority && [ "$RET" ] ; then
	    if [ $RET == "high" ] ; then db_set "debconf/priority" "critical"; fi
        fi
    fi
fi


for preseed in $preseeds ; do
    if [ -f /usr/lib/debian-edu-install/defaults.$preseed ] ; then
        log "Found preseeding for '$preseed'"
        cat /usr/lib/debian-edu-install/defaults.$preseed >> $preseedfile
    else
        error "Unable to find preseeding for '$preseed'"
    fi
done

# Enable the firstboot script to report installation errors.  Preseeded
# here and not in defaults.common to make sure it only is set on first time
# installation using debian-installer.  Checking the seen flag to allow
# this setting to be overriden using preseeding.
db_fget debian-edu-install/run-firstboot seen || true
if [ true != "$RET" ] ; then
    add_preseed debian-edu-install debian-edu-install/run-firstboot boolean true
fi

# Load into the cdebconf database used by d-i
debconf-set-selections $preseedfile || \
    error "Failed to load preseed values from $preseedfile"

# Get the post-base-installer.d fragment from preseed to pass relevant
# values into the debconf database in /target when the base system is
# installed.
touch $logfile # Create if missing, to make sure >> work
cat $preseedfile >> $logfile

# rm $preseedfile

# Make sure that the kernel question doesn't show up.  Can not use
# preseeding directly, as these values are not loaded yet when this
# script run.
db_fset "base-installer/kernel/image" seen true || true
db_fset "base-installer/kernel/which-kernel" seen true || true

# Avoid message which sometimes appears with newer x11-common due to
# upgrade issues.  Can not use preseeding directly, as these values
# are not loaded yet when this script run.
db_fset "x11-common/upgrade_issues" seen true || true