fort/bin/scripts/provider.lua
Nodir Temirkhodjaev 20cdf3b122 Parse arguments.
2015-02-05 14:34:19 +05:00

49 lines
809 B
Lua

-- WIPF Provider (Un)Registration script
local wipf = require"wipflua"
local sys = require"sys"
local register, boot
local function usage()
print[[
Usage: luajit.exe scripts\provider.lua <arguments>
Argumets:
register .... Register provider
boot ........ Block access to network when WIPF is not running
unregister .. Unregister provider
]]
sys.exit(false)
end
-- Process arguments
if #arg == 0 then
usage()
end
for _, a in ipairs(arg) do
if a == "register" then
register = true
elseif a == "boot" then
boot = true
elseif a == "help" then
usage()
end
end
-- Unregister
wipf.prov_unregister()
-- Register optionally
if register then
local _, err = wipf.prov_register(boot)
if err then
sys.stderr:write("Error: ", sys.strerror(err))
sys.exit(false)
end
end