martinzink commented on code in PR #1993:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1993#discussion_r2306880554


##########
minifi_main/MainHelper.cpp:
##########
@@ -106,8 +108,50 @@ std::filesystem::path determineMinifiHome(const 
std::shared_ptr<logging::Logger>
   }
 
   /* Set the valid MINIFI_HOME in our environment */
-  logger->log_info("Using " MINIFI_HOME_ENV_KEY "={}", minifi_home);
-  utils::Environment::setEnvironmentVariable(MINIFI_HOME_ENV_KEY, 
minifi_home.string().c_str());
+  logger->log_info("Using {}={}", MINIFI_HOME_ENV_KEY, minifi_home);
+  utils::Environment::setEnvironmentVariable(MINIFI_HOME_ENV_KEY.data(), 
minifi_home.string().c_str());
 
   return minifi_home;
 }
+
+Locations getFromMinifiHome(const std::filesystem::path& minifi_home) {
+  return {
+    .working_dir_ = minifi_home,
+    .lock_path_ = minifi_home / "LOCK",
+    .log_properties_path_ = minifi_home / DEFAULT_LOG_PROPERTIES_FILE,
+    .uid_properties_path_ = minifi_home / DEFAULT_UID_PROPERTIES_FILE,
+    .properties_path_ = minifi_home / DEFAULT_NIFI_PROPERTIES_FILE,
+    .logs_dir_ = minifi_home / "logs",
+    .fips_bin_path_ = minifi_home / "fips",
+    .fips_conf_path_ = minifi_home / "fips",
+  };
+}
+
+Locations getFromFHS() {
+  return {
+      .working_dir_ =  std::filesystem::path(RPM_WORK_DIR),
+      .lock_path_ = std::filesystem::path(RPM_WORK_DIR) / "LOCK",
+      .log_properties_path_ = std::filesystem::path(RPM_CONFIG_DIR) / 
"minifi-log.properties",
+      .uid_properties_path_ = std::filesystem::path(RPM_CONFIG_DIR) / 
"minifi-uid.properties",
+      .properties_path_ = std::filesystem::path(RPM_CONFIG_DIR) / 
"minifi.properties",
+      .logs_dir_ = std::filesystem::path(RPM_LOG_DIR),
+      .fips_bin_path_ = std::filesystem::path(RPM_LIB_DIR) / "fips",
+      .fips_conf_path_ = std::filesystem::path(RPM_CONFIG_DIR) / "fips"
+  };
+}
+
+std::optional<Locations> determineLocations(const 
std::shared_ptr<logging::Logger>& logger) {
+  if (const auto minifi_home_env = 
utils::Environment::getEnvironmentVariable(MINIFI_HOME_ENV_KEY.data())) {
+    if (minifi_home_env == MINIFI_HOME_ENV_VALUE_FHS) {
+      return getFromFHS();
+    }
+  }
+  if (const auto executable_path = utils::file::get_executable_path(); 
executable_path.parent_path() == "/usr/bin") {
+    return getFromFHS();
+  }

Review Comment:
   good idea, I changed it to 
https://github.com/apache/nifi-minifi-cpp/pull/1993/commits/3ff49a86599211343faf1f19b7e7f29dc08317c3



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to