Setting the customization script for virtual machines in VMware vCloud Director
search cancel

Setting the customization script for virtual machines in VMware vCloud Director

book

Article ID: 315387

calendar_today

Updated On:

Products

VMware Cloud Director

Issue/Introduction

Although there is information in the vCloud Director User's Guide about setting the customization script and that this script is called before and after customization, some additional information needs to be provided.


Environment

VMware Cloud Director 5.1.x
VMware Cloud Director 1.5.x
VMware Cloud Director 1.0.x
VMware Cloud Director 5.5.x

Resolution

In vCloud Director, when setting a customization script in a virtual machine, the script:
  • Is called only on initial customization and force recustomization.
  • Is called with the precustomization command line parameter before out-of-box customization begins.
  • Is called with the postcustomization command line parameter after out-of-box customization finishes.
  • Needs to be a batch file for Windows virtual machines and a shell script for Unix virtual machines.

Here are sample customization scripts for Windows and Unix and Linux virtual machines:

Windows sample batch file

@echo off
if "%1%" == "precustomization" (
echo Do precustomization tasks
) else if "%1%" == "postcustomization" (
echo Do postcustomization tasks
)
 
A Unix sample shell script
 
#!/bin/sh
if [ x$1 == x"precustomization" ]; then
echo Do Precustomization tasks
elif [ x$1 == x"postcustomization" ]; then
echo Do Postcustomization tasks
fi


Note: The length of customization script cannot be greater than 1500 characters.

A Linux sample shell script


#!/bin/sh
if [ x$1 == x"precustomization" ]; then
echo Do Precustomization tasks
elif [ x$1 == x"postcustomization" ]; then
echo Do Postcustomization tasks
fi

 
Note: "=" instead of "==" format works in most flavors of Linux. This format has been tested with SLES, RHEL, Ubuntu etc.

Additional Information

Configuring customization scripts for Linux VM in vSphere 7