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 576 577 578 579 580 581
|
#!/bin/sh -e
. /usr/share/debconf/confmodule
. /lib/preseed/preseed.sh # for $logfile
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
#UGLY HACK
#using /cdrom/.disk/mkisofs to determine if it's lenny or lenny-test
if grep -iq '/lenny-test' /cdrom/.disk/mkisofs ; then
de_suite="lenny-test"
else
#what is a sane default ? using the old way
de_suite="lenny"
fi
template="debian-edu-install/profile"
if [ true = "$expert" ] ; then
template="debian-edu-install/profile-expert"
fi
log() {
logger -t profilechooser "info: $*"
}
log "choosing profile"
log "Debian-edu-expert = $expert"
RET=""
looplimit="xxx"
loopcount=""
#ask profile question
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'"
preseedfile=/tmp/debian-edu-preseed.$$
touch $preseedfile
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() {
tasksel=
preseed=
#if a value is unset it breaks the case esac later on
workstation=false
ltspserver=false
server=false
networked=false
standalone=false
minimal=false
sugar=false
for value in `echo $EDUPROFILE |sed 's/ /-/g' | sed 's/,-/ /g'`; do
case $value in
Workstation)
networked=true
workstation=true
tasksel="${tasksel:+$tasksel, }DebianEdu networked workstation packages"
log "Added task '$value'"
;;
Thin-Client-Server)
networked=true
workstation=true
ltspserver=true
tasksel="${tasksel:+$tasksel, }DebianEdu networked thin client server packages"
log "Added task '$value'"
;;
Main-Server|Server)
networked=true
server=true
tasksel="${tasksel:+$tasksel, }DebianEdu main server packages"
log "Added task '$value'"
;;
Sugar)
standalone=true
sugar=true
tasksel="${tasksel:+$tasksel, }The sugar desktop environment for education"
log "Added task '$value'"
;;
Standalone)
standalone=true
if test "$networked" = true ; then
error=true
else
error=
fi
tasksel="DebianEdu standalone workstation packages"
log "Added task '$value'"
;;
Minimal)
networked=true
minimal=true
tasksel="${tasksel:+$tasksel, }DebianEdu networked minimal packages"
log "Added task '$value'"
;;
*)
error "unknown profile '$value'"
;;
esac
done
}
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" in
"true-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") # 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") # 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
;;
"true-false-true-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") # 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") # 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") # standalone
log "Preseeding partman for Single Standalone, select no recipe they get to partition manualy."
db_set "partman-auto/choose_recipe" Debian-Edu Workstation
db_set "partman-auto/expert_recipe_file" /lib/partman/recipes$arch$subarch/96eduwork
;;
"false-false-false-false-true") # 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
db_set "partman-lvm/confirm" true
db_fset "partman-lvm/confirm" seen true || true
# we do not want to see the confirm write to disk, or the purge lvm questions. We have asked this already
db_set "partman/confirm_write_new_label" true || true
db_set "partman/confirm" true || true
db_fset "partman/confirm" seen true || true
db_set "partman-lvm/device_remove_lvm" true || true
db_fset "partman-lvm/device_remove_lvm" seen true || true
}
ask_can_we_erase_harddrive
if [ true = "$AUTOPARTITIONING" ] ; then
automatic_partitioning
fi
ask_about_popcon
# The latest version of languagechooser insert nb_NO instead of no_NO.
# nb_NO one is missing in Woody, so we rewrite it to no_NO. This is a
# workaround for debian bug #260873.
# This is a hack that should go away when nb_NO is available
# everywhere. [pere 2004-07-22]
# 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/"
SUITE=stable
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
log "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
cp /cdrom/dists/$SUITE/Release $APTLISTDIR/tmp || nogetrel="/cdrom/dists/$SUITE/Release"
else
if [ "$PROTOCOL" = "http" ]; then
db_get mirror/http/proxy
http_proxy="$RET" || true
if [ "$http_proxy" ]; then
export http_proxy
fi
fi
wget "$PROTOCOL://$MIRROR$DIRECTORY/dists/$SUITE/Release" -O $APTLISTDIR/tmp || nogetrel="$PROTOCOL://$MIRROR$DIRECTORY/dists/$SUITE/Release"
fi
if [ "$nogetrel" != "" ]; then
log "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"
}
set_mirror_info
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
archstr=$(/bin/archdetect)
if grep -iq dvd /cdrom/.disk/cd_type ; then
#disable mirror useage if we install from dvd
db_set "apt-setup/use_mirror" false
db_fset "apt-setup/use_mirror" seen true || true
log "disabling mirror selection on dvd's"
#preseed skolelinux repos commented
db_set "apt-setup/local0/comment" "Debian edu local repo" || true
db_set "apt-setup/local0/repository" "http://ftp.skolelinux.org/skolelinux/ $de_suite local" || true
db_set "apt-setup/local0/source" true || true
elif ! wget -U "Wget, Debian Edu d-i $de_suite $archstr" -qO - http://ftp.skolelinux.org/welcome.msg ; then
#disable mirror useage if network is unreachable
db_set "apt-setup/use_mirror" false
db_fset "apt-setup/use_mirror" seen true || true
log "disabling mirror selection because of no network"
#preseed skolelinux repos commented
db_set "apt-setup/local0/comment" "Debian edu local repo" || true
db_set "apt-setup/local0/repository" "http://ftp.skolelinux.org/skolelinux/ $de_suite local" || true
db_set "apt-setup/local0/source" true || true
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 local repo" || true
db_set "apt-setup/local0/repository" "http://ftp.skolelinux.org/skolelinux/ $de_suite local" || true
db_set "apt-setup/local0/source" true || true
fi
log "Preseeding"
# Code from laptop-detect version 0.13.6
# Inlining instead of using laptop-detect-udeb because of bug #488386
# The debian-edu-profile-udeb package need to depend on dmidecode-udeb
# to get this function working.
is_laptop() {
# Are we a mac?
if test -d /proc/pmu; then
batteries=$(grep Battery /proc/pmu/info | cut -f2 -d:)
if test "$batteries" -ne 0; then
$PRINTIT "We're a laptop (Mac: batteries found)" >&2;
return 0
fi
return 1
fi
if [ -r /dev/mem -a -x /usr/sbin/dmidecode ]; then
# dmidecode to grab the Chassis type
dmitype=$(dmidecode --string chassis-type)
if test "$dmitype" = "Notebook" || test "$dmitype" = "Portable"; then
$PRINTIT "We're a laptop (dmidecode returned $dmitype)" >&2
return 0
fi
# turn back on for debugging
#echo "$dmitype"
fi
# check for any ACPI batteries
/sbin/modprobe battery 2> /dev/null || true
if [ -d /sys/class/power_supply ]; then
if grep -q Battery /sys/class/power_supply/*/type 2>/dev/null; then
$PRINTIT "We're a laptop (ACPI batteries found)" >&2
return 0
fi
fi
# old interface:
if [ -d /proc/acpi/battery ]; then
results=`find /proc/acpi/battery -mindepth 1 -type d`
if [ ! -z "$results" ]; then
$PRINTIT "We're a laptop (ACPI batteries found)" >&2
return 0
fi
fi
# check for APM batteries. This sucks, because we'll only get a valid response
# if the laptop has a battery fitted at the time
if [ -f /proc/apm ]; then
battery=`awk '{print $6}' </proc/apm`
if [ "$battery" != "0xff" ] && [ "$battery" != "0x80" ]; then
$PRINTIT "We're a laptop (APM batteries found)" >&2
return 0
fi
fi
#probably not a laptop; return
return 1
}
# Activate our and Debians Laptop task if a laptop is detected
if is_laptop; then
log "Detected a laptop"
tasksel="${tasksel:+$tasksel, }Laptop, DebianEdu laptop packages"
else
log "Did not detect a laptop"
fi
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
if [ "$tasksel" ] ; then
log "Would preseed tasksel with '$tasksel'"
# Disabled while testing autoselection in tasksel
# add_preseed tasksel tasksel/first multiselect "$tasksel"
else
log "No tasksel to preseed"
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
log "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 || \
log "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
db_fset "base-installer/kernel/image" seen true || true
db_fset "base-installer/kernel/which-kernel" seen true || true
# Hide tune2fs to force parman-ext3 to use mkfs.ext3 and thus
# get -O resize_inode enabled in the file system.
if [ -x /sbin/tune2fs ]; then
mv /sbin/tune2fs /sbin/tune2fs.dontuse
fi
# I doubt it work to fset xserver-xorg and x11-common here, as it
# would only affect the d-i database and not the database in
# /target/. [pere 2006-09-25]
# Try to avoid the xserver questions which will be solved by
# xdebconfigurator later on
# Removed 2007-03-17 to see if it make a difference.
#db_fset "xserver-xorg/config/display/modes" seen true || true
# Avoid message which sometimes appears with newer x11-common
# due to upgrade issues
db_fset "x11-common/upgrade_issues" seen true || true
|