RE: preinstall section - how to backup ssh keys?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 1 Dec 2003, James Olin Oden wrote:
> On Mon, 1 Dec 2003, Robert Denton wrote:
>
> > The post script doesn't have to run in a chroot environment.  But it will if
> > you specify: '%post --chroot'
> It runs in chroot by default (%post that is).  To run in non-chroot
> specify: [ proposal deleted ]

Here is what we do. It avoids the rather ugly loop in the %pre section
to copy the data back.

-- Alf.


%pre

mkdir -p /mnt/oldroot
mkdir -p /tmp/ssh

if [ -b /dev/sda ] ; then
  disk="/dev/sda"
else
  disk="/dev/hda"
fi

mounted=""
for i in `/usr/sbin/fdisk -l $disk | grep -i linux | grep -v swap | cut -d" " -f 1`
{
  part=`/usr/sbin/e2label $i`
  if [ $part = "/" ] ; then
    mount $i /mnt/oldroot
    mounted="true"
  fi
}

if [ -d /mnt/oldroot/etc/ssh ] ; then
  cp -a /mnt/oldroot/etc/ssh/ssh_host_* /tmp/ssh/.
  echo "Copied old ssh keys"
else
  echo "No old ssh directory found"
fi

# Add other stuff here that needs to be copied
# like Kerberos keytab files etc.

if [ -n $mounted ] ; then
  umount /mnt/oldroot
fi



%post --nochroot

if [ -d /tmp/ssh ] ; then
  mv -f /tmp/ssh/ssh_host_* /mnt/sysimage/etc/ssh/.
  mv -f /tmp/ssh/*srv*      /mnt/sysimage/etc/.
  mv -f /tmp/ssh/*keytab    /mnt/sysimage/etc/.
fi



-----------------------------------------------------------------------
  Alf Wachsmann                       | e-mail: alfw@xxxxxxxxxxxxxxxxx
  SLAC Computing Service              | Phone:  +1-650-926-4802
  2575 Sand Hill Road, M/S 97         | FAX:    +1-650-926-3329
  Menlo Park, CA 94025, USA           | Office: Bldg. 50/323
-----------------------------------------------------------------------
                http://www.slac.stanford.edu/~alfw (PGP)
-----------------------------------------------------------------------




[Index of Archives]     [Red Hat General]     [CentOS Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux