6

Trying to copy some files from my custom CentOS 7 install ISO to the new install in the %post section.

I've tried all of these:

cp /dev/cdrom/scripts/myscript.sh /etc/myscripts/myscript.sh
cp /dev/cdrom:/scripts/myscript.sh /etc/myscripts/myscript.sh
cp /mnt/sysimage/root/scripts/myscript.sh /etc/myscripts/myscript.sh
cp /scripts/myscript.sh /etc/myscripts/myscript.sh

But none of those end up with myscript.sh being in /etc/myscripts

Where does the install mount the cdrom?

UPDATE

I've tried:

%post --nochroot

#!/bin/sh

set -x -v

cp -r /run/install/repo/scripts/myscript.sh /mnt/sysimage/etc/httpd/conf/myscript.sh

which results in the install not booting (just hangs on the splash)

UPDATE 2

Simply doing:

%post --nochroot

cp -r /run/install/repo/scripts/myscritp.sh /mnt/sysimage/etc/myscritp.sh

%end

Works and the file is copied from the install media isolinux/scripts dir to the /etc directory on the install target filesystem.

Kiksy
  • 327
  • 1
  • 5
  • 11
  • Unless it changed for EL7, the path for the CD mountpoint is `/mnt/source`. Also, please reconsider placing scripts under `/etc`. (Refer to the [FHS](http://www.pathname.com/fhs/pub/fhs-2.3.html#USRLOCALLOCALHIERARCHY).) – Aaron Copley Jun 22 '15 at 15:26
  • @AaronCopley, you may be thinking of `/mnt/install`, which is (at least as of EL7 when I write this) a symlink to `/run/install`. `/run/install/repo` is indeed where the installation source ISO is mounted. `/mnt/sysimage` is the root of the newly-installed system. – Kenyon May 02 '18 at 21:37

1 Answers1

6

The %post section won't do what you need without some extra work - you need to do this copy inside a %post --nochroot section so you have access to the CD. You can probably issue a mount command inside %post, but using %post --nochroot is likely easier. I don't remember the source ISO layout offhand, but it'll be there somewhere.

John
  • 8,920
  • 1
  • 28
  • 34
  • I was pretty sure that media was still available under %post, but it's been a while. If this ends up being the case, @Kiksy, make sure to copy to `/mnt/sysimage/etc/myscripts` due to using `nochroot`. – Aaron Copley Jun 22 '15 at 15:29