diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2012-02-16 13:59:57 +0000 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2012-02-16 13:59:57 +0000 |
commit | d45c00925e238594f6bb79519e6fa7f250ba87a8 (patch) | |
tree | 060755d857fc15debd44c82b26ac58d099be69c8 | |
parent | 20d2c9ec926e5eff31fe34b606c0ce68609a3476 (diff) | |
download | awall-d45c00925e238594f6bb79519e6fa7f250ba87a8.tar.bz2 awall-d45c00925e238594f6bb79519e6fa7f250ba87a8.tar.xz |
use lfs.dir for listing modules
-rw-r--r-- | awall/init.lua | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/awall/init.lua b/awall/init.lua index 7290109..6e5f22f 100644 --- a/awall/init.lua +++ b/awall/init.lua @@ -8,20 +8,25 @@ module(..., package.seeall) require 'json' require 'lfs' +require 'stringy' require 'awall.iptables' +require 'awall.model' require 'awall.util' -local modules = {} - local testmode = arg[0] ~= '/usr/sbin/awall' + +local modules = {package.loaded['awall.model']} + local modpath = testmode and '.' or '/usr/share/lua/5.1' -for line in io.popen('cd '..modpath..' && ls awall/model.lua awall/modules/*.lua'):lines() do - local name = string.gsub(string.sub(line, 1, -5), '/', '.') - require(name) - table.insert(modules, package.loaded[name]) +for modfile in lfs.dir(modpath..'/awall/modules') do + if stringy.endswith(modfile, '.lua') then + local name = 'awall.modules.'..string.sub(modfile, 1, -5) + require(name) + table.insert(modules, package.loaded[name]) + end end |