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
#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


Messages In This Thread
Script for Reboot - by palomino - 05.04.2023, 19:09
RE: Script for Reboot - by forsterm - 05.04.2023, 19:38
RE: Script for Reboot - by Daniel - 06.04.2023, 07:09
RE: Script for Reboot - by AEK - 06.04.2023, 14:52
RE: Script for Reboot - by Dré - 08.04.2023, 13:58
RE: Script for Reboot - by merel - 08.04.2023, 18:13
RE: Script for Reboot - by Dré - 09.08.2023, 15:19
RE: Script for Reboot - by admin - 11.04.2023, 05:51

Forum Jump: