X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;f=fai%2Fscripts%2Frc_fai.sh;h=d1e4f6748ad0f718b997ac05e24f3938c750adcf;hb=ca7ab55a9c818a03fe09b23f1c1c29af4679b249;hp=e297052933b535522d46360d01ee3dbd11eee072;hpb=6e75bb527068d620fe1811b09bb09e76ab29e856;p=hdw-linux%2Fhdw-linux.git diff --git a/fai/scripts/rc_fai.sh b/fai/scripts/rc_fai.sh index e297052..d1e4f67 100755 --- a/fai/scripts/rc_fai.sh +++ b/fai/scripts/rc_fai.sh @@ -15,6 +15,36 @@ if [ ! -d $myconf ] ; then exit fi +echo "debug:" +route +ifconfig + +# +# we need writeable /tmp +# +mount -tramfs ramfs /tmp + +# +# check if disk is ready +# +if [ ! -f $myconf/disk_ready ] ; then + echo + echo "you're disk seems to not be ready. login now and use cfdisk" + echo "to partition your harddisk. please make sure it's compatible" + echo "to $myconf/disk:" + cat $myconf/disk + echo + echo "after partitioning your harddisk please touch the file" + echo "$myconf/disk_ready" + echo "on your fai install server and reboot." + echo "... fully automated, he? :p" + echo + exit +fi + +# +# disk +# disk=0 disk=`grep '#\ disk' $myconf/disk | awk '{ print $3 }'` if [ ! -b $disk ] ; then @@ -28,27 +58,114 @@ if [ "$swap" != "0" -a -b ${disk}${swap} ] ; then mkswap ${disk}${swap} echo "done" fi - -cat $myconf/disk | grep -v '^#' | while read nr mp; do +cat $myconf/disk | grep -v '^#' | while read nr mp fs ac; do if [ -b ${disk}${nr} ] ; then - echo "making filesystem for $mp" - mke2fs -j ${disk}${nr} + action="" + [ "$fs" = "ext3" ] && action="mke2fs -j" + [ "$fs" = "ext2" ] && action="mke2fs" + if [ "$ac" = "format" -a -n "$action" ] ; then + echo "making filesystem for $mp" + $action ${disk}${nr} + fi if [ "$mp" = "/" ] ; then echo "mounting root partition" mount ${disk}${nr} $root + mkdir -p $root/etc + grep -v '/dev/root' /etc/fstab > $root/etc/fstab + echo -e "${disk}${nr}\t$mp\t$fs\tdefaults 0 2" >> \ + $root/etc/fstab fi fi done - -cat $myconf/disk | grep -v '^#' | while read nr mp; do +cat $myconf/disk | grep -v '^#' | while read nr mp fs ac; do if [ "$mp" != "/" ] ; then if [ -b ${disk}${nr} ] ; then mkdir -p $root/$mp mount ${disk}${nr} $root/$mp + echo -e "${disk}${nr}\t$mp\t$fs\tdefaults 0 2" >> \ + $root/etc/fstab fi fi done +[ "$swap" != "0" -a -b ${disk}${swap} ] && \ + echo -e "${disk}${swap}\tswap\tswap\tdefaults 0 0" >> $root/etc/fstab +# packages might install new fstab file, stored. +cp $root/etc/fstab $root/etc/fstab~ + +# +# install packages +# +cd /tmp # we need to wget stuff! +pkglist="" +[ -f $myconf/packages ] && pkglist=$myconf/packages +if [ -z "$pkglist" ] ; then + echo "cant find package list for $myip, aborting" + exit +fi +hdw-get dist-install $root $pkglist + +# +# config / files +# +cp $root/etc/fstab~ $root/etc/fstab +cp /etc/hdw-get.conf $root/etc +# files +cd /fai/files +for file in `find -type f | grep -v CVS`; do + srcf=`basename $file` + trgf=`dirname $file` + [ "$srcf" = "DEFAULT" -o "$srcf" = "$myip" ] && cp -v $file $root/$trgf +done + +# +# essential device file +# +[ ! -c $root/dev/null ] && mknod -m 0666 $root/dev/null c 1 3 +[ ! -c $root/dev/console ] && mknod -m 0600 $root/dev/console c 5 1 + + +# +# lilo +# +proot=${disk}`grep /[^a-z,^A-Z] $myconf/disk | awk '{ print $1 }'` +echo "running lilo -> root device = $proot" +cat > $root/etc/lilo.conf << EOF +boot=$disk +prompt +lba32 +timeout=30 + +default=vmlinuz_hdw + +image=/boot/vmlinuz_hdw + label=vmlinuz_hdw + append="root=$proot" + read-only + +EOF +# run lilo in chroot +cat > $root/run_lilo.sh << EOF +mount /dev +mount /sys +mount /proc +mkdir -p /dev/shm && mount /dev/shm +mkdir -p /dev/pts && mount /dev/pts +udevstart +ln -s /proc/self/fd /dev/fd +ln -s /proc/self/fd/0 /dev/stdin +ln -s /proc/self/fd/1 /dev/stdout +ln -s /proc/self/fd/2 /dev/stderr +ln -s /proc/kcore /dev/core +lilo +EOF +chmod 755 $root/run_lilo.sh +chroot $root /usr/bin/env PATH="/bin:/usr/bin:/sbin:/usr/sbin" /bin/bash \ + --login +h /run_lilo.sh + +echo +echo "fai finished, good luck for reboot ... :)" +echo -echo "to be continued ...." +touch /tmp/fai_finished exit 0