On Tue, Jun 23, 2009 at 10:48 AM, Leonid Flaks<flaks(a)bnl.gov> wrote:
I made two changes keep_ssh_host_keys snippet - list-harddrives does
not
work on fedora 11, also RAID array supprt is added. I see similar snippet
keep_rhn_kees which could be patched in similar way. I tested it on fedora
only.
Looks good but I've got a few comments. This might be a bug in
anaconda's list-harddrives which should be filed upstream. Are you at
liberty to share your hardware specs of the server / array that isn't
showing any output in list-harddrives? Comment inline.
diff --git a/snippets/keep_ssh_host_keys
b/snippets/keep_ssh_host_keys
index 527c992..655de7f 100644
--- a/snippets/keep_ssh_host_keys
+++ b/snippets/keep_ssh_host_keys
@@ -10,11 +10,7 @@ insmod /lib/ext3.o
mkdir -p /tmp/ssh
-drives=$(list-harddrives | awk '{print $1}')
-for disk in $drives; do
- DISKS="$DISKS $(fdisk -l /dev/$disk | awk '/^\/dev/{print $1}')"
-done
-
+DISKS=$(cat /proc/partitions | sed -n
'/^.*\(sd[a-z][1-9].*\)/{s||/dev/\1|p}')
Sed supports filenames as arguments so the cat is redundant. This
doesn't work with HP raid controllers using the cciss driver
(/dev/cciss/c0d0 for an equiv of /dev/sda). It also doesn't work for
exotic storage such as fusion io where list-harddrives does in both
cases.
Here is an example /proc/partitions for you to look at on an HP server:
major minor #blocks name
104 0 292935982 cciss/c0d0
104 1 265041 cciss/c0d0p1
104 2 8385930 cciss/c0d0p2
104 3 284278207 cciss/c0d0p3
104 16 1464678702 cciss/c0d1
While much uglier to look at, this works in all cases I could throw at
it including the two mentioned above:
awk '{if ($NF !~ "name" && $NF ~ "^[a-zA-Z]") print
$NF}'
/proc/partitions | sed -e 's:^:/dev/:g'
Does this look ok to you?
# Try to find the keys on ordinary partitions
for disk in $DISKS; do
name=$(basename $disk)
@@ -33,6 +29,28 @@ for disk in $DISKS; do
rm -r /tmp/$name
done
+# Try software RAID
+if [ "$keys_found" = "no" ]; then
+ if mdadm -As; then
+ RDISKS="$(awk '/md/{print $1}' /proc/mdstat)"
+ for rdisk in $RDISKS; do
+ mkdir -p /tmp/$rdisk
+ mount /dev/$rdisk /tmp/$rdisk
+ [ $? -eq 0 ] || continue # Skip to the next partition if the
mount fails
+ # Copy current ssh host keys out to be reused
+ if [ -d /tmp/${rdisk}/etc/ssh ]; then
+ cp -a /tmp/${rdisk}/etc/ssh/ssh_host* /tmp/ssh
+ keys_found="yes"
+ umount /tmp/$rdisk
+ break
+ fi
+ umount /tmp/$rdisk
+ rm -r /tmp/$rdisk
+ done
+ fi
+fi
+
+
# Try LVM if that didn't work
if [ "$keys_found" = "no" ]; then
lvm lvmdiskscan
This looks fantastic and thanks for helping to make cobbler better. I
wonder if there is any way to break this up and make this re-usable.
ssh host keys, rhn files, and puppet certs all require something very
similar. Can you re-do this patch with the above comments fixed
please?
--
Jeff Schroeder
Don't drink and derive, alcohol and analysis don't mix.
http://www.digitalprognosis.com