summaryrefslogtreecommitdiff
path: root/rhnop-server
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2011-03-30 02:46:42 (GMT)
committerChristian Pointner <equinox@helsinki.at>2011-03-30 02:46:42 (GMT)
commit50bdc20f9024216de8f6cb45756ca54ffec42a5d (patch)
treebe4ab5d0870105aa79e5f89ba5dcc076724114de /rhnop-server
parent97ea5eee07f939f03a87c2d8df1c996ef38ca4b2 (diff)
added libdir handling
Diffstat (limited to 'rhnop-server')
-rw-r--r--rhnop-server/Makefile1
-rw-r--r--rhnop-server/conf.lua4
-rwxr-xr-xrhnop-server/configure1
-rw-r--r--rhnop-server/nopsyncd.c10
-rw-r--r--rhnop-server/qlistener.lua2
-rw-r--r--rhnop-server/tcpserver.lua1
6 files changed, 16 insertions, 3 deletions
diff --git a/rhnop-server/Makefile b/rhnop-server/Makefile
index 2d0f2f8..a0a9f64 100644
--- a/rhnop-server/Makefile
+++ b/rhnop-server/Makefile
@@ -79,6 +79,7 @@ install-bin: $(EXECUTABLE)
install-lib:
$(INSTALL) -d $(DESTDIR)$(LIBDIR)
$(INSTALL) -m 644 conf.lua $(DESTDIR)$(LIBDIR)
+ $(SED) -e 's#^local filename.*$$#local filename = "$(ETCDIR)/rhnop/nopsyncd.conf"#' -i $(DESTDIR)$(LIBDIR)/conf.lua
$(INSTALL) -m 644 playlog.lua $(DESTDIR)$(LIBDIR)
$(INSTALL) -m 644 rddb.lua $(DESTDIR)$(LIBDIR)
$(INSTALL) -m 644 qlistener.lua $(DESTDIR)$(LIBDIR)
diff --git a/rhnop-server/conf.lua b/rhnop-server/conf.lua
index 83257b5..8e97650 100644
--- a/rhnop-server/conf.lua
+++ b/rhnop-server/conf.lua
@@ -21,7 +21,9 @@
local conf = {}
-local file = assert(io.open("nopsyncd.conf", "r"))
+local filename = "nopsyncd.conf"
+
+local file = assert(io.open(filename, "r"))
for line in file:lines() do
local k,v = string.match(line, "^([^=#]+)=(.*)$")
if k and v and v ~= "" then
diff --git a/rhnop-server/configure b/rhnop-server/configure
index 0b0aa09..d1f68f9 100755
--- a/rhnop-server/configure
+++ b/rhnop-server/configure
@@ -191,6 +191,7 @@ LUA := '$LUA'
LUAC := '$LUAC'
STRIP := strip
INSTALL := install
+SED := sed
PREFIX := '$PREFIX'
BINDIR := '$BINDIR'
diff --git a/rhnop-server/nopsyncd.c b/rhnop-server/nopsyncd.c
index 63bef7f..acb1eb1 100644
--- a/rhnop-server/nopsyncd.c
+++ b/rhnop-server/nopsyncd.c
@@ -30,8 +30,11 @@
#include <lauxlib.h>
#include "l_pipe.h"
+#include "config.h"
#define LUA_MAIN_LOOP_FUNC "main_loop"
+#define QLISTENER LIBDIR"/qlistener.lua"
+#define TCPSERVER LIBDIR"/tcpserver.lua"
static const luaL_Reg nopsyncd_lualibs[] = {
{"", luaopen_base},
@@ -66,6 +69,9 @@ int init_main_loop(lua_State *L, const char* filename)
return -1;
}
+ lua_pushstring(L, LIBDIR);
+ lua_setglobal(L, "rhnoplibdir");
+
ret = lua_pcall(L, 0, 0, 0);
if(ret) {
const char* err_str = luaL_checkstring(L, -1);
@@ -143,14 +149,14 @@ int main(int argc, char* argv[])
return 1;
}
- ret = pthread_create(&qlistener, NULL, main_loop, "qlistener.lua");
+ ret = pthread_create(&qlistener, NULL, main_loop, QLISTENER);
if(ret) {
fprintf(stderr, "Error creating qlistener thread (code: %d)\n", ret);
return 1;
}
pthread_detach(qlistener); /* can't kill this thread so don't join to it */
- ret = pthread_create(&tcpserver, NULL, main_loop, "tcpserver.lua");
+ ret = pthread_create(&tcpserver, NULL, main_loop, TCPSERVER);
if(ret) {
fprintf(stderr, "Error creating qlistener thread (code: %d)\n", ret);
return 1;
diff --git a/rhnop-server/qlistener.lua b/rhnop-server/qlistener.lua
index 8f2c0e2..4e96649 100644
--- a/rhnop-server/qlistener.lua
+++ b/rhnop-server/qlistener.lua
@@ -22,6 +22,8 @@
local last_cart = nil
mq = require "mq"
+
+package.path = package.path .. ";" .. rhnoplibdir .. "/?.lua"
playlog = require "playlog"
rddb = require "rddb"
conf = require "conf"
diff --git a/rhnop-server/tcpserver.lua b/rhnop-server/tcpserver.lua
index bd945b6..c035ba4 100644
--- a/rhnop-server/tcpserver.lua
+++ b/rhnop-server/tcpserver.lua
@@ -21,6 +21,7 @@
require "socket"
+package.path = package.path .. ";" .. rhnoplibdir .. "/?.lua"
conf = require "conf"
function init_server()