Make the path for the scripts configurable
This commit is contained in:
parent
fac773249c
commit
46c24d4a6e
3 changed files with 11 additions and 2 deletions
|
@ -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 ####
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue