Merge pull request #22 from draios/no-env-var

No env var
This commit is contained in:
Henri DF 2016-04-06 16:07:52 -07:00
commit 5c4dc93e97
3 changed files with 16 additions and 19 deletions

View File

@ -34,12 +34,7 @@ $ make
as a result, you should have a digwatch executable `build/userspace/digwatch/digwatch`.
### Running
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/`
### Running locally-built sysdig
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_LUA_DIR "/usr/share/digwatch/lua/"
#define DIGWATCH_SOURCE_LUA_DIR "${PROJECT_SOURCE_DIR}/userspace/digwatch/lua/"
#define DIGWATCH_LUA_MAIN "${DIGWATCH_LUA_MAIN}"

View File

@ -190,7 +190,7 @@ int digwatch_init(int argc, char **argv)
// Parse the args
//
while((op = getopt_long(argc, argv,
"hm:No:",
"hNo:",
long_options, &long_index)) != -1)
{
switch(op)
@ -198,9 +198,6 @@ int digwatch_init(int argc, char **argv)
case 'h':
usage();
goto exit;
case 'm':
lua_main_filename = optarg;
break;
case 'N':
inspector->set_hostname_and_port_resolution_mode(false);
break;
@ -265,18 +262,21 @@ int digwatch_init(int argc, char **argv)
goto exit;
}
//
char* env_lua_dir = getenv("DIGWATCH_LUA_DIR");
if(env_lua_dir)
lua_main_filename = lua_dir + DIGWATCH_LUA_MAIN;
if (!std::ifstream(lua_main_filename))
{
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;
}
}
trim(lua_main_filename);
if(lua_main_filename.size() == 0)
{
lua_main_filename = lua_dir + DIGWATCH_LUA_MAIN;
}
// Initialize Lua interpreter
ls = lua_open();