diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index 38e9742a5..5712c70e2 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -527,6 +527,20 @@ std::string find_executable(const char *name) return ""; } +bool exec_controlscript(std::string script) +{ + std::string controlscript = (std::string)CONTROLDIR + "/" + script; + if (access((std::string)CONTROLDIR_VAR + "/" + script.c_str(), X_OK) == 0) + controlscript = (std::string)CONTROLDIR_VAR + "/" + script; + + dprintf(DEBUG_NORMAL, "executing %s\n", controlscript.c_str()); + int ret = my_system(controlscript.c_str()); + if (ret) + dprintf(DEBUG_NORMAL, "control script failed\n"); + + return ret; +} + std::string backtick(std::string command) { char *buf = NULL; diff --git a/src/system/helpers.h b/src/system/helpers.h index 38a2955b1..eb788e23d 100644 --- a/src/system/helpers.h +++ b/src/system/helpers.h @@ -59,6 +59,7 @@ bool get_mem_usage(unsigned long &total, unsigned long &free); int mySleep(int sec); std::string find_executable(const char *name); +bool exec_controlscript(std::string script); /* basically what "foo=`command`" does in the shell */ std::string backtick(std::string command);