Logic Machine Forum
Remote restore of user scripts - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Remote restore of user scripts (/showthread.php?tid=1301)



Remote restore of user scripts - hogo - 20.03.2018

Hi,

we want to update or initialize LM remotely via ssh/FTP. 

Our idea is to use restore scripts (user scripts) first and then we just use our implementation.

We will update restore file for user scripts via FTP and then execute LUA script via SSH (also updated) to remove all old user scripts and restore scripts from file

Question is: How we can restore user libraries via LUA script from unix command-line on LM? (if is possible from GUI it have to work also from script somehow)

Thank you for help.


RE: Remote restore of user scripts - admin - 20.03.2018

User libraries are plain files stored in /usr/share/lua/user/


RE: Remote restore of user scripts - FatMax - 07.12.2018

(20.03.2018, 14:33)admin Wrote: User libraries are plain files stored in /usr/share/lua/user/

Are these files encrypted in any way? I'm trying to read the files, but getting (in lack of better term) gibberish in response.


RE: Remote restore of user scripts - admin - 07.12.2018

.lua files are in byte-code form. If "Keep source" is enabled then .luas files with plain source code are kept there as well.


RE: Remote restore of user scripts - FatMax - 07.12.2018

(07.12.2018, 09:48)admin Wrote: .lua files are in byte-code form. If "Keep source" is enabled then .luas files with plain source code are kept there as well.

Gotcha! So if we were to update some of these libraries remotely, would there be a recommended process? The libraries in question are not ticked Keep Source (to protect ip), I'm guessing that would be a problem? Are the libraries linked to sql in any way?


RE: Remote restore of user scripts - admin - 07.12.2018

No, libraries are just Lua byte code files. If you don't want to share source then convert them locally on your LM first.


RE: Remote restore of user scripts - alb-smith - 15.06.2020

We have a similar problem.
We are implementing a script that downloads an update of a user library (luas file) and then saves it in the /usr/share/lua/ user folder.
Two questions:
a) In order to be executed it must be converted into bytecode and in this case can it be done with a LM local command (e.g. with a script)?
b) After copying the new library, is it necessary to restart the LM?


Thanks


RE: Remote restore of user scripts - admin - 15.06.2020

Lua can load both plain source and byte code files so using byte code for user libraries is not mandatory.
You can convert source to byte code like this:
Code:
fn = loadfile(path_to_source)
bc = string.dump(fn, false)
io.writefile(path_to_bytecode, bc)

You need to restart any resident scripts that are using old libraries. All other scripts will use updated libraries automatically when run. Restarting LM is the easiest solution.


RE: Remote restore of user scripts - alb-smith - 15.06.2020

thank you so much!