Make the path for the scripts configurable

This commit is contained in:
Micke Prag 2012-11-22 12:02:39 +01:00
parent fac773249c
commit 46c24d4a6e
3 changed files with 11 additions and 2 deletions

View file

@ -92,6 +92,10 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
######## Configurable options for the platform ########
IF (UNIX AND NOT APPLE)
SET(SCRIPT_PATH "/usr/local/share/telldus/scripts" CACHE PATH "The paths for scripts to execute on sensor events")
ENDIF()
######## Platforms-specific, non configurable ########
IF (APPLE) #### Mac OS X ####

View file

@ -24,6 +24,7 @@
#endif // _LINUX
#include "service/ConnectionListener.h"
#include "service/config.h"
#include "common/EventHandler.h"
#include "common/Message.h"
#include "common/Socket.h"
@ -103,7 +104,7 @@ void EventUpdateManager::run() {
void EventUpdateManager::loadScripts(const std::string &folder) {
#ifdef _LINUX
std::string path = TelldusCore::formatf("/usr/local/share/telldus/scripts/%s", folder.c_str());
std::string path = TelldusCore::formatf("%s/%s", SCRIPT_PATH, folder.c_str());
struct dirent **namelist;
int count = scandir(path.c_str(), &namelist, NULL, alphasort);
if (count < 0) {
@ -226,7 +227,7 @@ void EventUpdateManager::executeScripts(EventUpdateData *data) {
newEnv[env.size()] = 0; // Mark end of array
for(StringList::iterator it = d->fileList[dir].begin(); it != d->fileList[dir].end(); ++it) {
executeScript(TelldusCore::formatf("/usr/local/share/telldus/scripts/%s/%s", dir.c_str(), (*it).c_str()), (*it), newEnv);
executeScript(TelldusCore::formatf("%s/%s/%s", SCRIPT_PATH, dir.c_str(), (*it).c_str()), (*it), newEnv);
}
#endif // _LINUX
}

View file

@ -4,4 +4,8 @@
#define CONFIG_PATH "@SYSCONF_INSTALL_DIR@"
#define VAR_CONFIG_PATH "@STATE_INSTALL_DIR@"
#ifdef _LINUX
#define SCRIPT_PATH "@SCRIPT_PATH@"
#endif // _LINUX
#endif // CONFIG_H