mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-31 01:11:12 +02:00
- helpers: add function to execute control scripts
Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -397,6 +397,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;
|
||||
|
@@ -57,6 +57,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);
|
||||
|
||||
|
Reference in New Issue
Block a user