Guest User

Untitled

a guest
Mar 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. ubus = require 'ubus'
  2.  
  3. local conn = ubus.connect()
  4. if not conn then
  5. error('Failed to connect to ubusd')
  6. end
  7.  
  8. local interface = 'ttk'
  9. local status = conn:call('network.interface.' .. interface, 'status', { })
  10. if status.up then
  11. -- argh, there is no RAII...
  12. conn:close()
  13. return
  14. end
  15.  
  16. local logStatus = conn:call('log', 'write', { event = interface .. ' is down. Trying to restart...' })
  17.  
  18. -- this from official wiki. Maybe it is outdated
  19. -- status = conn:call('network.interface.' .. interface, 'up', { })
  20. -- found in /sbin/ifup script
  21. status = conn:call('network.interface', 'up', { interface = '' .. interface })
  22. -- print(tostring(status))
  23. -- logStatus = conn:call('log', 'write', { event = 'interface.up = ' .. status })
  24.  
  25. conn:close()
Add Comment
Please, Sign In to add comment