#!/bin/sh # # Create bootstrap information files -- prelude to creating a # Bacula Rescue Disk # # Kern Sibbald, December MMII # This source distributed under the GPL # di=diskinfo cwd=`pwd` host=`uname -s` case $host in Linux) ;; FreeBSD | SunOS | IRIX) echo "" echo "This code is not yet adapted to this OS" exit 1 ;; *) echo "" echo "Unknown operating system type: $host" exit 1 ;; esac if [ ! `whoami` = "root" ] ; then echo "" echo "You need to be root to run this, otherwise" echo "sfdisk produces no output. Continuing anyway ..." echo "" fi # # First collect information # echo "Begin collecting system info" mkdir -p $di cd $di mount -l >mount.bsi mount -l -t ext2 >mount.ext2.bsi mount -l -t ext3 >mount.ext3.bsi cp /etc/fstab fstab.bsi cp /etc/mtab mtab.bsi df -Tl >df.bsi sfdisk -s >sfdisk.disks.bsi grep "^/dev/" sfdisk.disks.bsi | sed -n 's/\(^.*\):.*$/\1/p' >disks.bsi for i in `cat disks.bsi`; do j=`echo $i | cut -c6-` sfdisk -l $i >sfdisk.$j.bsi sfdisk -d $i >sfdisk.make.$j.bsi done route -n >route.bsi ifconfig >ifconfig.bsi echo "Done collecting info. Building scripts ..." # # Done collecting information # # # First create partitioning script(s) # for i in `cat disks.bsi`; do j=`echo $i | cut -c6-` cat >$cwd/partition.$j <$cwd/format.$j <>$cwd/format.$j echo "mkswap $check $disk" >>$cwd/format.$j echo "echo \"\"" >>$cwd/format.$j done # Find ext2 partitions in mount output k=`grep "^$i" mount.ext2.bsi | cut -d ' ' -f 1` for disk in $k; do echo "echo \"Formating $disk -- ext2 partition\"" >>$cwd/format.$j label=`grep "^$disk" mount.ext2.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1` if [ x$label = x ] ; then echo "mke2fs -v \$check $disk" >>$cwd/format.$j else echo "mke2fs -v \$check -L $label $disk" >>$cwd/format.$j fi echo "echo \"\"" >>$cwd/format.$j done # Find ext3 partitions in mount output k=`grep "^$i" mount.ext3.bsi | cut -d ' ' -f 1` for disk in $k; do echo "echo \"Formating $disk -- ext3 partition\"" >>$cwd/format.$j label=`grep "^$disk" mount.ext3.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1` if [ x$label = x ] ; then echo "mke2fs -v -j \$check $disk" >>$cwd/format.$j else echo "mke2fs -v -j \$check -L $label $disk" >>$cwd/format.$j fi echo "echo \"\"" >>$cwd/format.$j done chmod 755 $cwd/format.$j done cd $cwd # # Create network start script # host=`hostname` ip=`host $host | cut -d ' ' -f 4` cat >start_network <mount_drives <>mount_drives sed -n 's/\(^.*\)\ on\ \(.*\)\ type.*$/mkdir -p \/mnt\/disk\2/p' $di/mount.ext3.bsi >>mount_drives echo "#" >>mount_drives sed -n 's/\(^.*\)\ on\ \(.*\)\ type.*$/mount \1 \/mnt\/disk\2/p' $di/mount.ext2.bsi >/tmp/1$$ sed -n 's/\(^.*\)\ on\ \(.*\)\ type.*$/mount \1 \/mnt\/disk\2/p' $di/mount.ext3.bsi >>/tmp/1$$ # sort so that root is mounted first sort -k 3 >mount_drives rm -f /tmp/1$$ chmod 755 mount_drives # copy sfdisk so we will have it cp -f /sbin/sfdisk .