2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-25 05:02:05 +00:00

Merge pull request #806 from xuweibj/I805

To fix issue #805, add flag to getinstdisk log
This commit is contained in:
Xiaopeng Wang 2016-03-16 18:31:29 +08:00
commit a43bdac1f2

View File

@ -28,7 +28,7 @@ tmpfile=$tmpdir"/getinstalldisk_"
if [ -z "$install_disk" ]; then
echo "Information from /proc/partitions:"
echo "[get_install_disk]Information from /proc/partitions:"
cat /proc/partitions
echo ""
@ -60,10 +60,10 @@ if [ -z "$install_disk" ]; then
disk_array=""
for partition in $partitions; do
echo "Check the partition $partition."
echo "[get_install_disk]Check the partition $partition."
if [ -e "$tmpfile${partition%%[0-9]*}" ]; then
echo " The disk ${partition%%[0-9]*} had OS installed, check next partition."
echo "[get_install_disk] The disk ${partition%%[0-9]*} had OS installed, check next partition."
continue
fi
@ -87,7 +87,7 @@ if [ -z "$install_disk" ]; then
# Check whether mount successfully
if [ $rc -eq 0 ]; then
echo " Partition $partition mount success."
echo "[get_install_disk] Partition $partition mount success."
ker_dir=$mount_dir
if [ -d "$mount_dir/boot" ]; then
@ -99,21 +99,21 @@ if [ -z "$install_disk" ]; then
disk_part=${partition%%[0-9]*}
touch "$tmpfile$disk_part"
disk_array=$disk_array"$disk_part "
echo " The partition $partition has kernel file."
echo "[get_install_disk] The partition $partition has kernel file."
break
done
umount $mount_dir || echo " $partition umount failed."
umount $mount_dir || echo "[get_install_disk] $partition umount failed."
else
echo " Partition $partition mount failed or the partition is swap."
echo "[get_install_disk] Partition $partition mount failed or the partition is swap."
fi
done
# If disk_array is not empty, make disks equal disk_array for next step to sort
if [ "$disk_array" ]; then
disks=$disk_array
echo "The disks which have kernel:"
echo " $disks"
echo "[get_install_disk]The disks which have kernel:"
echo "[get_install_disk] $disks"
echo ""
fi
@ -134,10 +134,10 @@ if [ -z "$install_disk" ]; then
disk_driver=$(udevadm info --attribute-walk --name=$disk | grep DRIVERS| grep -v '""'| grep -v '"sd"'|
\head -n 1| sed -e 's/[^"]*"//' -e 's/"//' | tr A-Z a-z)
echo "The disk $disk information: "
echo " disk_wwn=$disk_wwn"
echo " disk_path=$disk_path"
echo " disk_driver=$disk_driver"
echo "[get_install_disk]The disk $disk information: "
echo "[get_install_disk] disk_wwn=$disk_wwn"
echo "[get_install_disk] disk_path=$disk_path"
echo "[get_install_disk] disk_driver=$disk_driver"
# Check whether there is WWN, PATH information
if [ "$disk_wwn" ]; then
@ -145,16 +145,16 @@ if [ -z "$install_disk" ]; then
file_pre="wwn"
disk_data=$disk_wwn
elif [ $has_wwn -eq 1 ]; then
echo " The disk $disk has no wwn info."
echo " There is other disk has wwn info, so don't record this disk."
echo "[get_install_disk] The disk $disk has no wwn info."
echo "[get_install_disk] There is other disk has wwn info, so don't record this disk."
continue;
elif [ "$disk_path" ]; then
has_path=1
file_pre="path"
disk_data=$disk_path
elif [ $has_path -eq 1 ]; then
echo " The disk $disk has no wwn or path info."
echo " There is other disk has path info, so don't record this disk."
echo "[get_install_disk] The disk $disk has no wwn or path info."
echo "[get_install_disk] There is other disk has path info, so don't record this disk."
continue;
else
file_pre="other"
@ -165,15 +165,15 @@ if [ -z "$install_disk" ]; then
case "$disk_driver" in
"ata_piix"*|"PMC MaxRAID"|"ahci"|"megaraid_sas")
echo "$disk $disk_data" >> "$tmpfile""$file_pre""firstchoicedisks"
echo " Add disk: $disk $disk_data into $file_pre firstchoicedisks"
echo "[get_install_disk] Add disk: $disk $disk_data into $file_pre firstchoicedisks"
;;
"mptsas"|"mpt2sas"|"mpt3sas")
echo "$disk $disk_data" >> "$tmpfile""$file_pre""secondchoicedisks"
echo " Add disk: $disk $disk_data into $file_pre secondchoicedisks"
echo "[get_install_disk] Add disk: $disk $disk_data into $file_pre secondchoicedisks"
;;
*)
echo "$disk $disk_data" >> "$tmpfile""$file_pre""thirdchoicedisks"
echo " Add disk: $disk $disk_data into $file_pre thirdchoicedisks"
echo "[get_install_disk] Add disk: $disk $disk_data into $file_pre thirdchoicedisks"
;;
esac
done
@ -187,7 +187,7 @@ if [ -z "$install_disk" ]; then
if [ "$install_file" ] && [ -s $install_file ]; then
install_disk=/dev/$(cat $install_file | grep -v "^$" | sort -t : -k 2 -b | cut -d " " -f1 | head -n 1)
echo "The install_disk is $install_disk by sorting $file_pre and DRIVER."
echo "[get_install_disk]The install_disk is $install_disk by sorting $file_pre and DRIVER."
fi
rm $tmpfile*;
fi
@ -196,7 +196,7 @@ rm -rf $tmpdir;
# Cannot find proper disk for OS install, select the default one "/dev/sda"
if [ -z "$install_disk" ]; then
install_disk="/dev/sda"
echo "The default install_disk is $install_disk."
echo "[get_install_disk]The default install_disk is $install_disk."
fi
# Output the result to /tmp/install_disk file