RE: preinstall section - how to backup ssh keys?

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

 



Is it required to have "--nochroot" in my "%post" section? I have a lot of other things in "%post" and am not currently using "--nochroot". I thought I should still be able to see the /tmp/ssh directory created in the "%pre" section, correct? It does not seem to work, though, since I do not see the /tmp/ssh directory in the "%post" section. I did an "ls -la" on /tmp in the "%post" section, and the only thing there was:
total 12
drwxrwxrwt    2 root     root         4096 Dec  2 10:48 .
drwxr-xr-x   21 root     root         4096 Dec  2 10:48 ..
-rwx------    1 root     root          157 Dec  2 10:48 ks-script

I would think I would at least see the directory since it should have been created with mkdir in the %pre section. Is this a different "/tmp" directory in the %post section than what was used in %pre?

Any ideas?

Jeff

From: Alf Wachsmann <alfw@xxxxxxxxxxxxxxxxx>
Reply-To: kickstart-list@xxxxxxxxxx
To: "'kickstart-list@xxxxxxxxxx'" <kickstart-list@xxxxxxxxxx>
Subject: RE: preinstall section - how to backup ssh keys?
Date: Tue, 02 Dec 2003 07:47:43 -0800 (PST)

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)
-----------------------------------------------------------------------


_______________________________________________
Kickstart-list mailing list
Kickstart-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/kickstart-list

_________________________________________________________________
Is there a gadget-lover on your gift list? MSN Shopping has lined up some good bets! http://shopping.msn.com




[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