Page 1 of 1

User input in Kickstart %post

Posted: 2019/07/31 04:34:10
by 0xliam
Hi there,

I'm creating a installer ISO for a CentOS 7 based appliance, and I am having issues with getting user input to work properly during the %post section.

I found this thread which seems to report the same behaviour - viewtopic.php?f=47&t=63280&p=266565.

The rest of my %post script works (to install various repos and call APIs, etc), but I want the user to be prompted to enter some details:

Here's the first part of our %post section:

Code: Select all

%post --logfile=/root/ks-post.log
set -x
exec < /dev/tty2 > /dev/tty2
chvt 2
echo "################################"
echo "# Running Post Configuration   #"
echo "################################"
hostname=""
vpn=""
while [[ "$HOSTNAME" == "" ]] || [[ "$vpn" == "" ]] ; do
    echo
    echo " *** Please enter the following details: *** "
    echo
    read -p "Hostname: " hostname
    read -p "VPN Provisioning ID: " vpn
done
Setting these variables statically lets the script continue, but when attempting to use the read command, nothing is displayed on the screen past the echo commands, and the terminal seems to lock up and not accept any input, and just sit in the while loop indefinitely.

I am assuming it was a problem using tty2, however I've tried changing this to various ttys between 1-5 and I experience the same behaviour.

For setting hostname I can get away with using the built-in GUI, but I would really like to be able to specify some other details (API keys, etc) during install.

Does anyone have a working example of user input during %post? Or is there documentation around which tty should be used to accept user input?

Cheers.

Re: User input in Kickstart %post

Posted: 2019/07/31 12:20:40
by Thraex
Do you have it as a text only kickstart install? That was the only way I got it to work I think.
You can do this with the following.

Code: Select all

iotty=`tty`
exec > $iotty 2> $iotty
clear
read -p "Enter the system's fully qualified name: " NAME
echo "$NAME" > /etc/hostname
echo "hostname set to $NAME "

Re: User input in Kickstart %post

Posted: 2019/07/31 17:51:07
by aks
I guess you can get input from another terminal (as in the above).
Perhaps you could just pass argument to the kernel load line and then scrape them from /proc/cmdline?
As far as I remember, the kernel doesn't bail out on non known args (it might print something like "what you talking about?"), but who cares?
Just don't use real kernel args (obviously).
Should work. Don't know, didn't try.

Re: User input in Kickstart %post

Posted: 2019/08/17 05:15:17
by 0xliam
Thraex wrote:
2019/07/31 12:20:40
Do you have it as a text only kickstart install? That was the only way I got it to work I think.
You can do this with the following.

Code: Select all

iotty=`tty`
exec > $iotty 2> $iotty
clear
read -p "Enter the system's fully qualified name: " NAME
echo "$NAME" > /etc/hostname
echo "hostname set to $NAME "
Sorry for the delayed reply - this worked perfectly! And I can confirm it works in graphical install too for both %pre and %post sections.

Re: User input in Kickstart %post

Posted: 2019/08/18 12:22:32
by tony_down_under
Great! thanks for posting back. I might use this. At the moment I am using the reconfig after install option and setting the hostname there, but sometimes it's missed. Your option may be better