Using variables in kickstart file

Eric Sorenson ahpook at gmail.com
Thu Jul 19 17:47:34 UTC 2007


That is a very clever trick. Saved for future reference. Thank you Jason.

On 7/19/07, Jason Kohles <email at jasonkohles.com> wrote:
>
> 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 at dev1-mgmt-01 ~]# cat /proc/cmdline
> ro root=/dev/SystemVG/RootLV
> [root at dev1-mgmt-01 ~]# set -- `cat /proc/cmdline`
> [root at dev1-mgmt-01 ~]# for I in $*; do case "$I" in *=*) eval "$I";;
> esac; done
> [root at dev1-mgmt-01 ~]# echo $root
> /dev/SystemVG/RootLV
>
> --
> Jason Kohles
> email at jasonkohles.com
> http://www.jasonkohles.com/
> "A witty saying proves nothing."  -- Voltaire
>
>
> _______________________________________________
> Kickstart-list mailing list
> Kickstart-list at redhat.com
> https://www.redhat.com/mailman/listinfo/kickstart-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/kickstart-list/attachments/20070719/d384a354/attachment.htm>


More information about the Kickstart-list mailing list