![]() |
|
Script change in database activation - Printable Version +- LogicMachine 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: Script change in database activation (/showthread.php?tid=3421) |
Script change in database activation - sebastian.strasser - 15.06.2021 Hello, when i am changing a script in the database, how can i activate this change? Today the change is only affecting after a restart of the lm thanks RE: Script change in database activation - admin - 15.06.2021 What exactly are you changing and what is the type of the script? RE: Script change in database activation - sebastian.strasser - 15.06.2021 I am changing the script itself. I want to upload a script with ftp and the lm have to import it. I have 52 SL to update the script automatic everytime i update my masterscript. It works but only with restart. I think there must be a better option. The script to edit is a resident My Import script is actual: Code: file = '/home/ftp/importscripts/script.lua'
if io.exists(file) then
log('start scriptimport')
data = io.readfile(file)
db:query('UPDATE scripting SET script=? WHERE name=?', data, 'imported_from_ftp')
os.remove (file)
os.execute("reboot")
endRE: Script change in database activation - admin - 16.06.2021 What type of script is this? Event, resident, scheduled? RE: Script change in database activation - sebastian.strasser - 16.06.2021 Both scripts are resident. RE: Script change in database activation - admin - 16.06.2021 Use this: Code: data = [[alert('testing')]]
name = 'imported_from_ftp'
item = script.get(name)
if item then
item.script = data
-- update script code in the database
db:update('scripting', { script = data }, { id = item.id })
-- update script code in the filesystem
script.save(item, true)
-- restart script
script.disable(name)
script.enable(name)
endRE: Script change in database activation - sebastian.strasser - 19.07.2021 Thanks, works without problems |