Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-15-2014, 08:10 AM   #1
Registered: Jul 2013
Posts: 213

Rep: Reputation: Disabled
run .sh script using %post in kickstart file

i want to run a script using kickstart in it's %post section but when installation is completed, it is not running.

mkdir /mnt/temp 
mount -o nolock /mnt/temp 
openvt -s -w -- /mnt/temp/
umount /mnt/temp

Old 01-15-2014, 08:44 AM   #2
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 5,825
Blog Entries: 12

Rep: Reputation: 2008Reputation: 2008Reputation: 2008Reputation: 2008Reputation: 2008Reputation: 2008Reputation: 2008Reputation: 2008Reputation: 2008Reputation: 2008Reputation: 2008
Answering for the script part since I don't know kickstart.

I wonder how you know that it's not running; whether that be "the results didn't happen" or some log file complaint that the script wasn't run for some reason. Remember that mount may require root or better yet, sudo privileges. To do sudo in a script you may have to set it up so that the user id running the script can perform sudo without needing the password. Or at least verify that root is the ID running the script.

To debug I'd recommend you place output into a log file.

Add an echo line at the top of the script, output stdout and stderr to that same log file. See if you can get the user ID and runlevel when this script is running. This way you can determine (A) if the script is running at all, and (B) if steps in the script are not working because of circumstances you didn't foresee.


# Obviously replace <username> in all this with a user ID directory which you know the script can access.

echo "Post kickstart script running." >> /home/<username>/post-ks.log;
echo "Script run by user: $USER/`/usr/bin/whoami`.  At runlevel: $RUNLEVEL/`/usr/bin/who -r`" >> /home/<username>/post-ks.log;

# I use both $USER and whoami because the $USER variable may not be populated.
# I also use both $RUNLEVEL and who -r for the same reason, and many times $RUNLEVEL is NOT populated.
# No guarantees that you'll learn much except that the script did or didn't run, but if it's being run by user <blah-blah> and
# that user is nothing you've ever heard of, and also does not have the privileges to just execute mount without sudo privileges,
# then that would be a problem.  I'd also consider finding the path and using exacting paths for all shell commands.

/bin/mkdir -p /mnt/temp &>> /home/<username>/post-ks.log;

# Get stdout and stderr into your log and find out if there was a problem creating this directory, also use the -p argument
# because it will not complain if the parent wasn't there and also will not complain if /mnt/temp already exists.

/bin/mount -o nolock /mnt/temp &>> /home/<username>/post-ks.log;

# Should that say public?  I think a simple typo which may or may not be in the script by the way, get stdout and stderr

/bin/openvt -s -w -- /mnt/temp/ &>> /home/<username>/post-ks.log;

/bin/umount /mnt/temp &>> /home/<username>/post-ks.log;

# NOTE that you umount here but you don't remove the directory; hence when you try to create that directory with mkdir, it will
# cause an error because the second time and beyond, that directory exists, and the script will likely exit at that point.

# After ANY shell command, the variable $? contains the result.  Zero means it worked, any other value means it probably didn't
# work.  So you can have an echo include saying stuff like:

echo "Result of umount was $?" >> /home/<username>/post-ks.log;



Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] kickstart %post script help tripialos Linux - Newbie 2 08-20-2013 08:34 AM
kickstart %post fails to run only1rb Linux - Newbie 6 01-07-2013 05:23 PM
[SOLVED] Trouble with kickstart file's post script section FatKang Red Hat 2 11-30-2012 10:41 AM
Post script in kickstart qiuzhihong Linux - Software 1 04-19-2008 04:52 AM
Unable to run post-Installation kickstart scripts zoulo Linux - Enterprise 0 07-05-2005 04:26 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:09 PM.

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