diff --git a/package/gluon-announce/files/lib/gluon/announce/collect.lua b/package/gluon-announce/files/lib/gluon/announce/collect.lua
old mode 100755
new mode 100644
index 7bce0a783b096e7c106160d203e439e8e9216aab..e2974b4988994e7bfb87cb2fc19a426f0dada3ab
--- a/package/gluon-announce/files/lib/gluon/announce/collect.lua
+++ b/package/gluon-announce/files/lib/gluon/announce/collect.lua
@@ -1,43 +1,10 @@
 #!/usr/bin/lua
 
-local announce_base = '/lib/gluon/announce/'
-
-
-fs = require 'luci.fs'
-uci = require('luci.model.uci').cursor()
-util = require 'luci.util'
-
-
+local announce = require 'gluon.announce'
 local json = require 'luci.json'
 local ltn12 = require 'luci.ltn12'
 
+local announce_dir = '/lib/gluon/announce/' .. arg[1] .. '.d'
 
-local function collect_entry(entry)
-	if fs.isdirectory(entry) then
-		return collect_dir(entry)
-	else
-		return dofile(entry)
-	end
-end
-
-function collect_dir(dir)
-	local ret = {}
-
-	for _, entry in ipairs(fs.dir(dir)) do
-		if entry:sub(1, 1) ~= '.' then
-			local ok, val = pcall(collect_entry, dir .. '/' .. entry)
-			if ok then
-				ret[entry] = val
-			else
-				io.stderr:write(val, '\n')
-			end
-		end
-	end
-
-	return ret
-end
-
-local announce_dir  = announce_base .. arg[1] .. '.d/'
-
-encoder = json.Encoder(collect_dir(announce_dir))
+encoder = json.Encoder(announce.collect_dir(announce_dir))
 ltn12.pump.all(encoder:source(), ltn12.sink.file(io.stdout))
diff --git a/package/gluon-announce/files/usr/lib/lua/gluon/announce.lua b/package/gluon-announce/files/usr/lib/lua/gluon/announce.lua
new file mode 100755
index 0000000000000000000000000000000000000000..7f3f62e285f7e82541d4438acfa62e7f3aba4813
--- /dev/null
+++ b/package/gluon-announce/files/usr/lib/lua/gluon/announce.lua
@@ -0,0 +1,33 @@
+#!/usr/bin/lua
+
+module('gluon.announce', package.seeall)
+
+fs = require 'luci.fs'
+uci = require('luci.model.uci').cursor()
+util = require 'luci.util'
+
+local function collect_entry(entry)
+	if fs.isdirectory(entry) then
+		return collect_dir(entry)
+	else
+		return setfenv(loadfile(entry), _M)()
+	end
+end
+
+function collect_dir(dir)
+	local ret = {}
+
+	for _, entry in ipairs(fs.dir(dir)) do
+		if entry:sub(1, 1) ~= '.' then
+			local ok, val = pcall(collect_entry, dir .. '/' .. entry)
+			if ok then
+				ret[entry] = val
+			else
+				io.stderr:write(val, '\n')
+			end
+		end
+	end
+
+	return ret
+end
+