1

I have an execute block that runs an external install script, that I have no power over. That install script sometimes immediately does what I want and at other times first runs an arbitrary number of updates and needs to be called again to do the actual install. The update processes return failure 1 and the actual install returns success 0. Is there an elegant way to rerun the execute block until the script returns 0?

Of course I could just put several copies of the execute block into the recipe that only run when the folder that will be created doesn't exist and ignore whether the run was a success or not. But that would be incredibly ugly and hacky.

  • How is the script being invoked? Does it automatically get run with a package installation? Or is it a self-extracting script that contains a tar.gz that installs some software? – jtimberman Sep 8 '10 at 7:20
0

You can use the script as condition in "until" loop with an empty body:

until ./install_script ; do : ; done

Colon is a "do-nothing" command, "until" simply loops as long as its condition command returns a false value (non-zero exit status). The square bracket usually used for conditions is actually an alias to the "test" command.

Nitpicking: this is more of a shell question than chef question. You may want to change tags.

| improve this answer | |
  • Well, I hoped for more of a chef solution. I also did some asking around with "expert chefs" and it seems like there is no built-in way to do this in chef. I am actually using a bash-based solution right now (although yours is more elegant), but was hoping that there was a standard chef way to do this, since it seemed like a pretty usual problem to me. – ajmurmann Oct 4 '10 at 0:18
  • IMO, while it might be a usual problem, it lies more in domain of shell (write a script to run the command) than in domain of chef (manage server configuration, and use shell to execute commands anyway). Why implement one of shell features directly in chef, when shell is called anyway, it is well-implemented, well-tested and well-suited for this kind of problems? – Maciej Pasternacki Oct 4 '10 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.