2017年3月29日 星期三

kickstart pre-install script example

KS parameters defined here will be overwritten if parameter is defined in the global section.
Allow to separate parameter setup to different include files.

Development flow:
  Boot from CD-ROM and add ks=xxx to the boot option.
  After entering KS stage, hit Ctrl + Alt + F2 to enter shell for debugging
  Pre-install script will be placed at /tmp/ks-script-xxxxx


%pre --log=/tmp/pre.log
#!/bin/sh
for hdd in $(ls /sys/class/block/*/device/model 2>/dev/null);do
  hdd_model=$(cat $hdd|sed 's/ //g')
  echo "#Path: $hdd     Model: [$hdd_model]" >> /tmp/part-include

  if [ "$hdd_model" = "GGInInDer" ];then
      echo "#HDD model $hdd_model" > /tmp/part-include
      echo ignoredisk --only-use=$(echo $hdd|cut -d'/' -f5) >> /tmp/part-include
      echo "url --url=\"ftp://10.5.15.10/rhel71\"" >> /tmp/url-include
  fi
done
%end
%include /tmp/part-include
%include /tmp/url-include