1

In building a custom USB installer for Centos6.6 (not easy) I found that if the %post section of the kickstart file has backticks

  • Anaconda completes, but exits immediately to a blank screen (no video output), Normally it exits with a message saying Anaconda terminated, etc. and
  • Both anaconda-ks.log and the %post log file exist but have zero length.

This works

%pre --log=/root/postLog.log
echo "This is the post"
ls
%end

This doesn't work

%pre --log=/root/postLog.log
echo "This is the post"
echo `ls`
%end

This also doesn't work

%pre --log=/root/postLog.log
echo "This is the post"
echo $(ls)
%end

Why? I have a lot of things I need to do in the %post and not having command substituion/back tick support is going to make that more difficult.

Any workaround?

Edit: And why I need backticks?

The installer is for an appliance product so needs to install the base OS, custom OS rpms, and product rpms.

So in the %post section, something like this pattern is very common:

cd $ApplicationPackageDir
RPMLIST=`ls *.rpm`
RPMCOUNT=`ls *.rpm | /usr/bin/wc -l`

for theRpm in $RPMLIST
do
    echo /bin/rpm --quiet --upgrade --nodeps --force $theRpm
done

Similar pattern for generically doing something with whatever files exist in a particular directory.

The entire concept doesn't work if anaconda barfs on having a backtick in the file.

Besides, backtick is a valid bash operator – which kickstart seems to have trouble on.

Are bash backticks supposed to work in kickstart?

Edit II: Added $(ls) to example

Danny
  • 235
  • 3
  • 10
  • Don't use backticks? Can you give a better example of what you need in the %post section? You example isn't clear. – ewwhite Jun 13 '15 at 17:18
  • 1
    What if you use `echo $(ls)` ? Note that you can use a full script specifiying sha-bang or setting `--interpreter` : https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/3/html/System_Administration_Guide/s1-kickstart2-preinstallconfig.html – krisFR Jun 13 '15 at 17:21
  • Putting #!/bin/bash just after %post still has the same problem. I'll check out $(ls)... but is that a valid bash construct? – Danny Jun 13 '15 at 17:29
  • 2
    Backticks are supposed to be obsolete and used in old Bourne Shell. I am no saying it will work for you, but nowadays prefer `$()` : http://stackoverflow.com/questions/9405478/command-substitution-backticks-or-dollar-sign-paren-enclosed – krisFR Jun 13 '15 at 17:48
  • Doesn't answer the specific question about backtick support but you don't need them for that example. `for therpm in *.rpm; do` does the same thing. – Paul Haldane Jun 13 '15 at 22:01
  • Well, "teach an old dog..." I didn't know about the $(cmd) syntax. However, both forms are present in the bash manual on command substitution: http://www.gnu.org/software/bash/manual/bashref.html#Command-Substitution – Danny Jun 14 '15 at 01:49
  • What if you try `echo \$(ls)` ? – krisFR Jun 14 '15 at 13:01

0 Answers0