2 # Filename: /etc/debootstrap/chroot-script
3 # Purpose: script executed in chroot when installing Debian via grml-debootstrap
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 # Latest change: Fre Nov 03 12:27:20 CET 2006 [mika]
8 ################################################################################
12 . /etc/debootstrap/config || exit 1
14 [ -r /proc/1 ] || mount -t proc none /proc
16 if [ -n "$CHROOTMIRROR" ] ; then
17 echo "$CHROOTMIRROR" > /etc/apt/sources.list
20 # install additional packages
21 if [ "$PACKAGES" = 'yes' ] ; then
22 if ! [ -r /etc/debootstrap/packages ] ; then
23 echo "Error: /etc/debootstrap/packages not found, exiting."
27 apt-get -y install $(cat /etc/debootstrap/packages)
31 if [ -n "$RECONFIGURE" ] ; then
32 for package in $RECONFIGURE ; do
33 dpkg --list $package && dpkg-reconfigure $package || echo "Warning: $package does not exist, can not reconfigure it."
37 # set password of user root
38 echo "Activating shadow passwords."
40 echo "Setting password for user root:"
44 if ! [ -f /etc/hosts ] ; then
45 echo "Setting up /etc/hosts"
46 echo "127.0.0.1 localhost $HOSTNAME" > /etc/hosts
49 if ! [ -f /etc/network/interfaces ] ; then
50 echo "Setting up /etc/network/interfaces"
51 cat >> /etc/network/interfaces << EOF
52 iface lo inet loopback
60 if [ -n "$TIMEZONE" ] ; then
61 echo "Adjusting /etc/localtime"
62 ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime
65 if ! [ -f /etc/fstab ] ; then
66 echo "Setting up /etc/fstab"
67 cat >> /etc/fstab << EOF
68 sysfs /sys sysfs auto 0 0
69 proc /proc proc defaults 0 0
70 $TARGET / auto defaults,errors=remount-ro 0 1
71 # /dev/sda2 none swap sw 0 0
72 /dev/cdrom /mnt/cdrom0 iso9660 ro,user,noauto 0 0
76 # create default devices
77 if ! [ -r /dev/hda20 ] ; then
78 echo "Creating generic devices in /dev - this might take a while..."
79 cd /dev && MAKEDEV generic
82 # assume the first available kernel as our main kernel
83 KERNELIMG=$(ls -1 /boot/vmlinuz-* | head -1)
84 KERNELVER=${KERNELIMG#/boot/vmlinuz-}
87 if [ -n "$INITRD" ] ; then
88 echo "Generating initrd."
89 update-initramfs -c -t -k $KERNELVER
90 if [ -f "/boot/initrd.img-$KERNELVER" ] ; then
91 GRUBINITRD="initrd /boot/initrd.img-$KERNELVER"
92 LILOINITRD=" initrd=/boot/initrd.img-$KERNELVER"
96 if [ "$BOOTMGR" = 'grub' ] ; then
97 echo "Installing grub"
98 if ! [ -f /boot/grub/menu.lst ] ; then
101 cat >> /boot/grub/menu.lst << EOF
102 # Boot automatically after 30 secs.
105 # By default, boot the first entry.
108 # Fallback to the second entry.
111 title Debian Etch, kernel $KERNELVER (on $ARGET)
113 kernel $KERNELIMG root=$TARGET ro
116 # For booting Windows
118 # rootnoverify (hd0,0)
124 # copy stage-files to /boot/grub/
125 cp -i /usr/lib/grub/i386-pc/* /boot/grub/
127 # otherwise grub fails with 'Could not find device for /boot/boot: not found or not a block device'
128 cp /etc/mtab /etc/mtab.old
129 cp /proc/mounts /etc/mtab
131 # finally install grub
135 mv /etc/mtab.old /etc/mtab
138 if [ "$BOOTMGR" = 'lilo' ] ; then
139 echo "Installing lilo"
140 # /usr/share/doc/lilo/examples/conf.sample
141 cat > /etc/lilo.conf << EOF
142 # This allows booting from any partition on disks with more than 1024 cylinders.
145 # Specifies the boot device
148 # Specifies the device that should be mounted as root.
151 # use Debian on software raid:
152 # raid-extra-boot=mbr-only
160 image=/boot/vmlinuz-2.6.17-grml
168 # unmount all filesystems in chroot, make sure nothing is left...
174 # finally exit the chroot
175 echo "Finished chroot installation, exiting."
178 ## END OF FILE #################################################################