From 6d816a0a26c54106f5e80fe87e5d4158935a996c Mon Sep 17 00:00:00 2001 From: vanhofen Date: Mon, 1 Feb 2021 00:08:56 +0100 Subject: [PATCH] helpers: add function to execute init scripts Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/b4e75bdb240fadcbd67505b0a33f9deddb5c99c8 Author: vanhofen Date: 2021-02-01 (Mon, 01 Feb 2021) Origin message was: ------------------ - helpers: add function to execute init scripts ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/system/helpers.cpp | 10 ++++++++++ src/system/helpers.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index 0ebf7629e..8b0cb2320 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -568,6 +568,16 @@ bool exec_controlscript(std::string script) 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) { char *buf = NULL; diff --git a/src/system/helpers.h b/src/system/helpers.h index 7b0bb8213..006868679 100644 --- a/src/system/helpers.h +++ b/src/system/helpers.h @@ -61,6 +61,7 @@ int mySleep(int sec); std::string find_executable(const char *name); bool exec_controlscript(std::string script); +bool exec_initscript(std::string script, std::string command = "start"); /* basically what "foo=`command`" does in the shell */ std::string backtick(std::string command);