3 # author: hackbard@hackdaworld.dyndns.org
5 # automated install rc_fai.sh script
10 myip="`ifconfig eth0 | grep inet\ addr | awk '{ print $2 }' | awk -F: '{ print $2 }'`"
14 if [ ! -d $myconf ] ; then
15 echo "no config found, aborting fai"
24 # we need writeable /tmp
26 mount -tramfs ramfs /tmp
29 # check if disk is ready
31 if [ ! -f $croot/$myip/disk_ready ] ; then
33 echo "you're disk seems to not be ready. login now and use cfdisk"
34 echo "to partition your harddisk. please make sure it's compatible"
35 echo "to $croot/$myip/disk:"
38 echo "after partitioning your harddisk please touch the file"
39 echo "$croot/$myip/disk_ready"
40 echo "on your fai install server and reboot."
41 echo "... fully automated, he? :p"
50 disk=`grep '#\ disk' $myconf/disk | awk '{ print $3 }'`
51 if [ ! -b $disk ] ; then
52 echo "disk $disk not found, aborting fai"
56 swap=`grep '#\ swap' $myconf/disk | awk '{ print $3 }'`
57 if [ "$swap" != "0" -a -b ${disk}${swap} ] ; then
58 echo "creating swap device ..."
62 cat $myconf/disk | grep -v '^#' | while read nr mp fs ac; do
63 if [ -b ${disk}${nr} ] ; then
65 [ "$fs" = "ext3" ] && action="mke2fs -j"
66 [ "$fs" = "ext2" ] && action="mke2fs"
67 if [ "$ac" = "format" -a -n "$action" ] ; then
68 echo "making filesystem for $mp"
71 if [ "$mp" = "/" ] ; then
72 echo "mounting root partition"
73 mount ${disk}${nr} $root
75 grep -v '/dev/root' /etc/fstab > $root/etc/fstab
76 echo -e "${disk}${nr}\t$mp\t$fs\tdefaults 0 2" >> \
82 cat $myconf/disk | grep -v '^#' | while read nr mp fs ac; do
83 if [ "$mp" != "/" ] ; then
84 if [ -b ${disk}${nr} ] ; then
86 mount ${disk}${nr} $root/$mp
87 echo -e "${disk}${nr}\t$mp\t$fs\tdefaults 0 2" >> \
92 # packages might install new fstab file, stored.
93 cp $root/etc/fstab $root/etc/fstab~
98 cd /tmp # we need to wget stuff!
100 [ -f /fai/config/$myip/packages ] && pkglist=/fai/config/$myip/packages
101 if [ -z "$pkglist" ] ; then
102 echo "cant find package list for $myip, aborting"
105 hdw-get dist-install $root $pkglist
110 cp $root/etc/fstab~ $root/etc/fstab
111 cp /etc/hdw-get.conf $root/etc
114 for file in `find -type f | grep -v CVS`; do
115 srcf=`basename $file`
117 [ "$srcf" = "DEFAULT" -o "$srcf" = "$myip" ] && cp -v $file $root/$trgf
121 # essential device file
123 [ ! -c $root/dev/null ] && mknod -m 0666 $root/dev/null c 1 3
124 [ ! -c $root/dev/console ] && mknod -m 0600 $root/dev/console c 5 1
130 cat > $root/etc/lilo.conf << EOF
138 image=/boot/vmlinuz_hdw
145 cat > $root/run_lilo.sh << EOF
151 ln -s /proc/self/fd /dev/fd
152 ln -s /proc/self/fd/0 /dev/stdin
153 ln -s /proc/self/fd/1 /dev/stdout
154 ln -s /proc/self/fd/2 /dev/stderr
155 ln -s /proc/kcore /dev/core
158 chmod 755 $root/run_lilo.sh
159 chroot $root /usr/bin/env PATH="/bin:/usr/bin:/sbin:/usr/sbin" /bin/bash \
160 --login +h /run_lilo.sh
163 echo "fai finished, good luck for reboot ... :)"
166 touch /tmp/fai_finished