Init Scripts for VM

I’m attempting to understand how datastore init scripts files operate for contextuailization.

My idea is to write a bash script that installs some software on first boot only. I thought adding a shell script to the datastore and selecting it on the template would work.

I’ve read about VM_Hooks. However, from my understanding these are executed on every VM. While I only want to execute it on a specific VM, which is why I am adding it to the VM Template.

I am assuming the INIT_SCRIPTS

I’ve tried uploading a bash script (e.g., program-init.sh) and selecting it to no avail. Same with creating an ISO with the bash script and uploading it to the file datastore.

My question is, where does INIT_SCRIPTS look for an init.sh script? What is it expecting?

Hi, I used it in past. You have to upload you scripts to FILES type datastore and them select that “files” in VM tempalte and and set it as init_script. It will be automatically added to context cdrom and executed.

If you want execute only one, you can add some check to the start of the script.

Thanks for the reply. So let me get this straight, I need to do the following:

  1. So, you can upload a bash script, lets say named program-init.sh.
  2. You then select it as a context file for the VM I intend to use.
  3. In the textfield for INIT_SCRIPTS on this VM, I am to input program-init.sh

There is no special format for the files?

yes, when you adding new file form contains name field which should contain real file name (program-init.sh)

Okay, I wasn’t aware of that. Did I miss this in the documentation?

I don’t know, I figure out this by testing, so I was see what is in context cdrom.

Thanks. I’ll try it out and get back to you