- helpers: add function to execute init scripts

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
svenhoefer
2021-02-01 00:08:56 +01:00
committed by Thilo Graf
parent c88d2d5731
commit 6eb0c6af44
2 changed files with 11 additions and 0 deletions

View File

@@ -467,6 +467,16 @@ bool exec_controlscript(std::string script)
return ret; return ret;
} }
bool exec_initscript(std::string script, std::string command)
{
dprintf(DEBUG_NORMAL, "executing service %s %s\n", script.c_str(), command.c_str());
int ret = my_system(3, "service", script.c_str(), command.c_str());
if (ret)
dprintf(DEBUG_NORMAL, "exec init script [%s] failed\n", script.c_str());
return ret;
}
std::string backtick(std::string command) std::string backtick(std::string command)
{ {
char *buf = NULL; char *buf = NULL;

View File

@@ -59,6 +59,7 @@ int mySleep(int sec);
std::string find_executable(const char *name); std::string find_executable(const char *name);
bool exec_controlscript(std::string script); bool exec_controlscript(std::string script);
bool exec_initscript(std::string script, std::string command = "start");
/* basically what "foo=`command`" does in the shell */ /* basically what "foo=`command`" does in the shell */
std::string backtick(std::string command); std::string backtick(std::string command);