# This source distributed under the GPL
#
export LANG=C
-di=diskinfo
cwd=`pwd`
host=`uname -s`
+di=${cwd}/diskinfo
+scr=${cwd}/scripts
case $host in
Linux)
#
# First collect information
#
-rm -rf format.* partition.* $di create-*
+rm -rf format.* partition.* $di create-* $scr
echo "Begin collecting system info ..."
mkdir -p $di
cd $di
#
# First create partitioning script(s)
#
+mkdir -p $scr
for i in `cat disks.bsi`; do
j=`echo $i | cut -c6-`
- cat >$cwd/partition.$j <<END_OF_DATA
+ cat >$scr/partition.$j <<END_OF_DATA
#!/bin/sh
#
END_OF_DATA
-chmod 755 $cwd/partition.$j
+chmod 755 $scr/partition.$j
done
echo "Done making partitioning scripts"
#
# LVM phase 1: create the Physical Volumess
#
- cat > $cwd/create-pv <<EOF
+ cat > $scr/create-pv <<EOF
#!/bin/sh
#
# Create PVs for LVM -- created by getdiskinfo
echo ""
EOF
for pv in `cat lvm-pv.bsi | awk '{print $1}'`; do
- echo "echo \" $pv\"" >> $cwd/create-pv
+ echo "echo \" $pv\"" >> $scr/create-pv
done
- cat >> $cwd/create-pv <<EOF
+ cat >> $scr/create-pv <<EOF
echo ""
echo -n "Are you sure you want to continue? yes/no: "
read a
fi
EOF
for pv in `cat lvm-pv.bsi | awk '{print $1}'`; do
- echo "echo \"Creating PV on $pv\"" >> $cwd/create-pv
- echo "lvm pvcreate -ff -y -v $pv" >> $cwd/create-pv
+ echo "echo \"Creating PV on $pv\"" >> $scr/create-pv
+ echo "lvm pvcreate -ff -y -v $pv" >> $scr/create-pv
done
- echo "echo \"Done.\"" >> $cwd/create-pv
- echo "echo \"If there were no errors, run create-vg to create the volume groups.\"" >> $cwd/create-pv
- chmod +x $cwd/create-pv
+ echo "echo \"Done.\"" >> $scr/create-pv
+ echo "echo \"If there were no errors, run create-vg to create the volume groups.\"" >> $scr/create-pv
+ chmod +x $scr/create-pv
#
# LVM phase 2: create Volume Groups
#
- cat > $cwd/create-vg <<EOF
+ cat > $scr/create-vg <<EOF
#!/bin/sh
echo ""
echo "This script will create all volume groups listed in diskinfo/lvm-vg.bsi"
fi
EOF
cat lvm-vg.bsi | awk '{print $1, $2}' | while read vg pesize ; do
- echo "echo \"Creating VG $vg PE extent size $pesize kbytes"\" >> $cwd/create-vg
- pelist=""
- for pv in `cat lvm-pv.bsi | awk "\\\$2 == \"$vg\" { print \\\$1 }"` ; do
- pelist="$pelist $pv"
- done
- echo "lvm vgcreate $vg -v -s ${pesize}k $pelist" >> $cwd/create-vg
+ echo "echo \"Creating VG $vg PE extent size $pesize kbytes"\" >> $scr/create-vg
+ pelist=""
+ for pv in `cat lvm-pv.bsi | awk "\\\$2 == \"$vg\" { print \\\$1 }"` ; do
+ pelist="$pelist $pv"
+ done
+ echo "lvm vgcreate $vg -v -s ${pesize}k $pelist" >> $scr/create-vg
done
- echo "echo \"Done.\"" >> $cwd/create-vg
- echo "echo \"If there were no errors, run create-lv to create the logical volumes.\"" >> $cwd/create-vg
- chmod +x $cwd/create-vg
+ echo "echo \"Done.\"" >> $scr/create-vg
+ echo "echo \"If there were no errors, run create-lv to create the logical volumes.\"" >> $scr/create-vg
+ chmod +x $scr/create-vg
#
# Using the extent count should allow this script to continue to work
# even after the bug is fixed.
- cat > $cwd/create-lv <<EOF
+ cat > $scr/create-lv <<EOF
#!/bin/sh
echo ""
echo "This script will create all logical volumes listed in diskinfo/lvm-lv.bsi"
fi
EOF
cat lvm-lv.bsi | awk '{print $1, $2, $3}' | while read lv vg lvsize ; do
- # lv=`echo $lv | sed -e 's/.*\///'`
- echo "echo \"Creating LV $lv\"" >> $cwd/create-lv
- echo "lvm lvcreate -L ${lvsize}k $vg -n $lv" >> $cwd/create-lv
+ # lv=`echo $lv | sed -e 's/.*\///'`
+ echo "echo \"Creating LV $lv\"" >> $scr/create-lv
+ echo "lvm lvcreate -L ${lvsize}k $vg -n $lv" >> $scr/create-lv
done
- chmod +x $cwd/create-lv
+ chmod +x $scr/create-lv
fi
#
echo "Begin making formatting script(s) ..."
for i in `cat disks.bsi`; do
j=`echo $i | cut -c6-`
- cat >$cwd/format.$j <<END_OF_DATA
+ cat >$scr/format.$j <<END_OF_DATA
#!/bin/sh
#
# Format all partitions on disk $i -- created by getdiskinfo
# Find swap partitions in output from sfdisk
k=`grep "^$i.*82 Linux swap" sfdisk.$j.bsi | cut -d ' ' -f 1`
for disk in $k; do
- echo "echo \"Formatting $disk -- swap partition\"" >>$cwd/format.$j
- echo "mkswap $check $disk" >>$cwd/format.$j
- echo "echo \"\"" >>$cwd/format.$j
+ echo "echo \"Formatting $disk -- swap partition\"" >>$scr/format.$j
+ echo "mkswap $check $disk" >>$scr/format.$j
+ echo "echo \"\"" >>$scr/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
+ echo "echo \"Formating $disk -- ext2 partition\"" >>$scr/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
+ echo "mke2fs -v \$check $disk" >>$scr/format.$j
else
- echo "mke2fs -v \$check -L $label $disk" >>$cwd/format.$j
+ echo "mke2fs -v \$check -L $label $disk" >>$scr/format.$j
fi
- echo "echo \"\"" >>$cwd/format.$j
+ echo "echo \"\"" >>$scr/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
+ echo "echo \"Formating $disk -- ext3 partition\"" >>$scr/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
+ echo "mke2fs -v -j \$check $disk" >>$scr/format.$j
else
- echo "mke2fs -v -j \$check -L $label $disk" >>$cwd/format.$j
+ echo "mke2fs -v -j \$check -L $label $disk" >>$scr/format.$j
fi
- echo "echo \"\"" >>$cwd/format.$j
+ echo "echo \"\"" >>$scr/format.$j
done
# Find reiserfs partitions in mount output
k=`grep "^$i" mount.rei.bsi | cut -d ' ' -f 1`
for disk in $k; do
- echo "echo \"Formating $disk -- reiser partition\"" >>$cwd/format.$j
+ echo "echo \"Formating $disk -- reiser partition\"" >>$scr/format.$j
label=`grep "^$disk" mount.rei.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1`
if [ x$label = x ] ; then
- echo "mkereiserfs -V \$check $disk" >>$cwd/format.$j
+ echo "mkereiserfs -V \$check $disk" >>$scr/format.$j
else
- echo "mkereiserfs -V \$check -L $label $disk" >>$cwd/format.$j
+ echo "mkereiserfs -V \$check -L $label $disk" >>$scr/format.$j
fi
- echo "echo \"\"" >>$cwd/format.$j
+ echo "echo \"\"" >>$scr/format.$j
done
- chmod 755 $cwd/format.$j
+ chmod 755 $scr/format.$j
done
#
if [ $dolvm -eq 1 ] ; then
echo "Begin making LVM formatting script(s) ..."
for i in `cat lvm-vg.bsi | awk '{print $1}'`; do
- cat >$cwd/format.$i <<END_OF_DATA
+ cat >$scr/format.$i <<END_OF_DATA
#!/bin/sh
#
# Format all partitions on VG $i -- created by getdiskinfo
mapper="/dev/mapper/${i}"
k=`grep "^$mapper" swaps.bsi | awk '{print $1}'`
for disk in $k; do
- echo "echo \"Formatting $disk -- swap partition\"" >>$cwd/format.$i
- echo "mkswap $check $disk" >>$cwd/format.$i
- echo "echo \"\"" >>$cwd/format.$i
+ echo "echo \"Formatting $disk -- swap partition\"" >>$scr/format.$i
+ echo "mkswap $check $disk" >>$scr/format.$i
+ echo "echo \"\"" >>$scr/format.$i
done
# Find ext2 partitions in mount output
k=`grep "^$mapper" mount.ext2.bsi | cut -d ' ' -f 1`
for disk in $k; do
- echo "echo \"Formating $disk -- ext2 partition\"" >>$cwd/format.$i
+ echo "echo \"Formating $disk -- ext2 partition\"" >>$scr/format.$i
label=`grep "^$disk on" 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.$i
+ echo "mke2fs -v \$check $disk" >>$scr/format.$i
else
- echo "mke2fs -v \$check -L $label $disk" >>$cwd/format.$i
+ echo "mke2fs -v \$check -L $label $disk" >>$scr/format.$i
fi
- echo "echo \"\"" >>$cwd/format.$i
+ echo "echo \"\"" >>$scr/format.$i
done
# Find ext3 partitions in mount output
k=`grep "^$mapper" mount.ext3.bsi | cut -d ' ' -f 1`
for disk in $k; do
- echo "echo \"Formating $disk -- ext3 partition\"" >>$cwd/format.$i
+ echo "echo \"Formating $disk -- ext3 partition\"" >>$scr/format.$i
label=`grep "^$disk on" 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.$i
+ echo "mke2fs -v -j \$check $disk" >>$scr/format.$i
else
- echo "mke2fs -v -j \$check -L $label $disk" >>$cwd/format.$i
+ echo "mke2fs -v -j \$check -L $label $disk" >>$scr/format.$i
fi
- echo "echo \"\"" >>$cwd/format.$i
+ echo "echo \"\"" >>$scr/format.$i
done
# Find reiserfs partitions in mount output
k=`grep "^$mapper" mount.rei.bsi | cut -d ' ' -f 1`
for disk in $k; do
- echo "echo \"Formating $disk -- reiser partition\"" >>$cwd/format.$i
+ echo "echo \"Formating $disk -- reiser partition\"" >>$scr/format.$i
label=`grep "^$disk on" mount.rei.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1`
if [ x$label = x ] ; then
- echo "mkereiserfs -V \$check $disk" >>$cwd/format.$i
+ echo "mkereiserfs -V \$check $disk" >>$scr/format.$i
else
- echo "mkereiserfs -V \$check -L $label $disk" >>$cwd/format.$i
+ echo "mkereiserfs -V \$check -L $label $disk" >>$scr/format.$i
fi
- echo "echo \"\"" >>$cwd/format.$i
+ echo "echo \"\"" >>$scr/format.$i
done
- chmod 755 $cwd/format.$i
+ chmod 755 $scr/format.$i
done
fi
-cd $cwd
+cd $scr
#
# Create network start script
chmod 755 start_network
-cat >mount_drives <<END_OF_DATA
+cat >$scr/mount_drives <<END_OF_DATA
#!/bin/sh
#
# Mount disk drives -- created by getdiskinfo
sort -k 2 <${TMP1} >${TMP2}
# output mkdir followed by its mount
sed -n 's/\(^.*\)\ \(.*$\)/mkdir -p \2\
-mount \1 \2/p' ${TMP2} >>mount_drives
+mount \1 \2/p' ${TMP2} >>$scr/mount_drives
# Now build unmount_drives
-cat >umount_drives <<END_OF_DATA
+cat >$scr/umount_drives <<END_OF_DATA
#!/bin/sh
#
# Unmount disk drives -- created by getdiskinfo
#
END_OF_DATA
sort -r -k 2 <${TMP1} >${TMP2}
-sed -n 's/\(^.*\)\ \(.*$\)/umount \2/p' ${TMP2} >>umount_drives
-echo "umount /mnt/cdrom 2>/dev/null >/dev/null" >>umount_drives
-echo "sync" >>umount_drives
-echo "sync" >>umount_drives
+sed -n 's/\(^.*\)\ \(.*$\)/umount \2/p' ${TMP2} >>$scr/umount_drives
+echo "umount /mnt/cdrom 2>/dev/null >/dev/null" >>$scr/umount_drives
+echo "sync" >>$scr/umount_drives
+echo "sync" >>$scr/umount_drives
rm -f ${TMP1} ${TMP2}
-chmod 755 mount_drives umount_drives
+chmod 755 $scr/mount_drives $scr/umount_drives
echo "Done building scripts."