Re: Using variables in kickstart file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jul 19, 2007, at 10:07 AM, Ed Brown wrote:

Use python instead.

Or perl. You can substitute any parameter name you want from /proc/ cmdline, in place of the string 'ip' in the example given earlier:

ip=`cat /proc/cmdline |perl -e 'if (<> =~ /\sip=(.*?)\s/) {print $1}'`

ESXIP=`cat /proc/cmdline |perl -e 'if (<> =~ /\sESXIP=(.*?)\s/) {print $1}'`


Or you can use the -n option to perl, which makes it work quite a bit like awk anyway (see the perlrun man page)...

ESXIP=`perl -ne '/ESXIP=(\S+)/ && print $1' /proc/cmdline`


What I usually do though, is just exploit bash to do the whole thing. Stick this at the top of a %pre/%post script, and it will take anything of the form var=value from /proc/cmdline and turn it into a variable you can use directly...

	set -- `cat /proc/cmdline`
	for I in $*; do case "$I" in *=*) eval $I;; esac; done


You can try it from the command line to see how it works...

[root@dev1-mgmt-01 ~]# cat /proc/cmdline
ro root=/dev/SystemVG/RootLV
[root@dev1-mgmt-01 ~]# set -- `cat /proc/cmdline`
[root@dev1-mgmt-01 ~]# for I in $*; do case "$I" in *=*) eval "$I";; esac; done
[root@dev1-mgmt-01 ~]# echo $root
/dev/SystemVG/RootLV

--
Jason Kohles
email@xxxxxxxxxxxxxxx
http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire



[Index of Archives]     [Red Hat General]     [CentOS Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux