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 for Reboot
#1
Hello Daniel.

Is it possible to create a script for reboot the LM?
Reply
#2
Try this:
Code:
os.execute('reboot')
Reply
#3
Be careful with this, if you loop controller in constant reboot, the only way out is hardware factory reset.
------------------------------
Ctrl+F5
Reply
#4
(05.04.2023, 19:09)palomino Wrote: Hello Daniel.

Is it possible to create a script for reboot the LM?

just make backup defore implementing ths code))
Reply
#5
Is it also possible to get a notification when it restarts?
Reply
#6
(08.04.2023, 13:58)Dré Wrote: Is it also possible to get a notification when it restarts?




Code:
-- Common Function
function mail(to, subject, message)
  -- make sure these settings are correct
  local settings = {
    -- "from" field, only e-mail must be specified here
    from = 'servis@servis.com',
    -- smtp username
    user = 'username',
    -- smtp password
    password = 'password',
    -- smtp server
    server = 'smtp.myserver.com',
    -- smtp server port
    port = 25,
    -- enable ssl, required for gmail smtp
--    secure = 'sslv23',
  }
-- port 465
 
  local smtp = require('socket.smtp')

  if type(to) ~= 'table' then
    to = { to }
  end

  for index, email in ipairs(to) do
    to[ index ] = '<' .. tostring(email) .. '>'
  end

  -- message headers and body
  settings.source = smtp.message({
    headers = {
      to = table.concat(to, ', '),
      subject = subject,
      ['Content-type'] = 'text/html; charset=utf-8',
    },
    body = message
  })

  -- fixup from field
  settings.from = '<' .. tostring(settings.from) .. '>'
  settings.rcpt = to

  return smtp.send(settings)
end
Code:
-- Init Script
mail( 'mymail@mail.com',  'Restart LogicMachine',  'my message body')
Code:
-- Sync before reboot
os.execute('sync')
Reply
#7
You can add a notification to the init script. A short delay might be needed as internet connection might not be ready when the script starts.

As for reboot via a script it should not be needed at all. If you are experiencing a bug that requires rebooting LM to fix it then let us know and we will look into it.
Reply
#8
(08.04.2023, 18:13)merel Wrote:
Code:
-- Init Script
mail( 'mymail@mail.com',  'Restart LogicMachine',  'my message body')
Sorry about the late reaction.
It is working, but i set a delay of 5 minutes.
Because when there is a full power off, my network will start up, before i sent the message.
Reply


Forum Jump: