aboutsummaryrefslogtreecommitdiffstats
path: root/awall-cli
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2012-03-22 12:51:19 +0000
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2012-03-22 12:51:19 +0000
commit25f1c465c78f1eb6834f6e4fa77d5df066a23cd0 (patch)
tree3cdc82f38cfb08ec5d23c03a645494c5fd30a2b8 /awall-cli
parent42909321d7cab06239486e9041490386f4bd6dc1 (diff)
downloadawall-25f1c465c78f1eb6834f6e4fa77d5df066a23cd0.tar.bz2
awall-25f1c465c78f1eb6834f6e4fa77d5df066a23cd0.tar.xz
control input and output directories from command line
Diffstat (limited to 'awall-cli')
-rwxr-xr-xawall-cli28
1 files changed, 21 insertions, 7 deletions
diff --git a/awall-cli b/awall-cli
index 90953b1..2e98192 100755
--- a/awall-cli
+++ b/awall-cli
@@ -6,19 +6,33 @@ Copyright (C) 2012 Kaarle Ritvanen
Licensed under the terms of GPL2
]]--
+require 'alt_getopt'
require 'lfs'
require 'stringy'
-testmode = stringy.endswith(arg[0], '/awall-cli')
+short_opts = 'o:'
+long_opts = {['output-dir']='o'}
-if testmode then
- path = string.sub(arg[0], 1, -11)
- lfs.chdir(path)
+if stringy.endswith(arg[0], '/awall-cli') then
+ basedir = string.sub(arg[0], 1, -11)
+ input = {basedir..'/json'}
+
+ short_opts = short_opts..'i:'
+ long_opts['input-dir'] = 'i'
+end
+
+for switch, value in pairs(alt_getopt.get_opts(arg, short_opts, long_opts)) do
+ if switch == 'i' then table.insert(input, value)
+ elseif switch == 'o' then
+ iptdir = value
+ ipsfile = value..'/ipset'
+ else assert(false) end
end
+
require 'awall'
-awall.loadmodules(testmode and '.')
+awall.loadmodules(basedir)
-config = awall.Config.new(testmode and {'json', 'input'})
+config = awall.Config.new(input)
config:test()
-config:dump(testmode and 'output', testmode and 'output/ipset')
+config:dump(iptdir, ipsfile)