Will the second time restart all shell commands in my script?

I am developing a Vagrant wrapper script to set up an Ubuntu VM with a range of things installed. I notice that it sudo apt-get update

takes a long time to start up during initialization, and therefore checking that my Vagrant settings are configuring the VM correctly is very slow.

If I run it a vagrant provision

second time, will it rerun all shell commands in my script or will it only rerun the newly added settings? I really want to shorten the development time for this script!

+3


source to share


2 answers


Use bypass logic in your Script provision

When rerunning a given firewall provisioning device, it should rerun the entire script. Any bypasses or short circuits you might want to apply should be constructed in your script conditionals. As one example:



# Only install something if a certain file is missing.
if [ ! -f /some/file ]; then
    : # run your installer
fi

      

+1


source


Yes, it will restart all shell commands in the script. You can write a script that checks for the existence of a file. If the file exists, run the script and create the file so that the next time file is there and the script will not run.



0


source







All Articles