From 1a8e41150bbe7d2ec99311bad6ae8894b44cd292 Mon Sep 17 00:00:00 2001 From: Jan-Tarek Butt Date: Sat, 9 Feb 2019 04:51:29 +0100 Subject: [PATCH] gluon-hoodselector: hoodselector, use taps instead of spaces. Signed-off-by: Jan-Tarek Butt --- .../luasrc/usr/sbin/hoodselector | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/package/gluon-hoodselector/luasrc/usr/sbin/hoodselector b/package/gluon-hoodselector/luasrc/usr/sbin/hoodselector index 75e350b6..a02406f4 100755 --- a/package/gluon-hoodselector/luasrc/usr/sbin/hoodselector +++ b/package/gluon-hoodselector/luasrc/usr/sbin/hoodselector @@ -10,23 +10,23 @@ local lockfile = '/var/lock/hoodselector.lock' local lockfd, err = fcntl.open(lockfile, bit.bor(fcntl.O_WRONLY, fcntl.O_CREAT), 384) -- mode 0600 if not lockfd then - hoodutil.log(err, '\n') - os.exit(1) + hoodutil.log(err, '\n') + os.exit(1) end local ok, _ = fcntl.fcntl(lockfd, fcntl.F_SETLK, { - l_start = 0, - l_len = 0, - l_type = fcntl.F_WRLCK, - l_whence = unistd.SEEK_SET, + l_start = 0, + l_len = 0, + l_type = fcntl.F_WRLCK, + l_whence = unistd.SEEK_SET, }) if not ok then - io.stderr:write(string.format( - "Unable to lock file %s. Make sure there is no other instance of the hoodselector running.\n", - lockfile - )) - os.exit(1) + io.stderr:write(string.format( + "Unable to lock file %s. Make sure there is no other instance of the hoodselector running.\n", + lockfile + )) + os.exit(1) end -- VPN MODE @@ -36,31 +36,31 @@ end -- the default hood. -- If we can't determine the node's location, we will continue to the next mode. if hoodutil.direct_vpn() then - io.stdout:write('VPN connection found.\n') - local geo = hoodutil.get_geolocation() - if geo.lat ~= nil and geo.lon ~= nil then - io.stdout:write('Position found.\n') - local jhood = hoodutil.get_domains() - local geo_hood = hoodutil.get_hood_by_geo(jhood, geo) - if geo_hood ~= nil then - if hoodutil.set_hoodconfig(geo_hood) then - hoodutil.restart_services() - hoodutil.log('Domain set by VPN mode.\n') - end - return - end - io.stdout:write('No domain has been defined for the current position.\n') - if hoodutil.set_hoodconfig(hoodutil.get_default_hood(jhood)) then - hoodutil.restart_services() - hoodutil.log('Domain set by VPN mode.\n') - end - return - else - -- The hoodselector should continue with the next states because there can be other - -- VPN nodes in the local mesh network which provide a position and therefore - -- have set a geo base hood. - io.stdout:write('No position found\n') - end + io.stdout:write('VPN connection found.\n') + local geo = hoodutil.get_geolocation() + if geo.lat ~= nil and geo.lon ~= nil then + io.stdout:write('Position found.\n') + local jhood = hoodutil.get_domains() + local geo_hood = hoodutil.get_hood_by_geo(jhood, geo) + if geo_hood ~= nil then + if hoodutil.set_hoodconfig(geo_hood) then + hoodutil.restart_services() + hoodutil.log('Domain set by VPN mode.\n') + end + return + end + io.stdout:write('No domain has been defined for the current position.\n') + if hoodutil.set_hoodconfig(hoodutil.get_default_hood(jhood)) then + hoodutil.restart_services() + hoodutil.log('Domain set by VPN mode.\n') + end + return + else + -- The hoodselector should continue with the next states because there can be other + -- VPN nodes in the local mesh network which provide a position and therefore + -- have set a geo base hood. + io.stdout:write('No position found\n') + end else - io.stdout:write('No VPN connection found\n') + io.stdout:write('No VPN connection found\n') end