Logic Machine Forum
Script for Reboot - 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: Script for Reboot (/showthread.php?tid=4702)



Script for Reboot - palomino - 05.04.2023

Hello Daniel.

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


RE: Script for Reboot - forsterm - 05.04.2023

Try this:
Code:
os.execute('reboot')



RE: Script for Reboot - Daniel - 06.04.2023

Be careful with this, if you loop controller in constant reboot, the only way out is hardware factory reset.


RE: Script for Reboot - AEK - 06.04.2023

(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))


RE: Script for Reboot - Dré - 08.04.2023

Is it also possible to get a notification when it restarts?


RE: Script for Reboot - merel - 08.04.2023

(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')



RE: Script for Reboot - admin - 11.04.2023

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.


RE: Script for Reboot - Dré - 09.08.2023

(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.