[email protected] wrote:
> From: Jeff Schroeder <[email protected]>
>
> 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 <[email protected]>
> ---
> 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
>
Could the looping be eliminated by doing the top part in %pre and the
later in %post?
ex:
%pre
$SNIPPET('preserve_ssh_host_keys_pre')
%post
SNIPPET('preserve_ssh_host_keys_post')
I'd also encourage everyone else who has neat kickstart tricks to
contribute them. I like the idea of packaging more with Cobbler rather
than just keeping them on the Wiki.
--Michael
_______________________________________________
cobbler mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/cobbler