LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-13-2015, 09:04 PM   #1
midnightoil
LQ Newbie
 
Registered: Jun 2015
Posts: 14

Rep: Reputation: Disabled
Blank log file if %post contains back tick or command substitution


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

Code:
%pre --log=/root/postLog.log
echo "This is the post"
ls
%end
This doesn't work

Code:
%pre --log=/root/postLog.log
echo "This is the post"
echo `ls`
%end
This also doesn't work

Code:
%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?

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:

Code:
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 using command substitution in the file.

Is command substitution supposed to work in kickstart?
 
Old 06-14-2015, 07:00 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Why not just
Code:
/bin/rpm --quiet --upgrade --nodeps --force /some/directory/*.rpm
or make /bin/bash execute a shell script? (BTW the use of --nodeps is, especially when combined with the use of --force, questionable IMO. If you are going to break stuff ensure it's for the right reasons, if any.)
 
Old 06-14-2015, 08:39 PM   #3
midnightoil
LQ Newbie
 
Registered: Jun 2015
Posts: 14

Original Poster
Rep: Reputation: Disabled
But its the empty log file...

Umm, yes, of course that would work. But my problem is anaconda not sending any output to any file.

Since the original post I've found all kinds of things that cause the problem to the extend that I don't know what's really the issue. The empty files applies to both --log=abc.log and any file created in the script itself.

So the script executes, it just doesn't produce output. ie.

Code:
%post
touch someFile  <--- file is created
echo Hello there > anotherFile <-- file is created but is empty
Same for
Code:
exec 1> anotherFile 2>&1
/bin/ls
Which commands don't work? No idea. I've spent 100 reboots trying to pin it down and it seems like a moving target!
 
Old 06-15-2015, 05:18 AM   #4
midnightoil
LQ Newbie
 
Registered: Jun 2015
Posts: 14

Original Poster
Rep: Reputation: Disabled
Something with SELINUX?

I tried this %post:

Code:
%post
touch dvmItsDoingSomething

exec < /dev/tty4 > /dev/tty4
chvt 4
set -x
echo 1 HELLO THERE
echo 2 and again
echo 3 and again again
echo 4 This goes to a file > /kstest_output.log
echo 5 And did it work?
echo 6 Installation Complete 
sleep 15
chvt 1
%end
And I can see that it does switch to VT4 and there is output from echo on the screen. Specifically:
Code:
1 HELLO THERE
2 and again
3 and again again
5 And did it work?
6 Installation Complete
But... after rebooting, there is no "kstest_output.log" file isn't anywhere on the drive. Neither was there the usual anaconda-log file nor the dvmItsDoingSomething file.

Further I tried adding "--log=test.log" to the %post line. In this case,
it did switch to VT4
No echo lines were output, and
again no log files created anywhere on the filesysytem

Could this be something with SELINUX?

The ks file specifically says "selinux --disabled". However, I note the output of VT4 shows:
Code:
DEBUG kernel: SELinux 2048 avtab bash slots, 294585 rules.
DEBUG kernal: SELinux 2048 avtab bash slots, 294585 rules.
DEBUG kernal: SELinux 2048 9 users, 12 rules 4142 types, 228 boots
DEBUG kernal: SELinux 81 classes, 294585 rules
which comes just before my echo output (when it works)

I tried putting 'sestatus' before the echo statements to see if it was enforcing, but then anaconda just stopped with none of my log output at all....
 
Old 06-17-2015, 11:55 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by midnightoil View Post
UBut my problem is anaconda not sending any output to any file.
Odd. What's the shell and what are the environment variables? Farfetched prolly but I'm wondering if you would be able to redirect syslog output over the 'net and capture it that way?..
 
Old 06-17-2015, 01:01 PM   #6
midnightoil
LQ Newbie
 
Registered: Jun 2015
Posts: 14

Original Poster
Rep: Reputation: Disabled
Shell?

Yup, very odd. Not sure what shell its using when you just put %post.

I've also tried
%post
#!/bin/bash

But no difference.

The syslog file does get created. But nothing noteworthy in there. Just can't get any output from the script following %post... (and of course troubleshooting take hours because its at the end of full Centos install where the problem surfaces)
 
Old 06-20-2015, 02:54 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by midnightoil View Post
Yup, very odd. Not sure what shell its using when you just put %post.
Just putingt the 'env' command in your %post section should show the envvars.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Tilde / back-tick key not giving me a tilde or back-tic. Ubuntu 10.04 on Macbook Pro BrianK Linux - Laptop and Netbook 3 09-01-2015 09:14 PM
How do I display a tick in a pdf document. The document uses forms with tick choices. philp1863 Linux - Software 5 09-25-2014 08:47 AM
Taking back up of log file for running process/ route Programming 3 02-18-2010 05:15 AM
Deleted log file - how to get back via file descriptor and keep alive? prollocks Linux - General 1 05-29-2009 09:08 AM
clicking back on failed post returns to blank textarea Uzma LQ Suggestions & Feedback 7 02-27-2006 12:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration