mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-27 15:32:52 +02:00
helpers: modify exec_initscript() for usage with systemctl
Current behavior is untouched, but return value is boolean
and so far, the function obviously has returned true on error. So far this
was currently not evaluated but is changed now. Otherwise, "bool" makes
not really sense or was this intended?
Origin commit data
------------------
Branch: ni/coolstream
Commit: d2d22e5748
Author: Thilo Graf <dbt@novatux.de>
Date: 2021-06-22 (Tue, 22 Jun 2021)
------------------
This commit was generated by Migit
This commit is contained in:
@@ -568,14 +568,30 @@ bool exec_controlscript(std::string script)
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool exec_initscript(std::string script, std::string command)
|
||||
bool exec_initscript(std::string script, std::string command, std::string system_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());
|
||||
std::string user = getenv("USER");
|
||||
if (user != "root")
|
||||
dprintf(DEBUG_NORMAL, "[helpers] [%s - %d] NOTE: current user is not root!\n", __func__, __LINE__);
|
||||
|
||||
return ret;
|
||||
int ret = 1;
|
||||
if (system_command == "service")
|
||||
{
|
||||
dprintf(DEBUG_DEBUG, "executing %s %s %s\n", system_command.c_str(), script.c_str(), command.c_str());
|
||||
ret = my_system(3, system_command.c_str(), script.c_str(), command.c_str());
|
||||
}
|
||||
else if (system_command == "systemctl")
|
||||
{
|
||||
dprintf(DEBUG_DEBUG, "executing %s %s %s\n", system_command.c_str(), command.c_str(), script.c_str());
|
||||
ret = my_system(3, system_command.c_str(), command.c_str(), script.c_str());
|
||||
}
|
||||
else
|
||||
dprintf(DEBUG_NORMAL, "Error: [helpers] [%s - %d] no system command defined\n", __func__, __LINE__);
|
||||
|
||||
if (ret)
|
||||
dprintf(DEBUG_NORMAL, "Error: [helpers] exec init script [%s] failed\n", system_command.c_str());
|
||||
|
||||
return ret == 0 ? true : false;
|
||||
}
|
||||
|
||||
std::string backtick(std::string command)
|
||||
|
Reference in New Issue
Block a user