script-server icon indicating copy to clipboard operation
script-server copied to clipboard

Could global params be stored in conf.json and used in script.json files ?

Open raszuk opened this issue 2 years ago • 5 comments

Hi,

After setting up 40 different scripts I found that it would be super useful if we could use parameters stored globally in conf.json as part of some fields in script.json files.

For example instead of typing

/home/robert/arclab_v1/bin as Working directory in 40 files to define it once in conf.json and only use ${BIN_HOME} as example.

Same for some script names inside parameter definition - for example instead of placing ls /home/robert/arclab_v1/labs in 30 params just use ${ls_labs}

The main reason for this ask is ability to easily migrate to different server, different user etc ... without having to modify 100s of script.json files :) Not sure if this is possible today with some workaround or if ticket has been already logged for it before.

raszuk avatar Jan 08 '23 20:01 raszuk

Reasonable suggestion, don't know any workarounds.

I'm not that good at Bash/Powershell - are you sure such template syntax won't interfere with them? If it won't, then I guess its a good idea.

RollingHog avatar Jan 16 '23 11:01 RollingHog

Well if this is or those are a new json object(s) they will not interfere with anything other then the code which reads them.

So to be 100% on the safe side we could predefine say 10 user configurable global json objects example: user_obj_1..user_obj_10 and let user use it as it seems fit.

raszuk avatar Jan 16 '23 11:01 raszuk

Hey, did you try included option?

Robert Raszuk @.***> schrieb am Mo., 16. Jan. 2023, 12:44:

Well if this is or those are a new json object(s) they will not interfere with anything other then the code which reads them.

So to be 100% on the safe side we could predefine say 10 user configurable global json objects example: user_obj_1..user_obj_10 and let user use it as it seems fit.

— Reply to this email directly, view it on GitHub https://github.com/bugy/script-server/issues/616#issuecomment-1383927757, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJXPJKAS67P5TEKCMHEKPDWSUYA3ANCNFSM6AAAAAATUYXRKM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

bugy avatar Jan 16 '23 11:01 bugy

Oh ... did not know about it ... but even after reading https://github.com/bugy/script-server/issues/133 I am not sure if it does what I am asking for here.

How can I use objects/variables in WebUI if I create and define a new file include.json in runners folder ? I do not want and manually edit/touch all script files with vi or sed ;)

So far it looks like include file can extend my script parameters which is very cool on its own (but not what I am asking for).

I was just trying to have some global variables from global.json available to all scripts - that's all. The use is to have for example ${HOME} instead of typing in each script's Working directory field "/home/robert/arclab_v1/bin"

raszuk avatar Jan 16 '23 12:01 raszuk

Sorry, i probably misunderstood you then. I thought, that you can define common json file(s), where you would specify working directory and/or parameters. And then include this(these) file(s) in each of your configurations Of course this would still require a bit of duplication (for the include section), but at least this would solve env issue.

bugy avatar Jan 16 '23 12:01 bugy