Updates to load JSON file from default location
The default (read-only) location for the JSON configuration file should
be /usr/share/phosphor-psu-monitor. Load from there if a file does not
exist in /etc/phosphor-psu-monitor.
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Change-Id: I704d24ecb55c948843eaea74b648d4b7b6c5a8a2
diff --git a/phosphor-power-supply/main.cpp b/phosphor-power-supply/main.cpp
index 03ff3db..542be4b 100644
--- a/phosphor-power-supply/main.cpp
+++ b/phosphor-power-supply/main.cpp
@@ -40,7 +40,15 @@
CLI11_PARSE(app, argc, argv);
if (configfile.empty())
{
- configfile = "/etc/phosphor-psu-monitor/psu_config.json";
+ if (std::filesystem::exists(
+ "/etc/phosphor-psu-monitor/psu_config.json"))
+ {
+ configfile = "/etc/phosphor-psu-monitor/psu_config.json";
+ }
+ else
+ {
+ configfile = "/usr/share/phosphor-psu-monitor/psu_config.json";
+ }
}
if (!std::filesystem::exists(configfile))