· 8 years ago · Mar 05, 2018, 05:28 PM
1#!/bin/sh
2#
3# "SystemImager"
4#
5# $Id: autoinstallscript.template 3997 2007-03-25 10:58:50Z arighi $
6# vi:set filetype=sh:
7#
8# Copyright (C) 1999-2006 Brian Elliott Finley
9#
10# 28.07.2005 Erich Focht : SCSI device detection and generation of
11# /a/etc/systemconfig/hardware.lst
12#
13# David N. Lombard : Disks enumeration and disk editing
14#
15
16# This master autoinstall script was created with SystemImager v3.8.1
17
18# Pull in variables left behind by the linuxrc script.
19# This information is passed from the linuxrc script on the autoinstall media
20# via /tmp/variables.txt. Apparently the shell we use in BOEL is not
21# intelligent enough to take a "set -a" parameter.
22#
23. /tmp/variables.txt
24
25# Load functions and other variables
26. /etc/init.d/functions
27
28get_arch
29
30NO_LISTING=yes
31if [ -z $NO_LISTING ]; then
32 VERBOSE_OPT="v"
33else
34 VERBOSE_OPT=""
35fi
36
37[ -z $IMAGENAME ] && IMAGENAME=b-fc2-306-v2
38[ -z $OVERRIDES ] && OVERRIDES="b-fc2-306-v2 "
39
40### BEGIN Check to be sure this not run from a working machine ###
41# Test for mounted SCSI or IDE disks
42mount | grep [hs]d[a-z][1-9] > /dev/null 2>&1
43[ $? -eq 0 ] && logmsg Sorry. Must not run on a working machine... && shellout
44
45# Test for mounted software RAID devices
46mount | grep md[0-9] > /dev/null 2>&1
47[ $? -eq 0 ] && logmsg Sorry. Must not run on a working machine... && shellout
48
49# Test for mounted hardware RAID disks
50mount | grep c[0-9]+d[0-9]+p > /dev/null 2>&1
51[ $? -eq 0 ] && logmsg Sorry. Must not run on a working machine... && shellout
52### END Check to be sure this not run from a working machine ###
53
54
55################################################################################
56#
57# Stop RAID devices before partitioning begins
58#
59# Q1) Why did they get started in the first place?
60# A1) So we can pull a local.cfg file off a root mounted software RAID system.
61# They may not be started on your system -- they would only be started if
62# you did the stuff in Q3 below.
63#
64# Q2) Why didn't my local.cfg on my root mounted software RAID work for me
65# with the standard kernel flavour?
66# A2) The standard kernel flavour uses modules for the software RAID drivers --
67# therefore, software RAID is not available at the point in the boot process
68# where BOEL needs to read the local.cfg file. They are only pulled over
69# when this script is run, which is, of course, only runnable if it was
70# pulled over the network using the settings that you would have wanted it
71# to get from the local.cfg file, which it couldn't. Right?
72#
73# Q3) Whatever. So how do I make it work with a local.cfg file on my root
74# mounted software RAID?
75# A3) Compile an autoinstall kernel with software RAID, and any other drivers
76# you might need built in (filesystem, SCSI drivers, etc.).
77#
78if [ -f /proc/mdstat ]; then
79 RAID_DEVICES=` cat /proc/mdstat | grep ^md | sed 's/ .*$//g' `
80
81 # Turn dem pesky raid devices off!
82 for RAID_DEVICE in ${RAID_DEVICES}
83 do
84 DEV="/dev/${RAID_DEVICE}"
85 logmsg "mdadm --manage ${DEV} --stop"
86 mdadm --manage ${DEV} --stop
87 done
88fi
89#
90################################################################################
91# BEGIN disk enumeration
92#
93# Note the kludgey way to get /dev/sd* and /dev/*/c*d* to sort properly...
94#
95# Parse the correct file depending by the kernel release -AR-
96kernel=`uname -r | sed "s/^\(2\.[64]\).*/\1/"`
97if [ $kernel = "2.4" ]; then
98 diskfile=/proc/partitions
99else
100 diskfile=/proc/diskstats
101fi
102
103DISKORDER=
104
105[ -z $DISKORDER ] || {
106 logmsg enumerate_disks
107 order=`echo "$DISKORDER" | sed 's/ /,/g' | sed s/,,*/,/g | sed s/^,//`
108 DISKS=0
109 cdroms=`cat /proc/sys/dev/cdrom/info 2>/dev/null | sed -ne "s/^drive name:[[:space:]]*//p"`
110 while : ; do
111 [ -z $order ] && break
112 type=`expr $order : '\([^,]*\),' \| $order`
113 case $type in
114 cciss | ida | rd )
115 for dev in `cat $diskfile | sed -ne "s/.*\($type\\/c[0-9]d[0-9]\).*/\1/p" | sort -u` ; do
116 logmsg " $dev"
117 eval DISK$DISKS=/dev/${dev}
118 DISKS=`expr $DISKS + 1`
119 done
120 ;;
121 hd | sd )
122 for dev in `cat $diskfile | sed -ne "s/.*\($type[a-z]\+\).*/\1/p" | sort -u` ; do
123 skip=0
124 for cdrom in $cdroms; do
125 if [ "$dev" = "$cdrom" ]; then
126 skip=1
127 break
128 fi
129 done
130 if [ $skip -eq 0 ]; then
131 logmsg " $dev"
132 eval DISK$DISKS=/dev/${dev}
133 DISKS=`expr $DISKS + 1`
134 fi
135 done
136 ;;
137 * )
138 logmsg "type='$type'"
139 shellout
140 ;;
141 esac
142 order=`expr $order : '[^,]*,\(.*\)'`
143 done
144 logmsg DISKS=$DISKS
145 [ $DISKS -eq 0 ] && {
146 beep
147 beep
148 logmsg ""
149 logmsg "NO DISK DEVICE FILES WERE FOUND. THIS USUALLY MEANS THE KERNEL DID NOT"
150 logmsg "RECOGNIZE ANY OF THE ATTACHED DISKS."
151 logmsg ""
152 logmsg "The kernel boot messages, which preceded this, may indicate why."
153 logmsg ""
154 logmsg "Reverting to disk configuration specified by image master script."
155 DISKORDER=
156 logmsg ""
157 }
158 echo
159 beep
160}
161#
162# END disk enumeration
163################################################################################
164
165if [ -z $DISKORDER ] ; then
166 DISK0=/dev/sda
167elif [ -z $DISK0 ] ; then
168 echo "Undefined: DISK0"
169 shellout
170fi
171### BEGIN partition $DISK0 ###
172logmsg "Partitioning $DISK0..."
173logmsg "Old partition table for $DISK0:"
174parted -s -- $DISK0 print
175
176# Wipe the MBR (Master Boot Record) clean.
177logmsg "dd if=/dev/zero of=$DISK0 bs=512 count=1 || shellout"
178dd if=/dev/zero of=$DISK0 bs=512 count=1 || shellout
179
180# Re-read the disk label.
181logmsg "blockdev --rereadpt $DISK0"
182blockdev --rereadpt $DISK0
183
184# Create disk label. This ensures that all remnants of the old label, whatever
185# type it was, are removed and that we're starting with a clean label.
186logmsg "parted -s -- $DISK0 mklabel msdos || shellout"
187parted -s -- $DISK0 mklabel msdos || shellout
188
189# Get the size of the destination disk so that we can make the partitions fit properly.
190DISK_SIZE=`parted -s $DISK0 unit MB print | grep 'Disk geometry for' | sed 's/^.*-//g' | sed 's/\..*$//' | sed 's/MB//' `
191[ -z $DISK_SIZE ] && shellout
192if [ "$ARCH" = "alpha" ]; then
193 END_OF_LAST_PRIMARY=1
194else
195 END_OF_LAST_PRIMARY=0
196fi
197
198
199logmsg "Creating partition ${DISK0}1."
200START_MB=
201END_MB=$(echo "scale=3; ($START_MB + 81)" | bc)
202logmsg "parted -s -- $DISK0 mkpart ext3 $START_MB $END_MB || shellout"
203parted -s -- $DISK0 mkpart ext3 $START_MB $END_MB || shellout
204logmsg parted -s -- $DISK0 set 1 boot on || shellout
205parted -s -- $DISK0 set 1 boot on || shellout
206
207logmsg "Creating partition ${DISK0}2."
208START_MB=
209END_MB=$(echo "scale=3; ($START_MB + 108798)" | bc)
210logmsg "parted -s -- $DISK0 mkpart ext3 $START_MB $END_MB || shellout"
211parted -s -- $DISK0 mkpart ext3 $START_MB $END_MB || shellout
212
213logmsg "Creating partition ${DISK0}3."
214START_MB=
215END_MB=$(echo "scale=3; ($START_MB + 37936)" | bc)
216logmsg "parted -s -- $DISK0 mkpart linux-swap $START_MB $END_MB || shellout"
217parted -s -- $DISK0 mkpart linux-swap $START_MB $END_MB || shellout
218
219logmsg "New partition table for $DISK0:"
220logmsg "parted -s -- $DISK0 print"
221parted -s -- $DISK0 print
222### END partition $DISK0 ###
223
224
225if [ -z $DISKORDER ] ; then
226 DISK1=/dev/sdb
227elif [ -z $DISK1 ] ; then
228 echo "Undefined: DISK1"
229 shellout
230fi
231### BEGIN partition $DISK1 ###
232logmsg "Partitioning $DISK1..."
233logmsg "Old partition table for $DISK1:"
234parted -s -- $DISK1 print
235
236# Wipe the MBR (Master Boot Record) clean.
237logmsg "dd if=/dev/zero of=$DISK1 bs=512 count=1 || shellout"
238dd if=/dev/zero of=$DISK1 bs=512 count=1 || shellout
239
240# Re-read the disk label.
241logmsg "blockdev --rereadpt $DISK1"
242blockdev --rereadpt $DISK1
243
244# Create disk label. This ensures that all remnants of the old label, whatever
245# type it was, are removed and that we're starting with a clean label.
246logmsg "parted -s -- $DISK1 mklabel msdos || shellout"
247parted -s -- $DISK1 mklabel msdos || shellout
248
249# Get the size of the destination disk so that we can make the partitions fit properly.
250DISK_SIZE=`parted -s $DISK1 unit MB print | grep 'Disk geometry for' | sed 's/^.*-//g' | sed 's/\..*$//' | sed 's/MB//' `
251[ -z $DISK_SIZE ] && shellout
252if [ "$ARCH" = "alpha" ]; then
253 END_OF_LAST_PRIMARY=1
254else
255 END_OF_LAST_PRIMARY=0
256fi
257
258
259logmsg "Creating partition ${DISK1}1."
260START_MB=
261END_MB=$(echo "scale=3; ($START_MB + 146815)" | bc)
262logmsg "parted -s -- $DISK1 mkpart ext3 $START_MB $END_MB || shellout"
263parted -s -- $DISK1 mkpart ext3 $START_MB $END_MB || shellout
264
265logmsg "New partition table for $DISK1:"
266logmsg "parted -s -- $DISK1 print"
267parted -s -- $DISK1 print
268### END partition $DISK1 ###
269
270
271
272### BEGIN software-RAID initialization commands -AR- ###
273logmsg "Load software RAID modules."
274modprobe linear
275modprobe raid0
276modprobe raid1
277modprobe raid5
278modprobe raid6
279modprobe raid10
280### END software-RAID initialization commands ###
281
282logmsg "Load device mapper driver (for LVM)."
283modprobe dm-mod
284
285### BEGIN LVM initialization commands -AR- ###
286### END LVM initialization commands ###
287
288### BEGIN LVM groups creation commands -AR- ###
289### END LVM groups creation commands ###
290
291### BEGIN LVM volumes creation commands -AR- ###
292### END LVM volumes creation commands ###
293
294logmsg "Load additional filesystem drivers."
295modprobe ext2
296modprobe ext3
297modprobe fat
298modprobe jfs
299modprobe reiserfs
300modprobe vfat
301modprobe xfs
302
303### BEGIN swap and filesystem creation commands ###
304logmsg "mke2fs -q -j ${DISK0}2 || shellout"
305mke2fs -q -j ${DISK0}2 || shellout
306logmsg "mkdir -p /a/ || shellout"
307mkdir -p /a/ || shellout
308logmsg "mount ${DISK0}2 /a/ -t ext3 -o defaults || shellout"
309mount ${DISK0}2 /a/ -t ext3 -o defaults || shellout
310
311logmsg "mke2fs -q -j ${DISK0}1 || shellout"
312mke2fs -q -j ${DISK0}1 || shellout
313logmsg "mkdir -p /a/boot || shellout"
314mkdir -p /a/boot || shellout
315logmsg "mount ${DISK0}1 /a/boot -t ext3 -o defaults || shellout"
316mount ${DISK0}1 /a/boot -t ext3 -o defaults || shellout
317
318logmsg "mke2fs -q -j ${DISK1}1 || shellout"
319mke2fs -q -j ${DISK1}1 || shellout
320logmsg "mkdir -p /a/usr/local/blast/db || shellout"
321mkdir -p /a/usr/local/blast/db || shellout
322logmsg "mount ${DISK1}1 /a/usr/local/blast/db -t ext3 -o defaults || shellout"
323mount ${DISK1}1 /a/usr/local/blast/db -t ext3 -o defaults || shellout
324
325logmsg "mkswap -v1 ${DISK0}3 || shellout"
326mkswap -v1 ${DISK0}3 || shellout
327logmsg "swapon ${DISK0}3 || shellout"
328swapon ${DISK0}3 || shellout
329
330### END swap and filesystem creation commands ###
331
332### BEGIN mount proc in image for tools like System Configurator ###
333logmsg "mkdir -p /a/proc || shellout"
334mkdir -p /a/proc || shellout
335logmsg "mount proc /a/proc -t proc -o defaults || shellout"
336mount proc /a/proc -t proc -o defaults || shellout
337### END mount proc in image for tools like System Configurator ###
338
339if [ ! $kernel = "2.4" ]; then
340### BEGIN mount sysfs in image for tools that might be run during chroot ###
341logmsg "mkdir -p /a/sys || shellout"
342mkdir -p /a/sys || shellout
343logmsg "mount sysfs /a/sys -t sysfs -o defaults || shellout"
344mount sysfs /a/sys -t sysfs -o defaults || shellout
345### END mount sysfs in image for tools that might be run during chroot ###
346fi
347
348################################################################################
349#
350# Lay the image down on the freshly formatted disk(s)
351#
352if [ ! -z $MONITOR_SERVER ]; then
353 start_report_task
354fi
355
356if [ ! -z $FLAMETHROWER_DIRECTORY_PORTBASE ]; then
357
358 # Use multicast
359 MODULE_NAME="${IMAGENAME}"
360 DIR=/a
361 RETRY=7
362 FLAMETHROWER_TARPIPE=y
363 flamethrower_client
364 if [ ! -z $MONITOR_SERVER ]; then
365 stop_report_task 101
366 fi
367elif [ "x$BITTORRENT" = "xy" ]; then
368 # Use BitTorrent
369 if [ -f "${TORRENTS_DIR}/image-${IMAGENAME}.tar.gz.torrent" ]; then
370 bittorrent_tarball="image-${IMAGENAME}.tar.gz"
371 compress='z'
372 elif [ -f "${TORRENTS_DIR}/image-${IMAGENAME}.tar.torrent" ]; then
373 bittorrent_tarball="image-${IMAGENAME}.tar"
374 compress=''
375 else
376 logmsg "error: cannot find a valid torrent file for the image ${IMAGENAME}"
377 shellout
378 fi
379 # Evaluate the staging directory
380 if [ -z $BITTORRENT_STAGING ]; then
381 logmsg bittorrent_autodetect_staging_dir
382 BITTORRENT_STAGING=`bittorrent_autodetect_staging_dir ${TORRENTS_DIR}/${bittorrent_tarball}.torrent`
383 if [ -z $BITTORRENT_STAGING ]; then
384 logmsg ""
385 logmsg "error: cannot find a staging directory to save file: $bittorrent_tarball"
386 logmsg "Try to increase the size of a partition (like /tmp) in your patitioning schema"
387 logmsg "to fit the image into a staging directory."
388 logmsg ""
389 shellout
390 fi
391 logmsg "--> staging in: $BITTORRENT_STAGING"
392 fi
393 # Download image from peers
394 logmsg "Start downloading image using torrent ${bittorrent_tarball}.torrent"
395 logmsg ""
396 logmsg "--> INFO: remember to start /etc/init.d/systemimager-server-bittorrent on the image server!"
397 logmsg ""
398 bittorrent_get_file ${TORRENTS_DIR}/${bittorrent_tarball}.torrent ${BITTORRENT_STAGING}
399 if [ ! -z $MONITOR_SERVER ]; then
400 stop_report_task 101
401 fi
402 # Extract image.
403 logmsg "Extracting image from ${bittorrent_tarball} ..."
404 (cd /a/ && tar -x${VERBOSE_OPT}${compress}Spf ${BITTORRENT_STAGING}/${bittorrent_tarball} > /dev/console) || shellout
405
406 # Stop BitTorrent client.
407 bittorrent_stop
408 rm -f ${BITTORRENT_STAGING}/${bittorrent_tarball}
409 unset bittorrent_tarball
410else
411 # Use rsync
412 if [ $NO_LISTING ]; then
413 logmsg "Quietly installing image... "
414 start_spinner
415 fi
416 if [ "${TMPFS_STAGING}" = "yes" ]; then
417
418 # Deposit image into tmpfs
419 DIR=/tmp/tmpfs_staging
420 logmsg
421 logmsg "TMPFS_STAGING=${TMPFS_STAGING} -- Staging in ${DIR}"
422 mkdir -p ${DIR}
423
424 logmsg "rsync -aHS${VERBOSE_OPT} --exclude=lost+found/ --numeric-ids ${IMAGESERVER}::${IMAGENAME}/ ${DIR}/"
425 rsync -aHS${VERBOSE_OPT} --exclude=lost+found/ --exclude=/proc/* --numeric-ids \
426 ${IMAGESERVER}::${IMAGENAME}/ ${DIR}/ > /dev/console || shellout
427
428 if [ ! -z $MONITOR_SERVER ]; then
429 stop_report_task 101
430 fi
431
432 # Move from staging in tmpfs to disk
433 rsync -aHS${VERBOSE_OPT} --exclude=lost+found/ --numeric-ids ${DIR}/ /a/ > /dev/console || shellout
434 else
435 logmsg "rsync -aHS${VERBOSE_OPT} --exclude=lost+found/ --exclude=/proc/* --numeric-ids ${IMAGESERVER}::${IMAGENAME}/ /a/"
436 rsync -aHS${VERBOSE_OPT} --exclude=lost+found/ --exclude=/proc/* --numeric-ids ${IMAGESERVER}::${IMAGENAME}/ /a/ > /dev/console || shellout
437 if [ ! -z $MONITOR_SERVER ]; then
438 stop_report_task 101
439 fi
440 fi
441fi
442
443beep
444
445#
446################################################################################
447
448
449if [ $NO_LISTING ]; then
450 stop_spinner
451fi
452
453# Leave notice of which image is installed on the client
454echo $IMAGENAME > /a/etc/systemimager/IMAGE_LAST_SYNCED_TO || shellout
455
456### BEGIN generate new fstab file from autoinstallscript.conf ###
457cat <<'EOF' > /a/etc/fstab
458/dev/sda2 / ext3 defaults 1 1
459/dev/sda1 /boot ext3 defaults 1 2
460/dev/sdb1 /usr/local/blast/db ext3 defaults 0 0
461none /dev/pts devpts gid=5,mode=620 0 0
462none /dev/shm tmpfs defaults 0 0
463none /proc proc defaults 0 0
464none /sys sysfs defaults 0 0
465/dev/sda3 swap swap defaults 0 0
466bfmaster1:/home/nazo /home/nazo nfs defaults 0 0
467bfmaster1:/storage/mbshared /storage/mbshared nfs defaults 0 0
468bfmaster1:/storage/mail /var/spool/mail nfs defaults 0 0
469/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0
470EOF
471### END generate new fstab file from autoinstallscript.conf ###
472
473################################################################################
474#
475# Process override directories
476#
477for OVERRIDE in $OVERRIDES
478do
479 if [ ! -z $FLAMETHROWER_DIRECTORY_PORTBASE ]; then
480 # Use multicast
481 MODULE_NAME="override_${OVERRIDE}"
482 DIR=/a
483 RETRY=7
484 FLAMETHROWER_TARPIPE=y
485 flamethrower_client
486 elif [ "x$BITTORRENT" = "xy" ]; then
487 # Use BitTorrent
488 if [ -f "${TORRENTS_DIR}/override-${OVERRIDE}.tar.gz.torrent" ]; then
489 bittorrent_tarball="override-${OVERRIDE}.tar.gz"
490 compress='z'
491 elif [ -f "${TORRENTS_DIR}/override-${OVERRIDE}.tar.torrent" ]; then
492 bittorrent_tarball="override-${OVERRIDE}.tar"
493 compress=''
494 else
495 bittorrent_tarball=""
496 logmsg "warning: cannot find a valid torrent file for override ${OVERRIDE}"
497 fi
498 # Evaluate the staging directory
499 if [ ! -z $bittorrent_tarball ] && [ -z $BITTORRENT_STAGING ]; then
500 logmsg bittorrent_autodetect_staging_dir
501 BITTORRENT_STAGING=`bittorrent_autodetect_staging_dir ${TORRENTS_DIR}/${bittorrent_tarball}.torrent`
502 if [ -z $BITTORRENT_STAGING ]; then
503 logmsg "warning: cannot find a staging directory to save file: $bittorrent_tarball"
504 bittorrent_tarball=""
505 fi
506 logmsg "--> staging in: $BITTORRENT_STAGING"
507 fi
508 if [ ! -z $bittorrent_tarball ]; then
509 # Start downloading
510 logmsg "Start downloading override using torrent ${bittorrent_tarball}.torrent"
511 logmsg ""
512 logmsg "--> INFO: remember to start /etc/init.d/systemimager-server-bittorrent on the image server!"
513 logmsg ""
514 # Download override from peers
515 bittorrent_get_file ${TORRENTS_DIR}/${bittorrent_tarball}.torrent ${BITTORRENT_STAGING}
516 # Extract override.
517 logmsg "Extracting override from ${bittorrent_tarball} ..."
518 (cd /a/ && tar -x${VERBOSE_OPT}${compress}Spf ${BITTORRENT_STAGING}/${bittorrent_tarball} > /dev/console) || shellout
519 # Stop BitTorrent client.
520 bittorrent_stop
521 rm -f ${BITTORRENT_STAGING}/${bittorrent_tarball}
522 else
523 # Use rsync
524 logmsg "trying to download override ${OVERRIDE} with rsync..."
525 logmsg "rsync -av --numeric-ids $IMAGESERVER::overrides/$OVERRIDE/ /a/"
526 rsync -av --numeric-ids $IMAGESERVER::overrides/$OVERRIDE/ /a/ > /dev/console || logmsg "Override directory $OVERRIDE doesn't seem to exist, but that may be OK."
527 fi
528 unset bittorrent_tarball
529 else
530 # Use rsync
531 logmsg "rsync -av --numeric-ids $IMAGESERVER::overrides/$OVERRIDE/ /a/"
532 rsync -av --numeric-ids $IMAGESERVER::overrides/$OVERRIDE/ /a/ > /dev/console || logmsg "Override directory $OVERRIDE doesn't seem to exist, but that may be OK."
533 fi
534done
535
536beep
537
538#
539################################################################################
540
541################################################################################
542# BEGIN disk edits
543#
544[ -z $DISKORDER ] || {
545 echo "Editing files for actual disk configuration..."
546 echo " /dev/sda -> $DISK0"
547 echo " /dev/sdb -> $DISK1"
548 for file in /etc/fstab /etc/systemconfig/systemconfig.conf /boot/grub/menu.lst /etc/lilo.conf /etc/grub.conf; do
549 [ -f /a/$file ] || continue
550 echo " $file"
551 cp /a/$file /a/$file.image
552 cat /a/$file.image |
553 sed s:/dev/sdb:%DISK1%:g |
554 sed s:/dev/sda:%DISK0%:g |
555 sed s:%DISK0%:$DISK0:g |
556 sed s:%DISK1%:$DISK1:g |
557 cat > /a/$file
558 done
559 echo
560 beep
561}
562#
563# END disk edits
564################################################################################
565
566
567##################################################################
568#
569# Uncomment the line below to leave your hostname blank.
570# Certain distributions use this as an indication to take on the
571# hostname provided by a DHCP server. The default is to have
572# SystemConfigurator assign your clients the hostname that
573# corresponds to the IP address the use during the install.
574# (If you used to use the static_dhcp option, this is your man.)
575#
576#HOSTNAME=""
577
578
579################################################################################
580#
581# mount /dev /a/dev -o bind if needed
582#
583#not needed for this image
584#
585################################################################################
586
587
588################################################################################
589#
590# Detect scsi hardware and include the device IDs into the hardware.lst
591# file used by systemconfigurator. Do nothing if the hardware.lst file
592# already exists (which is a sign that it has been already prepared).
593# Would be shorter if discover could return numerical device IDs...
594#
595if [ ! -f /a/etc/systemconfig/hardware.lst ]; then
596 [ ! -d /a/etc/systemconfig ] && mkdir -p /a/etc/systemconfig
597 SCSI_MODS=`discover -f "%m\n" scsi | grep -v ide-scsi | uniq`
598 for MOD in $SCSI_MODS; do
599 DEVID=`grep $MOD /proc/bus/pci/devices | cut -f 2 | sort | uniq`
600 for MYDEV in $DEVID; do
601 VENDOR=`echo $MYDEV | cut -b 1-4`
602 MODEL=`echo $MYDEV | cut -b 5-8`
603 echo "$VENDOR $MODEL scsi $MOD" >> /a/etc/systemconfig/hardware.lst
604 echo "Added SCSI device $VENDOR:$MODEL using module $MOD to hardware.lst"
605 done
606 done
607fi
608#
609################################################################################
610
611################################################################################
612#
613# System Configurator
614#
615# Configure the client's hardware, network interface, and boot loader.
616#
617
618# Create an /etc/mtab file with appropriate entries
619cat /etc/mtab | grep -v '/dev/ram' | grep -v -E '^\/dev\s+\/a\/dev\s' | sed 's,/a/*,/,g' | sort -u > /a/etc/mtab
620
621export PATH=/usr/local/sbin:/usr/local/bin:$PATH
622[ -z $DEVICE ] && DEVICE=eth0
623chroot /a/ systemconfigurator --excludesto=/etc/systemimager/systemconfig.local.exclude --configsi --stdin << EOL || shellout
624[NETWORK]
625HOSTNAME = $HOSTNAME
626DOMAINNAME = $DOMAINNAME
627
628[INTERFACE0]
629DEVICE = eth0
630EOL
631#
632################################################################################
633
634
635################################################################################
636#
637# Post Install Scripts
638#
639run_post_install_scripts
640#
641################################################################################
642
643################################################################################
644#
645# Save virtual console session in the imaged client
646#
647if [ ! -z $MONITOR_SERVER ]; then
648 if [ "x$MONITOR_CONSOLE" = "xyes" ]; then
649 [ ! -d /a/root ] && mkdir -p /a/root
650 cp -f /tmp/si_monitor.log /a/root/si_monitor.log
651 fi
652fi
653
654#
655################################################################################
656
657
658################################################################################
659#
660# Unmount filesystems
661#
662logmsg "umount /a/usr/local/blast/db || shellout"
663umount /a/usr/local/blast/db || shellout
664
665if [ ! $kernel = "2.4" ]; then
666logmsg "umount /a/sys || shellout"
667umount /a/sys || shellout
668fi
669
670logmsg "umount /a/proc || shellout"
671umount /a/proc || shellout
672
673logmsg "umount /a/boot || shellout"
674umount /a/boot || shellout
675
676logmsg "umount /a/ || shellout"
677umount /a/ || shellout
678
679#
680################################################################################
681
682
683################################################################################
684#
685# Tell the image server we are done
686#
687rsync $IMAGESERVER::scripts/imaging_complete > /dev/null 2>&1
688logmsg "Imaging completed"
689#
690################################################################################
691
692if [ ! -z $MONITOR_SERVER ]; then
693 # Report the 'imaged' state to the monitor server.
694 send_monitor_msg "status=100:speed=0"
695 if [ "x$MONITOR_CONSOLE" = "xyes" ]; then
696 # Print some empty lines and sleep some seconds to give time to
697 # the virtual console to get last messages.
698 # XXX: this is a dirty solution, we should find a better way to
699 # sync last messages... -AR-
700 logmsg ""
701 logmsg ""
702 logmsg ""
703 sleep 10
704 fi
705 # Report the post-install action.
706 send_monitor_msg "status=104:speed=0"
707fi
708
709# Explicitly kill sleep processes.
710# This is needed to close the SSH tunnel on the image server when the
711# SSH transport is used).
712killall sleep >/dev/null 2>&1
713
714# Take network interface down
715[ -z $DEVICE ] && DEVICE=eth0
716ifconfig $DEVICE down || shellout
717
718# Announce completion (even for non beep-incessantly --post-install options)
719beep 3
720
721# reboot the autoinstall client
722shutdown -r now