At a minimum, init script needs to install java runtime.

Custom prepared images are suggested if initialization script is taking more than 20 minutes.

Below are the 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 entered then plugin will execute default powershell script which will work only if anonymous access is allowed for master machine.

If your master machine is configured with security options, refer to script https://gist.github.com/snallami/5aa9ea2c57836a3b3635 and edit it accordingly.