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 21:45:09 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 # if ! [ -n /etc/kernel-img.conf ] ; then
21 # echo "do_initrd = Yes" > /etc/kernel-img.conf
24 # install additional packages
25 if [ "$PACKAGES" = 'yes' ] ; then
26 if ! [ -r /etc/debootstrap/packages ] ; then
27 echo "Error: /etc/debootstrap/packages not found, exiting."
31 apt-get -y install $(cat /etc/debootstrap/packages)
35 if [ -n "$RECONFIGURE" ] ; then
36 for package in $RECONFIGURE ; do
37 dpkg --list $package 1>/dev/null 2>/dev/null && dpkg-reconfigure $package || echo "Warning: $package does not exist, can not reconfigure it."
41 # set password of user root
42 echo "Activating shadow passwords."
44 echo "Setting password for user root:"
48 if ! [ -f /etc/hosts ] ; then
49 echo "Setting up /etc/hosts"
50 echo "127.0.0.1 localhost $HOSTNAME" > /etc/hosts
53 if ! [ -f /etc/network/interfaces ] ; then
54 echo "Setting up /etc/network/interfaces"
55 cat >> /etc/network/interfaces << EOF
56 iface lo inet loopback
64 if [ -n "$TIMEZONE" ] ; then
65 echo "Adjusting /etc/localtime"
66 ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime
69 function createfstab(){
70 echo "Setting up /etc/fstab"
71 cat > /etc/fstab << EOF
72 $TARGET / auto defaults,errors=remount-ro 0 1
73 sysfs /sys sysfs auto 0 0
74 proc /proc proc defaults 0 0
75 /dev/cdrom /mnt/cdrom0 iso9660 ro,user,noauto 0 0
76 # /dev/sda2 none swap sw 0 0
80 # set up /etc/fstab if file is not present (cdebootstrap)
81 if [ ! -f /etc/fstab ] ; then
85 # set up /etc/fstab if file is UNCONFIGURED (debootstrap)
86 if grep -q UNCONFIGURED /etc/fstab ; then
90 # create default devices
91 if ! [ -r /dev/hda20 ] ; then
92 echo "Creating generic devices in /dev - this might take a while..."
93 cd /dev && MAKEDEV generic
96 # assume the first available kernel as our main kernel
97 KERNELIMG=$(ls -1 /boot/vmlinuz-* | head -1)
98 KERNELVER=${KERNELIMG#/boot/vmlinuz-}
101 if [ -n "$INITRD" ] ; then
102 echo "Generating initrd."
103 update-initramfs -c -t -k $KERNELVER
104 if [ -f "/boot/initrd.img-$KERNELVER" ] ; then
105 GRUBINITRD="initrd /boot/initrd.img-$KERNELVER"
106 LILOINITRD=" initrd=/boot/initrd.img-$KERNELVER"
110 if [ -n "$GROOT" ] ; then
111 echo "Installing grub"
113 # copy stage-files to /boot/grub/
114 [ -d /boot/grub/ ] || mkdir /boot/grub
115 cp /usr/lib/grub/i386-pc/* /boot/grub/
117 # finally install grub
119 sed -i "s/groot=.*/groot=(${GROOT})/g" /boot/grub/menu.lst
120 # not sure why savedefault does not work for me; any ideas?
121 sed -i "s/^savedefault.*/# &/g" /boot/grub/menu.lst
124 if [ -z "$MBR" ] ; then
125 echo "Notice: \$MBR not set, will not install grub therefor."
127 cp /proc/mounts /etc/mtab
133 # unmount all filesystems in chroot, make sure nothing is left...
134 umount -a 1>/dev/null 2>/dev/null || true
135 umount /proc 1>/dev/null 2>/dev/null || true
136 umount /proc 1>/dev/null 2>/dev/null || true
137 umount -a 1>/dev/null 2>/dev/null || true
139 # finally exit the chroot
140 echo "Finished chroot installation, exiting."
143 ## END OF FILE #################################################################