Trouble accepting user input in a kickstart script

General support questions
Post Reply
3tforms
Posts: 1
Joined: 2017/07/10 22:11:23

Trouble accepting user input in a kickstart script

Post by 3tforms » 2017/07/10 22:19:37

I am trying to prompt for the hostname in the pre portion of a kickstart file, but it doesn't seem to capture any input. the echoes/cat are just me testing output. The only thing that is printed is a blank line. What am I missing here?

Code: Select all

%pre --interpreter=/usr/bin/bash
exec < /dev/tty6 > /dev/tty6 2> /dev/tty6 chvt 6
IFS=$'\n'
read -p "Enter hostname: " HOSTNAME
echo $HOSTNAME
echo $HOSTNAME > /tmp/hostname.tmp
cat /tmp/hostname.tmp
sleep 5

chvt 1
exec < /dev/tty1 > /dev/tty1 2> /dev/tty1
%end
/code]

aks
Posts: 3032
Joined: 2014/09/20 11:22:14

Re: Trouble accepting user input in a kickstart script

Post by aks » 2017/07/11 15:51:07

Yeah I used to do that with C5/6, but I found it doesn't work in C7 KS. I ended up not prompting during KS and just passing values at the command line and/or reading data from an external DB. I *think* the whole thing might be handled by something like screen or tmux now.
Having said all that, sometime back I came across this: http://www.trueblade.com/techblog/user- ... -kickstart which *should* work as a nice little python script. Please let us know if it worked for you.

CaViCcHi
Posts: 68
Joined: 2012/04/18 17:03:15
Contact:

Re: Trouble accepting user input in a kickstart script

Post by CaViCcHi » 2017/07/11 17:57:50

I'd say leave alone the interpreter, at that point you can simply add the shebang below as the code is a bit buggy with interpreters (if you check out the boot logs you'll see a warning and fall back)

Code: Select all

%post --log=/root/post.log
#!/usr/bin/env bash
##
#
exec < /dev/tty6 > /dev/tty6
chvt 6
echo
echo " La la la... post installation blah blah..."
(
	your stuff...
)
) 2>&1 | /usr/bin/tee /root/post.log
chvt 1
#
%end


Post Reply

Return to “CentOS 7 - General Support”