At a minimum, the init script needs to install a Java runtime.
Custom prepared images are recommended if the initialization script is taking more than 20 minutes to execute.
Below are examples of initialization scripts:
1) Ubuntu
# Install Java
sudo apt-get -y update
sudo apt-get install -y openjdk-7-jdk
sudo apt-get -y update --fix-missing
sudo apt-get install -y openjdk-7-jdk
2) For Windows slaves with JNLP launch, if no init script is provided then Jenkins will execute the default PowerShell script,
which will work only if anonymous access is allowed for the master machine.
If your master machine is configured with security options, refer to this script:
https://gist.github.com/snallami/5aa9ea2c57836a3b3635
and edit it accordingly.