Use of pre_postinstall_file in definition.rb

RodolpheB edited this page Jun 8, 2012 · 1 revision

pre_postinstall_file allows you to execute an arbitary script before each postinstall_file.

Main purpose was to allow set up of proxy environnment variable for the build of a vagrant box via veewee, without having to persist those modifications in the template box.

Principle is that before each execution of a postinstall_file :

  • if pre_postinstall_file is setted up and has not been transfered :
  • transfer it
  • append call to execution of parameter 1 ($1) of the future command line at the end of the transfered file, by executing :
    execute="\n# We must execute the script passed as the first argument\n\$1" && printf "%b\n" "$execute"
  • if pre_postinstall_file is setted up and has beean transfered :
  • modify the command to be executed for the postinstall_file by calling sh on the pre_postinstall_file with the postinstall_file as the first parameter

How To

  • Create a custom script in the definitions/ directory (i.e.

# Export for proxy 
export http_proxy=
export https_proxy=
  • Edit definitions<boxname>\definition.rb to add the pre_postinstall_file property and point it to the custom script


        :pre_postinstall_file => "",
  • Check execution

At veewee post install build runtime you'll see this type of lines :

[vagrant] Executing command: echo 'vagrant'|sudo -S sh './' ./