Hi,
In data mercoledì 24 giugno 2015 15:20:09, Priyanka Ranjan ha scritto:
I am writing a guestfish script . I want to implement conditional
logic
inside guestfish script. For example , if state.tgz exists in image do
something else if onetime.tgz exists in the image do someotherthing .
Is it possible to do this within guestfish script. I tried to search a
solution for this in guestfish doucmentation but couldn't find anything
useful.
guestfish is shell exposing the libguestfs APIs, but without many actual
shell features. If you need to do more complex logic than just executing
commands one after the other, then most probably there are two options:
(a) split the job in different guestfish calls. Pro: you can do using
guestfish different operations depending on the results, etc. Contra:
the appliance is booted once each guestfish run, so disks are remounted
every time, and you need to parse the string output of guestfish
yourself.
(b) switch to some programming language API for the job you are doing.
Anything among C, OCaml, Python, Perl, etc, should be equivalent.
Pro: complex language API available, with data structures,
conditionals, etc. Contra: more than a simple shell script, and will
require to rewrite the current guestfish-using shell script.
Between the two choices, my personal recommendation would be (b).
--
Pino Toscano