summaryrefslogtreecommitdiffstats
path: root/snippets/keep_ssh_host_keys
diff options
context:
space:
mode:
authorJames Cammarata <jimi@sngx.net>2009-03-07 21:44:00 -0600
committerJames Cammarata <jimi@sngx.net>2009-03-07 21:44:00 -0600
commitd3fdc6d4965b02ce18346f067c14080115943a38 (patch)
treed2fa630d3f0e941acb7f5115c31ea91aabb4ae11 /snippets/keep_ssh_host_keys
parent54e462f3dca472d8bb8dc8a2b0a69c60ed9fe2ec (diff)
parent61db7baa541acc32b305ea6977a14ee8f5b3f470 (diff)
downloadcobbler-d3fdc6d4965b02ce18346f067c14080115943a38.tar.gz
cobbler-d3fdc6d4965b02ce18346f067c14080115943a38.tar.xz
cobbler-d3fdc6d4965b02ce18346f067c14080115943a38.zip
Merge branch 'devel' of git://git.fedorahosted.org/cobbler into ris-devel
Conflicts: cobbler/utils.py
Diffstat (limited to 'snippets/keep_ssh_host_keys')
-rw-r--r--snippets/keep_ssh_host_keys44
1 files changed, 44 insertions, 0 deletions
diff --git a/snippets/keep_ssh_host_keys b/snippets/keep_ssh_host_keys
new file mode 100644
index 00000000..93a6fadb
--- /dev/null
+++ b/snippets/keep_ssh_host_keys
@@ -0,0 +1,44 @@
+#raw
+# Nifty trick to restore ssh keys without using a nochroot %post
+
+echo "Saving ssh host keys..." > /dev/ttyS0
+
+keys_found=no
+
+insmod /lib/jbd.o
+insmod /lib/ext3.o
+
+drives=$(list-harddrives | awk '{print $1}')
+for disk in $drives; do
+ DISKS="$DISKS $(fdisk -l /dev/$disk | awk '/^\/dev/{print $1}')"
+done
+
+for disk in $DISKS; do
+ name=$(basename $disk)
+ mkdir -p /tmp/$name /tmp/ssh
+ mount $disk /tmp/$name
+ [ $? -eq 0 ] || continue # Skip to the next partition if the mount fails
+
+ # Copy current ssh host keys out to be reused
+ if [ -d /tmp/${name}/etc/ssh ]; then
+ cp -a /tmp/${name}/etc/ssh/ssh_host* /tmp/ssh
+ keys_found="yes"
+ umount /tmp/$name
+ break
+ fi
+ umount /tmp/$name
+ rm -r /tmp/$name
+done
+
+# Loop until the ssh rpm is installed
+if [ "$keys_found" = "yes" ]; then
+ while : ; do
+ sleep 10
+ if [ -d /mnt/sysimage/etc/ssh ] ; then
+ cp -f /tmp/ssh/ssh_host* /mnt/sysimage/etc/ssh/
+ logger "SSH-HOST-KEY copied to newly installed system"
+ break
+ fi
+ done &
+fi
+#end