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 15:06:22 CET 2006 [mika]
8 ################################################################################
10 set -e # exit on any error
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 1>/dev/null 2>/dev/null && 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 # set up /etc/fstab if file is UNCONFIGURED
66 if grep -q UNCONFIGURED /etc/fstab ; then
67 echo "Setting up /etc/fstab"
68 cat > /etc/fstab << EOF
69 $TARGET / auto defaults,errors=remount-ro 0 1
70 sysfs /sys sysfs auto 0 0
71 proc /proc proc defaults 0 0
72 # /dev/sda2 none swap sw 0 0
73 /dev/cdrom /mnt/cdrom0 iso9660 ro,user,noauto 0 0
77 # create default devices
78 if ! [ -r /dev/hda20 ] ; then
79 echo "Creating generic devices in /dev - this might take a while..."
80 cd /dev && MAKEDEV generic
83 # assume the first available kernel as our main kernel
84 KERNELIMG=$(ls -1 /boot/vmlinuz-* | head -1)
85 KERNELVER=${KERNELIMG#/boot/vmlinuz-}
88 if [ -n "$INITRD" ] ; then
89 echo "Generating initrd."
90 update-initramfs -c -t -k $KERNELVER
91 if [ -f "/boot/initrd.img-$KERNELVER" ] ; then
92 GRUBINITRD="initrd /boot/initrd.img-$KERNELVER"
93 LILOINITRD=" initrd=/boot/initrd.img-$KERNELVER"
97 if [ -n "$GROOT" ] ; then
98 echo "Installing grub"
99 # if ! [ -f /boot/grub/menu.lst ] ; then
102 # cat >> /boot/grub/menu.lst << EOF
103 ## Boot automatically after 30 secs.
106 ## By default, boot the first entry.
109 ## Fallback to the second entry.
112 #title Debian Etch, kernel $KERNELVER (on $ARGET)
114 #kernel $KERNELIMG root=$TARGET ro
117 ## For booting Windows
119 ## rootnoverify (hd0,0)
125 # copy stage-files to /boot/grub/
126 [ -d /boot/grub/ ] || mkdir /boot/grub
127 cp /usr/lib/grub/i386-pc/* /boot/grub/
129 # otherwise grub fails with 'Could not find device for /boot/boot: not found or not a block device'
130 # cp /etc/mtab /etc/mtab.old
131 # cp /proc/mounts /etc/mtab
133 # finally install grub
136 sed -i "s/groot=.*/groot=(${GROOT})/g" /boot/grub/menu.lst
140 # mv /etc/mtab.old /etc/mtab
143 # unmount all filesystems in chroot, make sure nothing is left...
144 umount -a 1>/dev/null 2>/dev/null || true
145 umount /proc 1>/dev/null 2>/dev/null || true
146 umount /proc 1>/dev/null 2>/dev/null || true
147 umount -a 1>/dev/null 2>/dev/null || true
149 # finally exit the chroot
150 echo "Finished chroot installation, exiting."
153 ## END OF FILE #################################################################