Remove the need for DIGWATCH_LUA_DIR env var

This commit is contained in:
Henri DF 2016-04-06 16:04:44 -07:00
parent c7d0c7dbd9
commit dcbae750c8
3 changed files with 15 additions and 11 deletions

View File

@ -34,12 +34,7 @@ $ make
as a result, you should have a digwatch executable `build/userspace/digwatch/digwatch`. as a result, you should have a digwatch executable `build/userspace/digwatch/digwatch`.
### Running ### Running locally-built sysdig
Set the path of the digwatch lua directory in the env var `DIGWATCH_LUA_DIR`:
`export DIGWATCH_LUA_DIR=<path_to_digwatch>/userspace/digwatch/lua/`
Create a file with some [digwatch rules](Rule-syntax-and-design). For example: Create a file with some [digwatch rules](Rule-syntax-and-design). For example:

View File

@ -3,6 +3,8 @@
#define DIGWATCH_VERSION "${DIGWATCH_VERSION}" #define DIGWATCH_VERSION "${DIGWATCH_VERSION}"
#define DIGWATCH_LUA_DIR "/usr/share/digwatch/lua/" #define DIGWATCH_LUA_DIR "/usr/share/digwatch/lua/"
#define DIGWATCH_SOURCE_LUA_DIR "${PROJECT_SOURCE_DIR}/userspace/digwatch/lua/"
#define DIGWATCH_LUA_MAIN "${DIGWATCH_LUA_MAIN}" #define DIGWATCH_LUA_MAIN "${DIGWATCH_LUA_MAIN}"

View File

@ -262,14 +262,21 @@ int digwatch_init(int argc, char **argv)
goto exit; goto exit;
} }
// lua_main_filename = lua_dir + DIGWATCH_LUA_MAIN;
char* env_lua_dir = getenv("DIGWATCH_LUA_DIR"); if (!std::ifstream(lua_main_filename))
if(env_lua_dir)
{ {
lua_dir = string(env_lua_dir); lua_dir = DIGWATCH_SOURCE_LUA_DIR;
lua_main_filename = lua_dir + DIGWATCH_LUA_MAIN;
if (!std::ifstream(lua_main_filename))
{
fprintf(stderr, "Could not find Digwatch Lua libraries (tried %s, %s). \n",
DIGWATCH_LUA_DIR DIGWATCH_LUA_MAIN,
lua_main_filename.c_str());
result = EXIT_FAILURE;
goto exit;
}
} }
lua_main_filename = lua_dir + DIGWATCH_LUA_MAIN;
// Initialize Lua interpreter // Initialize Lua interpreter
ls = lua_open(); ls = lua_open();