VMware Cloud Community
AureusStone
Expert
Expert

Can not get my postbuild working in vSphere.

I am trying to get my postbuild script working. I have used it in 3.5 and 3.0.2 and it works fine. I have been reading lots, but haven't been able to get it working. I am trying to run the scripts from an FTP, but it doesn't seem to work.

I would like to keep using the postbuild script, rather then merge the commands in to the kickstart.

  1. ----------------------------------------------------------------------------------------------------------------------------------->
  2. This section creates the host.cfg file that holds all the unique variables
  3. Update the below with the host specific settings from the config sheet.
  4. The following should be set to either Server or Workstation depending on
  5. The following variable can be one of the following: A B C D E F
  6. -----------------------<
%packages @base %post mkdir /vmimages/build cat >> //vmimages/build/build.sh << EOF1 #!/bin/sh logger "ESX Host Scripted Build - build.sh" echo "ESX Host Scripted Build..." cd /vmimages/build echo "Connecting to FTP server to collect build source files..." esxcfg-firewall --allowOutgoing ftp -n <<EOF6 open 10.20.12.2 user anonymous password cd /scripts/4.0 binary prompt mget postbuild.sh exit EOF6 needed by postbuild.sh to configure the server echo "Generating Custom Host config file..." echo "hwmodel=BL685 G1" > /vmimages/build/host.cfg echo "iphostname=vmtestesx7" >> /vmimages/build/host.cfg echo "ipdomain=test.com" >> /vmimages/build/host.cfg echo "ippridns=10.20.12.1" >> /vmimages/build/host.cfg echo "ipsecdns=10.20.12.2" >> /vmimages/build/host.cfg echo "vmotionip=10.21.168.7" >> /vmimages/build/host.cfg echo "vmotionnm=255.255.254.0" >> /vmimages/build/host.cfg echo "Contact=\"Me\"" >> /vmimages/build/host.cfg echo "Location=\"Test Lab\"" >> /vmimages/build/host.cfg which guest operating system the host will be hosting. echo "guestos=Server" >> /vmimages/build/host.cfg echo "environment=A" >> /vmimages/build/host.cfg echo "ntpserver1=10.20.12.20" >> /vmimages/build/host.cfg echo "ntpserver2=10.20.12.21" >> /vmimages/build/host.cfg echo "ntpserver3=10.20.12.22" >> /vmimages/build/host.cfg echo "prefer=prefer" >> /vmimages/build/host.cfg echo "scspeed=1000" >> /vmimages/build/host.cfg echo "dataspeed=1000" >> /vmimages/build/host.cfg echo "ftphost=10.20.12.2" >> /vmimages/build/host.cfg echo "esxPatchesPath=/patches/4.0" >> /vmimages/build/host.cfg chmod +x /vmimages/build/postbuild.sh sh /vmimages/build/postbuild.sh> /vmimages/build/postbuild.log EOF1 cp /etc/rc.d/rc.local /etc/rc.d/rc.local.sav echo "sh /vmimages/build/build.sh> /vmimages/build/build.log" > > /etc/rc.d/rc.local

Reply
0 Kudos
4 Replies
Vishy1
Enthusiast
Enthusiast

Try this

%post --interpreter=bash

If you found this information useful, please consider awarding points for Correct or Helpful.
Reply
0 Kudos
AureusStone
Expert
Expert

Thanks Vishy. I have tried that, but doesn't seem to make a differance. When I don't define bash, it seems that vSphere just defaults to bash.

Reply
0 Kudos
Vishy1
Enthusiast
Enthusiast

This site may help with ESX 4 scripting

http://blog.laspina.ca/ubiquitous/tag/esx-4-0

If you found this information useful, please consider awarding points for Correct or Helpful.
Reply
0 Kudos
Sreejesh_D
Virtuoso
Virtuoso

We have to metnion "%post --interpreter=bash" in KS file before the post install scripts.

See the following snippet of the KS file which we were using successfully.

-


vmaccepteula

reboot

rootpw test123456

timezone America/Los_Angeles

keyboard us

authconfig --enableshadow --enablemd5

bootloader --location=mbr

esxlocation --firstdisk=",local"

virtualdisk esxconsole --size=8000 --onfirstvmfs

part / --fstype=ext3 --size=5000 --onvirtualdisk=esxconsole

part swap --size=256 --grow --maxsize=512

--onvirtualdisk=esxconsole --fstype=swap

part /var/log --fstype=ext3 --size=500 --grow --maxsize=2000

--onvirtualdisk=esxconsole

%post --interpreter=bash

echo "Hello Bash!" > /bash_result.txt

ifup lo

esxcfg-vswitch -a VMSwitch

esxcfg-vswitch -A 'My VM Network' VMSwitch

esxcfg-vswitch -L vmnic33 VMSwitch

esxcfg-firewall --allowIncoming --allowOutgoing

cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak

-


Regards,

Sreejesh

Reply
0 Kudos