summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJasper Capel <capel@stone-it.com>2009-03-12 17:14:56 +0100
committerJasper Capel <capel@stone-it.com>2009-03-12 17:14:56 +0100
commitb0742e66ae3b4d495ba88c44ff3fb019c57c6216 (patch)
tree2b79696320ef54c38d8cf983a6ec4b249535ce6c
parent37325215977dbf850fe1c621b91ecfaa99bcdf81 (diff)
downloadcobbler-b0742e66ae3b4d495ba88c44ff3fb019c57c6216.tar.gz
cobbler-b0742e66ae3b4d495ba88c44ff3fb019c57c6216.tar.xz
cobbler-b0742e66ae3b4d495ba88c44ff3fb019c57c6216.zip
Teach keep_ssh_host_keys about LVM
-rw-r--r--snippets/keep_ssh_host_keys37
1 files changed, 36 insertions, 1 deletions
diff --git a/snippets/keep_ssh_host_keys b/snippets/keep_ssh_host_keys
index 93a6fadb..527c9926 100644
--- a/snippets/keep_ssh_host_keys
+++ b/snippets/keep_ssh_host_keys
@@ -8,14 +8,17 @@ keys_found=no
insmod /lib/jbd.o
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
+# Try to find the keys on ordinary partitions
for disk in $DISKS; do
name=$(basename $disk)
- mkdir -p /tmp/$name /tmp/ssh
+ mkdir -p /tmp/$name
mount $disk /tmp/$name
[ $? -eq 0 ] || continue # Skip to the next partition if the mount fails
@@ -30,6 +33,38 @@ for disk in $DISKS; do
rm -r /tmp/$name
done
+# Try LVM if that didn't work
+if [ "$keys_found" = "no" ]; then
+ lvm lvmdiskscan
+ vgs=$(lvm vgs | tail -n +2 | awk '{ print $1 }')
+ for vg in $vgs; do
+ # Activate any VG we found
+ lvm vgchange -ay $vg
+ done
+
+ lvs=$(lvm lvs | tail -n +2 | awk '{ print "/dev/" $2 "/" $1 }')
+ for lv in $lvs; do
+ tmpdir=$(mktemp -d findkeys.XXXXXX)
+ mkdir -p /tmp/${tmpdir}
+ mount $lv /tmp/${tmpdir} || continue # Skip to next volume if this fails
+
+ # Let's see if the keys are in there
+ if [ -d /tmp/${tmpdir}/etc/ssh ]; then
+ cp -a /tmp/${tmpdir}/etc/ssh/ssh_host* /tmp/ssh/
+ keys_found="yes"
+ umount /tmp/${tmpdir}
+ break # We're done!
+ fi
+ umount /tmp/${tmpdir}
+ rm -r /tmp/${tmpdir}
+ done
+
+ # And clean up..
+ for vg in $vgs; do
+ lvm vgchange -an $vg
+ done
+fi
+
# Loop until the ssh rpm is installed
if [ "$keys_found" = "yes" ]; then
while : ; do