Hi There... I've stripped it down as much as possible, as you can see I'm defining 2 disks however I cannot gaurentee that these 2 disks will always exist and am looking for something more dynamic, i.e find a way of scanning for them at pre-setup time and manually setting it up if it exists, as these are scsi devices I'm trying to associate the sda / sdb to what would be the correct luns etc which would be used in defining the rootvg and datavg etc.? Excuse the perl not had time to clean it up, but this would be used to validate / build websphere volumes based on build time parameters I pick up from /proc/cmdline and if there is the existance of an additional volume group build on that otherwise build on rootvg. As always any help would be greatly appreciated. install text network --bootproto dhcp lang en_US keyboard uk zerombr clearpart --all part /boot --fstype ext3 --size=100 --ondisk=sda part pv.00 --size=0 --grow --ondisk=sda part pv.01 --size=0 --grow --ondisk=sdb volgroup datavg --pesize=32768 pv.01 volgroup rootvg --pesize=32768 pv.00 logvol / --fstype ext3 --name=rootlv --vgname=rootvg --size=2048 logvol /home --fstype ext3 --name=homelv --vgname=rootvg --size=2048 logvol /opt --fstype ext3 --name=optlv --vgname=rootvg --size=1280 logvol /tmp --fstype ext3 --name=tmplv --vgname=rootvg --size=128 logvol /usr --fstype ext3 --name=usrlv --vgname=rootvg --size=5120 logvol /var --fstype ext3 --name=varlv --vgname=rootvg --size=2048 logvol swap --fstype swap --name=paginglv --vgname=rootvg --size=2048 bootloader --location mbr timezone Europe/London auth --enablemd5 --enableshadow rootpw --iscrypted XXXXXXXX selinux --disabled reboot firewall --disabled skipx key --skip %packages bridge-utils libXp @ Base compat-libstdc++-33 device-mapper-multipath %pre %post --nochroot ( set -x mkdir /mnt/sysimage/tmp/ks-tree-copy if [ -d /oldtmp/ks-tree-shadow ]; then cp -fa /oldtmp/ks-tree-shadow/* /mnt/sysimage/tmp/ks-tree-copy elif [ -d /tmp/ks-tree-shadow ]; then cp -fa /tmp/ks-tree-shadow/* /mnt/sysimage/tmp/ks-tree-copy fi cp /etc/resolv.conf /mnt/sysimage/etc/resolv.conf cp -f /tmp/ks-pre.log /mnt/sysimage/root/ ) >> /mnt/sysimage/root/ks-post.log 2>&1 %post ( # Log %post errors rhn_check ) >> /root/ks-post.log 2>&1 # Start post_install_network_config generated code # End post_install_network_config generated code # MOTD echo >> /etc/motd echo "RHN Satellite kickstart on $(date +'%Y-%m-%d')" >> /etc/motd echo >> /etc/motd # end of generated kickstart file %post --interpreter /usr/bin/perl my $vg_data = "datavg"; my $backup_vg = "rootvg"; my $vgs = '/usr/sbin/vgs'; sub extract_bootparam{ open (DATA, "/proc/cmdline") or die "cannot open file $!\n"; my @item=split(/[ ]+/,<DATA>); for (@item){ chomp; next if !/^name|role/; push(@bp_array,$_); } close (DATA); return (@bp_array); } sub validate_bootparam{ (my $item1,my $item2)=@_; if ( ($item1 eq "") || ($item2 eq "")){ die "No Defined Boot Parameters [ name=<name> role=<roletype> ]";} (my $item1a,my $item1b)=split('=',$item1); (my $item2a,my $item2b)=split('=',$item2); if (($item1a =~ /name/)&&($item2a =~ /role/)){return ($item1b,$item2b);} elsif (($item2a =~ /name/) && ($item1a =~ /role/)){return ($item2b,$item1b);} else{die "No Defined Boot Parameters [ name=<name> role=<roletype> ]";} } sub validate_vg{ print "Validate Volume Group : $vg_data\n"; my $result_vg=`$vgs --options vg_name --noheadings $vg_data 2>&1`; if ( $result_vg =~ /not found/ ){ print "ERROR!! $result_vg Attempting to validate rootvg\n"; $vg_data=$backup_vg; my $result_vg=`$vgs --options vg_name --noheadings $vg_data 2>&1`; if ( $result_vg =~ /not found/ ){ die "ERROR!! $result_vg.. Exiting...\n"; }else{ print "$vg_data has been validated... continuing\n"; } } open(VG_DATA,"$vgs --options vg_name,vg_free --noheadings --units M $vg_data 2>/dev/null|") or die "LVM Error: $!"; for (<VG_DATA>){; chomp; s/^\s+//; (my $item1, my $item2)=split(/[ ]+/,$_); return((split(/\./,$item2))[0]); } close (VG_DATA); } sub create_group{ (my $item1, my $item2)=@_; print "Create Group\n"; print "============\n"; my $item1_gname=(getgrnam($item1))[0]; my $item2_gid=(getgrgid($item2))[2]; if ( $item1_gname eq $item1 ){ print "ERROR!! Group $item1 not created, group already exists...\n"; }elsif ( $item2_gid == $item2 ){ print "ERROR!! Group $item1 not created, group-id already exists ...\n"; }else{ my $result_grp=`/usr/sbin/groupadd -g $item2 $item1 2>&1`; if ( $result_grp =~ /exists|unique/){print "ERROR!! Creating group $item1 : $result_grp";} else {print "Group $item1 has been created \n";} } } sub create_user{ (my $item1, my $item2, my $item3, my $item4)=@_; print "Create User\n"; print "===========\n"; my $item1_uname=(getpwnam($item1))[0]; my $item2_uid=(getpwuid($item2))[2]; my $item3_gid=(getgrgid($item3))[2]; if ( $item1_uname eq $item1){ print "ERROR!! User $item1 not created, user already exists...\n"; }elsif ( $item2_uid == $item2){ print "ERROR!! User $item1 not created, user-id validation problem...\n"; }elsif ( $item3_gid != $item3){ print "ERROR!! User $item1 not created, group-id validation problem...\n"; }else{ my $result_usr=`/usr/sbin/useradd -u $item2 -g $item3 -c $item4 -b /home -m $item1 2>&1`; if ( ($result_usr =~ /exists|unique/ )&&( $result_usr !~ /mailbox/) ){print "Cannot add user $item1 : $result_usr";} else{print "User $item1 has been created\n";} } } sub create_perms{ (my $item1, my $item2, my $item3)=@_; print "Create Perms\n"; print "============\n"; my $item1_uname=(getpwnam($item2))[0]; my $item2_gid=(getgrgid($item3))[2]; if ( -d $item1){ if ( ($item1_uname eq $item2) && ($item2_uid == $item3) ){ print "user $item2 and group $item3 exist...\n"; my $result_perm=`/bin/chown -R ${item2}:${$item3} ${item1}`; if ( $result_perm =~/invalid [user|group]/){print "ERROR!! Unable to change permissions\n";} else {print "Permissions have been changed \n";} }else{print "ERROR!! User/Group ($item2:$item3) validation has occured, unable to change permissions\n";} }else{print "ERROR!! Permissions for $item1 unchanged directory doesn't exist..\n";} } sub create_clientlv{ (my $item1, my $item2,my $item3,my $item4,my $item5,my $item6)=@_; my $lv_curr_free=&validate_vg(); if ( $item4 > $lv_curr_free ){ $item4=($lv_curr_free - ($lv_curr_free % 2))/2;} if ( (length($item5)==1) && ($item5=~/\//)){$item5="";} if ( $item6 eq "" ){ print "Creating Logical Volume /dev/${vg_data}/${item3}61${item1}\n"; my $result_lv=`/usr/sbin/lvcreate --size ${item4} --name ${item3}61${item1} $vg_data 2>&1`; if ( $result_lv =~ /create/){ print "Formatting Logical Volume ${item3}61${item1}\n"; my $result_mk=`/sbin/mkfs.ext3 /dev/${vg_data}/${item3}61${item1} 2>&1`; print "Validating Filesystem ${item5}/${item3}61${item1}\n"; if ( -d "${item5}/${item3}61${item1}" ){ print "ERROR!! ${item5}/${item3}61${item1} already exists...\n";} else{ print "Creating Filesystem ${item5}/${item3}61${item1}\n"; my $result_fstab=`/bin/echo -e "/dev/${vg_data}/${item3}61${item1}\t${item5}/${item3}61${item1}\t\text3 \tdefaults\t1 2" >> /etc/fstab`; my $result_dir=`/bin/mkdir -p ${item5}/${item3}61${item1} 2>&1`; if ( $result_dir =~ /cannot create directory/ ){print "ERROR!! $result_dir\n";} else{ my $result_mnt=`/bin/mount ${item5}/${item3}61${item1}`; printf "Exit code %d",$? >> 8;} } }else {print "ERROR!! ${item3}61${item1} already exists...\n";} }elsif( $item6 eq "-" ){ print "Creating Logical Volume /dev/${vg_data}/${item3}\n"; my $result_lv=`/usr/sbin/lvcreate --size ${item4} --name ${item3} $vg_data 2>&1`; if ( $result_lv =~ /create/ ){ print "Formatting Logical Volume ${item3}\n"; my $result_mk=`/sbin/mkfs.ext3 /dev/${vg_data}/${item3} 2>&1`; print "Validating Filesystem ${item5}/${item3}\n"; if ( -d "${item5}/${item3}" ){ print "ERROR!! ${item5}/${item3} already exists...\n"; } else{ print "Creating Filesystem ${item5}/${item3}\n"; my $result_fstab=`/bin/echo -e "/dev/${vg_data}/${item3}\t${item5}/${item3}\t\text3\tdefaults\t1 2" >> /etc/fstab`; my $result_dir=`/bin/mkdir -p ${item5}/${item3} 2>&1`; if ( $result_dir =~ /cannot create directory/ ){print "ERROR!! $result_dir\n";} else{my $result_mnt=`/bin/mount ${item5}/${item3}`;printf "Exit Code %d",$? >>8;} } }else {print "ERROR!! ${item5}/${item3} already exists...\n";} }else{ print "Creating Logical Volume /dev/${vg_data}/${item3}61${item1}${item6}\n"; my $result_lv=`/usr/sbin/lvcreate --size ${item4} --name ${item3}61${item1}_${item6} $vg_data 2>&1`; if ( $result_lv =~ /create/ ){ print "Formatting Logical Volume ${item3}61${item1}${item6}\n"; my $result_mk=`/sbin/mkfs.ext3 /dev/${vg_data}/${item3}61${item1}_${item6} 2>&1`; print "Validating Filesystem ${item5}/${item3}61${item1}/${item6}\n"; if ( -d "${item5}/${item3}61${item1}/${item6}" ){print "ERROR!! ${item5}/${item3}61${item1}/${item6} already exists...\n"} else{ print "Creating Filesystem ${item5}/${item3}61${item1}/${item6}\n"; my $result_fstab=`/bin/echo -e "/dev/${vg_data}/${item3}61${item1}_${item6}\t${item5}/${item3}61${item1 }/${item6}\t\text3\tdefaults\t1 2" >> /etc/fstab`; my $result_dir=`/bin/mkdir -p ${item5}/${item3}61${item1}/${item6}`; if ( $result_dir =~ /cannot create directory/ ){print "ERROR!! $result_dir\n";} else{my $result_mnt=`/bin/mount ${item5}/${item3}61${item1}/${item6}`;printf "Exit Code %d",$? >> 8;} } }else {print "ERROR!! ${item3}61${item1}${item6} already exists...\n"; } } } sub define_clientlv{ (my $item1, my $item2)=@_; print "Create Standard Filesystems\n"; &create_clientlv($item1,$item2,"logs",2048,"/","-"); &create_clientlv($item1,$item2,"scripts",256,"/","-"); &create_clientlv($item1,$item2,"scratch",2048,"/","-"); if ( $item2 eq "IHS" ){ &create_clientlv($item1,$item2,"plg",10240,"/usr/websphere"); &create_perms("/usr/websphere","webadmin","webadms"); }elsif ( $item2 eq "WAS" ){ &create_group("dba",209); &create_user("oracle",1001,40112,"Oracle"); &create_clientlv($item1,$item2,"ndb",10240,"/usr/websphere"); &create_clientlv($item1,$item2,"was",10240,"/usr/websphere","AppServer") ; &create_clientlv($item1,$item2,"u01",5128,"/","-"); &create_perms("/u01","oracle","dba"); }elsif ( $item2 eq "WDM" ){ &create_clientlv($item1,$item2,"ndb",4096); &create_clientlv($item1,$item2,"was",4096,"/","DeploymentManager"); }else{die "No Valid Role Defined : $item2\n";} } (my @bootparam_val1)=&extract_bootparam(); (my $name,my $role)=&validate_bootparam(@bootparam_val1); &define_clientlv($name,$role); -----Original Message----- From: kickstart-list-bounces@xxxxxxxxxx [mailto:kickstart-list-bounces@xxxxxxxxxx] On Behalf Of Chris Lumens Sent: 27 August 2010 15:52 To: kickstart-list@xxxxxxxxxx Subject: Re: harddrive in %pre > I am writing a script to install from a USB key, however it appears as > a different device on several different systems, so I put the harddisk > command into an include, generated by the %pre area, however the > system seems to be ignoring this - is there a way to make it work, or > are there commands which just can't be put into includes? Any of the method selection commands (harddrive/nfs/url/cdrom) are the only ones that cannot be put in an include. There are ways to do what you're trying to do, but I'll need a little more context to make a suggestion. Can you post your kickstart file, minus any sensitive information? - Chris _______________________________________________ Kickstart-list mailing list Kickstart-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/kickstart-list ----------------------------------------------------------------------------------------------------- Lloyds TSB Bank plc. Registered Office: 25 Gresham Street, London EC2V 7HN. Registered in England and Wales, number 2065. Telephone: 020 7626 1500. Bank of Scotland plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 327000. Telephone: 0870 600 5000 Lloyds TSB Scotland plc. Registered Office: Henry Duncan House, 120 George Street, Edinburgh EH2 4LH. Registered in Scotland, number 95237. Telephone: 0131 225 4555. Cheltenham & Gloucester plc. Registered Office: Barnett Way, Gloucester GL4 3RL. Registered in England and Wales, number 2299428. Telephone: 01452 372372. Lloyds TSB Bank plc, Lloyds TSB Scotland plc, Bank of Scotland plc and Cheltenham & Gloucester plc are authorised and regulated by the Financial Services Authority. Halifax is a division of Bank of Scotland plc. Cheltenham & Gloucester Savings is a division of Lloyds TSB Bank plc. HBOS plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 218813. Telephone: 0870 600 5000 Lloyds Banking Group plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 95000. Telephone: 0131 225 4555 This e-mail (including any attachments) is private and confidential and may contain privileged material. If you have received this e-mail in error, please notify the sender and delete it (including any attachments) immediately. You must not copy, distribute, disclose or use any of the information in it or any attachments. Telephone calls may be monitored or recorded. ============================================================================== _______________________________________________ Kickstart-list mailing list Kickstart-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/kickstart-list