#------------------------------------------------------------------------------- # This PHP should be called from a kickstart config file in the %post section. # The output of this script will be a shell script which is customized based # on the arguments passed in by kickstart. # # Kickstart won't let you use '?' in a %ksappend URL apparently, so you can't # use query_string and must use path_info instead. However, I've abandoned the # %ksappend macro anyway. I know call this script like this: # # wget -O /root/ks-post-config.sh \ # "http://ks/ks-server.php?mac=${MAC_ADDR}&dist=${DIST}" # chmod 700 /root/ks-post-config.sh # /root/ks-post-config.sh # # This script assumes a directory structure something like this: # # [root@noc ks]# find scripts # scripts # scripts/fc4 # scripts/fc4/ks-fc4-mac-00-09-3D-10-FF-FF.sh # scripts/fc4/ks-fc4-yum-config.sh # scripts/fc4/ks-fc4-mac-00-09-3D-11-FF-FF.sh # scripts/fc4/ks-fc4-buildhost.sh # scripts/fc4/ks-fc4-yum-rt.sh # scripts/fc4/ks-fc4-mac-00-09-3D-12-FF-FF.sh # scripts/fc4/ks-fc4-scsi-fix.sh # scripts/fc4/ks-fc4-yum-update.sh # scripts/fc4/ks-fc4-ntp-config.sh # scripts/fc4/ks-fc4-grub-config.sh # scripts/fc4/ks-fc4-yum-prune.sh # scripts/fc4/ks-fc4-yum-fw.sh # scripts/fc5 # scripts/fc5/ks-fc5-yum-update.sh # scripts/fc5/ks-fc5-yum-config.sh # scripts/fc5/ks-fc5-chkconfig.sh # scripts/fc5/ks-fc5-sysctl.sh # scripts/fc5/ks-fc5-grub-config.sh # # Tue Jun 12 17:32:18 PDT 2007 # - quick hack to support F7 which dropped the core # - identify Xen hosts by their MAC # Thu Sep 28 14:51:08 PDT 2006 # - intial public release # ################################################################################ /* i'm switching to query_string, but you'll need this if you use %ksappend $path_info=$_SERVER['PATH_INFO']; $path_info=preg_replace('/^\//', '', $path_info); $components=explode('&',$path_info); foreach ($components as $pair) { list($key, $val) = explode('=',$pair); $INPUT[$key] = $val; } */ $INPUT['mac'] = $_REQUEST['mac']; $INPUT['dist'] = $_REQUEST['dist']; $mac_addr=$INPUT['mac']; # mac must look like this: 00-09-3D-12-FF-FF if (! preg_match( '/^[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}$/', $mac_addr)) { $mac_addr=0; } # we set our Xen MACs to be aa:00.... if (! preg_match('/^aa:/i',$mac_addr) { $arch='xen'; } # Dist may only be fc#. Default is fc4 if ($INPUT['dist'] && ! preg_match('/^f.?[0-9]\$/',$INPUT['dist'])) { $dist=$INPUT['dist']; } else { $dist='fc4'; } $dir='/var/www/html/ks/scripts/' . $dist; # files should be served in the following order $config_files = array( 'ks-' . $dist . '-chkconfig.sh', 'ks-' . $dist . '-sysctl.sh', 'ks-' . $dist . '-grub-config.sh', 'ks-' . $dist . '-ntp-config.sh', 'ks-' . $dist . '-scsi-fix.sh', 'ks-' . $dist . '-mkinitrd-fix.sh', 'ks-' . $dist . '-yum-config.sh', 'ks-' . $dist . '-yum-prune.sh', 'ks-' . $dist . '-yum-update.sh'); if ( strlen($mac_addr)==17 ) { array_push($config_files, 'ks-' . $dist . '-mac-' . $mac_addr . '.sh'); } # concatenate all the appropriate scripts and spit them out foreach ($config_files as $file) { $filename=$dir . "/" . $file; $fh = fopen ($filename, "r"); if (! $fh) { print "# " . $_SERVER['PHP_SELF'] . " Failed to open $filename\n"; } $contents = fread($fh, filesize($filename)); print $contents; } ?>