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:24:53 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 # set up /etc/fstab if file is UNCONFIGURED
70 if grep -q UNCONFIGURED /etc/fstab ; then
71 echo "Setting up /etc/fstab"
72 cat > /etc/fstab << EOF
73 $TARGET / auto defaults,errors=remount-ro 0 1
74 sysfs /sys sysfs auto 0 0
75 proc /proc proc defaults 0 0
76 # /dev/sda2 none swap sw 0 0
77 /dev/cdrom /mnt/cdrom0 iso9660 ro,user,noauto 0 0
81 # create default devices
82 if ! [ -r /dev/hda20 ] ; then
83 echo "Creating generic devices in /dev - this might take a while..."
84 cd /dev && MAKEDEV generic
87 # assume the first available kernel as our main kernel
88 KERNELIMG=$(ls -1 /boot/vmlinuz-* | head -1)
89 KERNELVER=${KERNELIMG#/boot/vmlinuz-}
92 if [ -n "$INITRD" ] ; then
93 echo "Generating initrd."
94 update-initramfs -c -t -k $KERNELVER
95 if [ -f "/boot/initrd.img-$KERNELVER" ] ; then
96 GRUBINITRD="initrd /boot/initrd.img-$KERNELVER"
97 LILOINITRD=" initrd=/boot/initrd.img-$KERNELVER"
101 if [ -n "$GROOT" ] ; then
102 echo "Installing grub"
104 # copy stage-files to /boot/grub/
105 [ -d /boot/grub/ ] || mkdir /boot/grub
106 cp /usr/lib/grub/i386-pc/* /boot/grub/
108 # finally install grub
110 sed -i "s/groot=.*/groot=(${GROOT})/g" /boot/grub/menu.lst
111 # not sure why savedefault does not work for me; any ideas?
112 sed -i "s/^savedefault.*/# &/g" /boot/grub/menu.lst
117 # unmount all filesystems in chroot, make sure nothing is left...
118 umount -a 1>/dev/null 2>/dev/null || true
119 umount /proc 1>/dev/null 2>/dev/null || true
120 umount /proc 1>/dev/null 2>/dev/null || true
121 umount -a 1>/dev/null 2>/dev/null || true
123 # finally exit the chroot
124 echo "Finished chroot installation, exiting."
127 ## END OF FILE #################################################################