Thank you, Alf!
I am now able to get this working using your examples. Here is how i'm
doing it:
# section from kickstart file:
%pre
mkdir -p /tmp/sshkeys
mkdir -p /mnt/oldroot
mount /dev/hda2 /mnt/oldroot
cp /mnt/oldroot/etc/ssh/ssh_host_* /tmp/sshkeys
umount /mnt/oldroot
%post --nochroot
cp /tmp/sshkeys/* /mnt/sysimage/etc/ssh
%post
# other chroot stuff goes here (patches, other rpms, etc...)
(/dev/hda2 is our root partition on all our kickstarted PCs.)
I did discover that if you use both a "%post" and "%post --nochroot"
section, the "%post --nochroot" section apparently MUST come before the
"%post" section. It did not seem to work when I had the "%post" and then
the "%post --nochroot" after it. (This is only if you have code that is
needed in the nonchroot and chroot environments.)
Thanks again everyone for the suggestions.
Jeff
From: Alf Wachsmann <alfw@xxxxxxxxxxxxxxxxx>
Reply-To: kickstart-list@xxxxxxxxxx
To: kickstart-list@xxxxxxxxxx
Subject: RE: preinstall section - how to backup ssh keys?
Date: Tue, 02 Dec 2003 11:07:32 -0800 (PST)
On Tue, 2 Dec 2003, Crow69 aka thedude wrote:
> 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
That does not work.
In your chroot-ed %post section you only see your new system.
The solution for your problem are two %post sections: your original
one and the new with "--nochroot". Kickstart will execute them both.
-- Alf.
> 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
>
>
> _______________________________________________
> Kickstart-list mailing list
> Kickstart-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/kickstart-list
>
-----------------------------------------------------------------------
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
_________________________________________________________________
Has one of the new viruses infected your computer? Find out with a FREE
online computer virus scan from McAfee. Take the FreeScan now!
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963