-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #611 from wazuh/enhancement/553-restart-command-macos
Restart command support in macOS
- Loading branch information
Showing
10 changed files
with
76 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <restart_handler_unix.hpp> | ||
|
||
#include <logger.hpp> | ||
|
||
namespace restart_handler | ||
{ | ||
bool RunningAsService() | ||
{ | ||
return (0 == std::system("which systemctl > /dev/null 2>&1") && nullptr != std::getenv("INVOCATION_ID")); | ||
} | ||
|
||
boost::asio::awaitable<module_command::CommandExecutionResult> RestartService() | ||
{ | ||
if (std::system("systemctl restart wazuh-agent") != 0) | ||
{ | ||
co_return module_command::CommandExecutionResult {module_command::Status::IN_PROGRESS, | ||
"Systemctl restart execution"}; | ||
} | ||
else | ||
{ | ||
LogError("Systemctl restart failed"); | ||
co_return module_command::CommandExecutionResult {module_command::Status::FAILURE, | ||
"Systemctl restart failed"}; | ||
} | ||
} | ||
} // namespace restart_handler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <restart_handler_unix.hpp> | ||
|
||
#include <logger.hpp> | ||
|
||
namespace restart_handler | ||
{ | ||
bool RunningAsService() | ||
{ | ||
return (getppid() == 1); | ||
} | ||
|
||
boost::asio::awaitable<module_command::CommandExecutionResult> RestartService() | ||
{ | ||
if (std::system("launchctl kickstart -k system/com.wazuh.agent") != 0) | ||
{ | ||
co_return module_command::CommandExecutionResult {module_command::Status::IN_PROGRESS, | ||
"launchctl restart execution"}; | ||
} | ||
else | ||
{ | ||
LogError("launchctl failed to restart Agent"); | ||
co_return module_command::CommandExecutionResult {module_command::Status::FAILURE, | ||
"launchctl restart failed"}; | ||
} | ||
} | ||
} // namespace restart_handler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters