This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Script change in database activation
#1
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
Reply
#2
What exactly are you changing and what is the type of the script?
Reply
#3
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")
end
Reply
#4
What type of script is this? Event, resident, scheduled?
Reply
#5
Both scripts are resident.
Reply
#6
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)
end
Reply
#7
Thanks, works without problems
Reply


Forum Jump: