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 }'`"
13 if [ ! -d $myconf ] ; then
14 echo "no config found, aborting fai"
23 # we need writeable /tmp
25 mount -tramfs ramfs /tmp
28 # check if disk is ready
30 if [ ! -f $myconf/disk_ready ] ; then
32 echo "you're disk seems to not be ready. login now and use cfdisk"
33 echo "to partition your harddisk. please make sure it's compatible"
34 echo "to $myconf/disk:"
37 echo "after partitioning your harddisk please touch the file"
38 echo "$myconf/disk_ready"
39 echo "on your fai install server and reboot."
40 echo "... fully automated, he? :p"
49 disk=`grep '#\ disk' $myconf/disk | awk '{ print $3 }'`
50 if [ ! -b $disk ] ; then
51 echo "disk $disk not found, aborting fai"
55 swap=`grep '#\ swap' $myconf/disk | awk '{ print $3 }'`
56 if [ "$swap" != "0" -a -b ${disk}${swap} ] ; then
57 echo "creating swap device ..."
61 cat $myconf/disk | grep -v '^#' | while read nr mp fs ac; do
62 if [ -b ${disk}${nr} ] ; then
64 [ "$fs" = "ext3" ] && action="mke2fs -j"
65 [ "$fs" = "ext2" ] && action="mke2fs"
66 if [ "$ac" = "format" -a -n "$action" ] ; then
67 echo "making filesystem for $mp"
70 if [ "$mp" = "/" ] ; then
71 echo "mounting root partition"
72 mount ${disk}${nr} $root
74 grep -v '/dev/root' /etc/fstab > $root/etc/fstab
75 echo -e "${disk}${nr}\t$mp\t$fs\tdefaults 0 2" >> \
80 cat $myconf/disk | grep -v '^#' | while read nr mp fs ac; do
81 if [ "$mp" != "/" ] ; then
82 if [ -b ${disk}${nr} ] ; then
84 mount ${disk}${nr} $root/$mp
85 echo -e "${disk}${nr}\t$mp\t$fs\tdefaults 0 2" >> \
90 [ "$swap" != "0" -a -b ${disk}${swap} ] && \
91 echo -e "${disk}${swap}\tswap\tswap\tdefaults 0 0" >> $root/etc/fstab
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 $myconf/packages ] && pkglist=$myconf/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 proot=${disk}`grep /[^a-z,^A-Z] $myconf/disk | awk '{ print $1 }'`
131 echo "running lilo -> root device = $proot"
132 cat > $root/etc/lilo.conf << EOF
140 image=/boot/vmlinuz_hdw
147 cat > $root/run_lilo.sh << EOF
151 mkdir -p /dev/shm && mount /dev/shm
152 mkdir -p /dev/pts && mount /dev/pts
154 ln -s /proc/self/fd /dev/fd
155 ln -s /proc/self/fd/0 /dev/stdin
156 ln -s /proc/self/fd/1 /dev/stdout
157 ln -s /proc/self/fd/2 /dev/stderr
158 ln -s /proc/kcore /dev/core
161 chmod 755 $root/run_lilo.sh
162 chroot $root /usr/bin/env PATH="/bin:/usr/bin:/sbin:/usr/sbin" /bin/bash \
163 --login +h /run_lilo.sh
166 echo "fai finished, good luck for reboot ... :)"
169 touch /tmp/fai_finished