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.

ZeroTier Service via LUA
#1
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
Reply
#2
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')
------------------------------
Ctrl+F5
Reply
#3
Thanks you so Mich

Is there a Place to understand the UCI module and its options and funcs?
Reply
#4
Each service has different config options. This is not documented because it's an internal function.
Reply
#5
(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.
Reply
#6
Just create event script on boolean object. Add it to mosaic and done.
------------------------------
Ctrl+F5
Reply
#7
Hi,

Is there anyway to get the Zerotier's IP via script?
Reply
#8
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)
Reply
#9
Thanks!
Reply


Forum Jump: