Adding script file into .adef


#1

Following this
http://legato.io/legato-docs/latest/basicAppsAddThings.html

I want to add script file named script.sh into the application and it must run before application starts

processes:
{
run:
{
( /usr/bin/script.sh )
( applicationComponent )
}

}

bundles:
{
file:
{
[x] script/script.sh /usr/bin/
// [x] script/script.sh /usr/bin/script.sh also same error
}
}

Could not exec ‘/usr/bin/script.sh’. No such file or directory.

What do I miss?


#2

Hi @raxsix
I wonder if absolute paths are supported in the run section…
I would bundle the script in the /bin folder of the sandbox (which is in the path) and call it without path in the run section.

Please note that:

  • you’ll also need to bind the /bin/sh executable in the sandbox, otherwise your script won’t run (you don’t have sh by default in the sandbox)
  • I think that executables are launched in parallel on the run section, so you can’t expect that your app will be launched after the script is terminated.

#3

What about just calling the script via a system (system("/bin/sh /usr/bin/script.sh")) call at the front end of your app? That will provide that it runs before your app gets going.


#4

I like your idea but can you give me some more info how to implement this
Where do you put that
system (system("/bin/sh /usr/bin/script.sh"))?


#5

Just one “system” call.
system("/bin/sh ./script.sh");

Add it to your “bundles” to put it in your local directory in your adef like this:
bundles:
{
[xr] …/script.sh ./ //or [xr] …/script.sh ./bin/ this assumes that the script.sh you wrote is in your project //directory
}


#6

Ok thanks, I will try it out