Jeff Schroeder wrote:
On Fri, Feb 6, 2009 at 11:01 AM, Michael DeHaan
<mdehaan(a)redhat.com> wrote:
> jeffschroed(a)gmail.com wrote:
>
>> From: Jeff Schroeder <jeffschroeder(a)computer.org>
>>
>> The original idea is from Garrick Staples @ USC. My implementation is
>> designed to work on crazy raid controllers like in HP servers that show
>> /dev/cciss/c0d0 or normal servers that show /dev/sda. This assumes that
>> the list-harddrives command is available. It is part of anaconda and
>> might not be available on SUSE or other non Redhat based distributions.
>>
>> Signed-off-by: Jeff Schroeder <jeffschroeder(a)computer.org>
>> ---
>> snippets/keep_ssh_host_keys | 44
>> +++++++++++++++++++++++++++++++++++++++++++
>> 1 files changed, 44 insertions(+), 0 deletions(-)
>> create mode 100644 snippets/keep_ssh_host_keys
>>
>> diff --git a/snippets/keep_ssh_host_keys b/snippets/keep_ssh_host_keys
>> new file mode 100644
>> index 0000000..93a6fad
>> --- /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
>>
>>
> Applied to devel, thanks!
>
Perhaps my git-foo is lacking or something is missing :)
Really? Check git.