Logic Machine Forum
Startup (Init) Script - 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: Startup (Init) Script (/showthread.php?tid=4273)



Startup (Init) Script - jamesng - 30.09.2022

Hi

What's the best way to make changes to the Start-up (Init) script?   I can see that rebooting the device will force my updates into the runnings script, however is there another way to kill the running script and restart it?  I'm on the Schneider SHAC version of LogicMachine.

Kind Regards
James


RE: Startup (Init) Script - admin - 30.09.2022

Init script modification: https://forum.logicmachine.net/showthread.php?tid=4195&pid=27089#pid27089
Use script.reload() to reload event scripts, restart resident scripts and update scheduled scripts.


RE: Startup (Init) Script - jamesng - 02.10.2022

Is it as simple as creating another script which refers to the init script by it's id - or is there a different way to refer to it?

Kind Regards
James

Code:
script.reload('initscript')



RE: Startup (Init) Script - admin - 03.10.2022

You don't need to "reload" the init script. Just update the source file and it will be used during next boot. If you want to call init script again you should put code into a common function that can be called from multiple scripts.


RE: Startup (Init) Script - jamesng - 03.10.2022

I was trying to avoid rebooting the device as we're developing / making changes to the init script.

Will the script.reload('initscript') call do this or do we have to reboot the Schneider SHAC version of LogicMachine to see changes made to the init script we're developing?

Many thanks


RE: Startup (Init) Script - admin - 03.10.2022

script.reload('initscript') is not a valid call. The only thing you need to do is write code directly to the init file, no other actions are needed.
Code:
-- overwrite init script
io.writefile('/usr/share/lua/genohm-scada/initscript.lua', scripttext)