Logic Machine Forum
ZeroTier Service via LUA - 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: ZeroTier Service via LUA (/showthread.php?tid=3437)



ZeroTier Service via LUA - emme - 23.06.2021

hi,

I used to interact with openVPN Client by disabling by default the connection at server startup



Code:
require('uci')
uci.set('openvpn-lm', 'openvpn', 'enabled', 0)
uci.commit('openvpn-lm')
os.execute('/etc/init.d/openvpn-lm restart)


is there a way to di the save for zerotier client?
I've tried to replace zerotier-one to openvpn but it was an unsuccesful tentative Sad

thanks


RE: ZeroTier Service via LUA - Daniel - 23.06.2021

Code:
enabled = event.getvalue()

require('uci')
uci.set('zerotier', 'default', 'enabled', enabled and 1 or 0)
uci.commit('zerotier')

os.execute('/etc/init.d/zerotier restart')



RE: ZeroTier Service via LUA - emme - 23.06.2021

Thanks you so Mich

Is there a Place to understand the UCI module and its options and funcs?


RE: ZeroTier Service via LUA - admin - 25.06.2021

Each service has different config options. This is not documented because it's an internal function.


RE: ZeroTier Service via LUA - Evens - 26.08.2021

(23.06.2021, 15:35)Daniel. Wrote:
Code:
enabled = event.getvalue()

require('uci')
uci.set('zerotier', 'default', 'enabled', enabled and 1 or 0)
uci.commit('zerotier')

os.execute('/etc/init.d/zerotier restart')

Hi Daniel,

Can you help me with a script for Enable and Disable the Zerotier from a GA? 
Im running a Iot Edge and want to restrict the data usage, and want to remotly enable / disable Zerotier from Mosaic. 

Best Regard 
Even Sundgot.


RE: ZeroTier Service via LUA - Daniel - 26.08.2021

Just create event script on boolean object. Add it to mosaic and done.


RE: ZeroTier Service via LUA - gtsamis - 08.10.2021

Hi,

Is there anyway to get the Zerotier's IP via script?


RE: ZeroTier Service via LUA - admin - 09.10.2021

You can get the IP like this:
Code:
info = io.readproc('zerotier-cli -D/var/lib/zerotier-one_default/ -j listnetworks')
info = require('json').pdecode(info)

if type(info) == 'table' then
  net = info[1]
  if type(net) == 'table' and type(net.assignedAddresses) == 'table' then
    ip = net.assignedAddresses[1]:gsub('/%d+', '') --remove subnet part
  end
end

log(ip)



RE: ZeroTier Service via LUA - gtsamis - 09.10.2021

Thanks!