Skip to content

Commit

Permalink
keep_ssh_host_keys snippet gets F11+RAID support
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonid Flaks authored and Michael DeHaan committed Jun 25, 2009
1 parent e463ee6 commit 238b0df
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Cobbler CHANGELOG
- (FEAT) bringing back the koan live CD
- (FEAT) koan live CD can go interactive if no profile is specified and system autodiscovery fails
- (BUGF) koan autodetection now can gather MACs/IPs for bridged interfaces better
- (FEAT) keep_ssh_host_keys gets F11+RAID support

1.6.6 (for more accurate listing, see release16 branch)
- (BUGF) don't use -m option for drac unless power_id is set
Expand Down
31 changes: 26 additions & 5 deletions snippets/keep_ssh_host_keys
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ 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=$(awk '{if ($NF ~ "^[a-zA-Z].*[0-9]$" && $NF !~ "c[0-9]+d[0-9]+$") print "/dev/"$NF}' /proc/partitions)
# In the awk line above we want to make list of partitions, but not devices/controllers
# cciss raid controllers have partitions like /dev/cciss/cNdMpL, where N,M,L - some digits, we want to make sure 'pL' is there
#
# Try to find the keys on ordinary partitions
for disk in $DISKS; do
name=$(basename $disk)
Expand All @@ -33,6 +32,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
Expand Down

0 comments on commit 238b0df

Please sign in to comment.