aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-01-13 11:40:56 +0100
committerDan Engelbrecht <[email protected]>2025-01-13 11:40:56 +0100
commitafb0fb0a2c7934b62d61fc191bfbce3a7535fe5e (patch)
tree57ba9b5ad3bcd91a9f4f68d01db7582801f8ba86 /src
parentgenerate unit file (diff)
downloadzen-afb0fb0a2c7934b62d61fc191bfbce3a7535fe5e.tar.xz
zen-afb0fb0a2c7934b62d61fc191bfbce3a7535fe5e.zip
clang format
Diffstat (limited to 'src')
-rw-r--r--src/zenutil/service.cpp80
1 files changed, 41 insertions, 39 deletions
diff --git a/src/zenutil/service.cpp b/src/zenutil/service.cpp
index d31786835..834d8b764 100644
--- a/src/zenutil/service.cpp
+++ b/src/zenutil/service.cpp
@@ -359,49 +359,51 @@ namespace {
#endif // ZEN_PLATFORM_MAC
#if ZEN_PLATFORM_LINUX
-// const char* SystemInstallFolder = "/etc/systemd/system/";
+ // const char* SystemInstallFolder = "/etc/systemd/system/";
-std::string GetUnitName(std::string_view ServiceName) { return fmt::format("com.epicgames.unreal.{}", ServiceName); }
+ std::string GetUnitName(std::string_view ServiceName) { return fmt::format("com.epicgames.unreal.{}", ServiceName); }
-std::filesystem::path GetServiceUnitPath(const std::string& UnitName)
-{
- const std::filesystem::path SystemUnitFolder = "/etc/systemd/system/";
- return SystemUnitFolder / (UnitName + ".service");
-}
+ std::filesystem::path GetServiceUnitPath(const std::string& UnitName)
+ {
+ const std::filesystem::path SystemUnitFolder = "/etc/systemd/system/";
+ return SystemUnitFolder / (UnitName + ".service");
+ }
-std::string BuildUnitFile(std::string_view ServiceName,
- const std::filesystem::path& ExecutablePath,
- std::string_view CommandLineOptions,
- std::string_view AliasName)
-{
- #if 0
+ std::string BuildUnitFile(std::string_view ServiceName,
+ const std::filesystem::path& ExecutablePath,
+ std::string_view CommandLineOptions,
+ std::string_view AliasName)
+ {
+# if 0
ZEN_UNUSED(ServiceName, ExecutablePath, CommandLineOptions, AliasName);
return "";
- #else
- return fmt::format("[Unit]\n"
- "Description={}\n"
- "Documentation=https://github.com/epicgames/zen\n"
- "\n"
- "DefaultDependencies=no\n"
- "After=network.target\n"
- "StartLimitIntervalSec=0\n"
- "\n"
- "[Service]\n"
- "Type=simple\n"
- "Restart=always\n"
- "RestartSec=1\n"
- "User=serviceuser\n"
- "ExecStart={} {}\n"
- "Restart=always\n"
- "RuntimeDirectory={}\n"
- "[Install]\n"
- "Alias={}",
- ServiceName,
- ExecutablePath, CommandLineOptions,
- ExecutablePath.parent_path(),
- AliasName);
- #endif
-}
+# else
+ return fmt::format(
+ "[Unit]\n"
+ "Description={}\n"
+ "Documentation=https://github.com/epicgames/zen\n"
+ "\n"
+ "DefaultDependencies=no\n"
+ "After=network.target\n"
+ "StartLimitIntervalSec=0\n"
+ "\n"
+ "[Service]\n"
+ "Type=simple\n"
+ "Restart=always\n"
+ "RestartSec=1\n"
+ "User=serviceuser\n"
+ "ExecStart={} {}\n"
+ "Restart=always\n"
+ "RuntimeDirectory={}\n"
+ "[Install]\n"
+ "Alias={}",
+ ServiceName,
+ ExecutablePath,
+ CommandLineOptions,
+ ExecutablePath.parent_path(),
+ AliasName);
+# endif
+ }
#endif // ZEN_PLATFORM_LINUX
} // namespace
@@ -940,7 +942,7 @@ InstallService(std::string_view ServiceName, const ServiceSpec& Spec)
ZEN_UNUSED(ServiceName, Spec);
const std::string UnitName = GetUnitName(ServiceName);
- std::string UnitFile = BuildUnitFile(ServiceName, Spec.ExecutablePath, Spec.CommandLineOptions, UnitName);
+ std::string UnitFile = BuildUnitFile(ServiceName, Spec.ExecutablePath, Spec.CommandLineOptions, UnitName);
const std::filesystem::path ServiceUnitPath = GetServiceUnitPath(UnitName);
ZEN_INFO("Writing systemd unit file to {}", ServiceUnitPath.string());