Kickstart Post install script

 

KickstartPost install script

 

Syntax:

%post

Commands/code that need to run in post OS install as part of kickstart

%end

 

Example:

%post

mkdir /root/testfile

cp /etc/resolv.conf /etc/resolv.conf_backup

cd /var/tmp

wgethttp://1.1.1.1/samplefile.txt

clear

%post

 

Enable logging for post install

%post –log=/root/postinstall.log

%end

 

Execute custom scripts in post install

%post –log=/root/postinstall.log

cd /var/tmp

wgethttp://1.1.1.1/sample_script.sh  ## download our custom script

## execute script, but progress will be invisible

sh /var/tmp/sample_script.sh

%end

 

 

Interactive post install scripts:

Place following lines before the lines what want to see on screen and take user inputs.

%post

—-

—-

Myterminal=`tty`

exec<$ Myterminal>$ Myterminal 2>$ Myterminal

clear

—-

%end

Myterminalvariable above will take our current terminal. Next we are explicitly setting this scripts I/O to the tty’s standard descriptors.

 

Another process for interactive post install scripts

To switch automatically to whatever terminal we need, get shell prompt and redirect all I/O to tha terminal, in this example we’ll switch to terminal /console – 4

%post

## entering into interactive terminal in kickstart post install.

exec< /dev/tty4> /dev/tty4 2> /dev/tty4

chvt 4

# Get into a shell prompt

/bin/bash

# Please your script /echo /read command to display and take inputs from user interactively here

Echo “Enter your name: ”

read name

echo “Welcome to post install : “ $name

# Then switch back to Anaconda on the first console

chvt 1

exec< /dev/tty1 > /dev/tty1 2> /dev/tty1



%end