#ifndef __PROCESSUTILITY_INL__ #define __PROCESSUTILITY_INL__ #include "BoostLog.h" #include "ProcessUtility.h" #include #include #if (defined __arm__) || (defined __aarch64__) #include #else #include #endif template void DockerUtility::runScript(std::string_view container, const std::string &script, Args &&...scriptArgs) { using namespace boost::process; auto env = boost::this_process::environment(); auto user = env["USER"].to_string(); auto docker = search_path("docker"); system(docker, args = {"exec", "-d", "-u", user, container.data(), "bash", script, std::forward(scriptArgs)...}); } template void NativeUtility::runScript(const std::string &script, Args &&...scriptArgs) { #if (defined __arm__) || (defined __aarch64__) using namespace std::experimental; #else using namespace std; #endif #if defined(WIN32) || defined(ANDROID) LOG(info) << "DockerUtility::runScript() not supported on windows or android."; #else auto askpass = filesystem::current_path().parent_path() / "Askpass/Askpassd.AppImage"; auto env = boost::this_process::environment(); env["SUDO_ASKPASS"] = askpass; auto bash = boost::process::search_path("bash"); boost::process::system(bash, boost::process::args = {script, std::forward(scriptArgs)...}, env); #endif } #endif // __PROCESSUTILITY_INL__