9 #include <boost/filesystem.hpp>
10 #include <boost/program_options.hpp>
11 #include <boost/property_tree/ini_parser.hpp>
20 void updateFromPropertyTree(
const boost::property_tree::ptree& pt);
21 void writeToStream(std::ostream& out_stream)
const;
26 struct PKCS11_slot_st;
29 boost::filesystem::path module;
31 std::string uptane_key_id;
32 std::string tls_cacert_id;
33 std::string tls_pkey_id;
34 std::string tls_clientcert_id;
36 void updateFromPropertyTree(
const boost::property_tree::ptree& pt);
37 void writeToStream(std::ostream& out_stream)
const;
42 boost::filesystem::path server_url_path;
43 CryptoSource ca_source{CryptoSource::kFile};
44 CryptoSource pkey_source{CryptoSource::kFile};
45 CryptoSource cert_source{CryptoSource::kFile};
47 void updateFromPropertyTree(
const boost::property_tree::ptree& pt);
48 void writeToStream(std::ostream& out_stream)
const;
53 std::string p12_password;
54 std::string expiry_days{
"36000"};
55 boost::filesystem::path provision_path;
56 ProvisionMode mode{ProvisionMode::kDefault};
57 std::string device_id;
58 std::string primary_ecu_serial;
59 std::string primary_ecu_hardware_id;
60 std::string ecu_registration_endpoint;
62 void updateFromPropertyTree(
const boost::property_tree::ptree& pt);
63 void writeToStream(std::ostream& out_stream)
const;
67 uint64_t polling_sec{10U};
68 std::string director_server;
69 std::string repo_server;
70 CryptoSource key_source{CryptoSource::kFile};
71 KeyType key_type{KeyType::kRSA2048};
72 bool force_install_completion{
false};
73 boost::filesystem::path secondary_config_file;
74 uint64_t secondary_preinstall_wait_sec{600U};
76 void updateFromPropertyTree(
const boost::property_tree::ptree& pt);
77 void writeToStream(std::ostream& out_stream)
const;
81 #define PACKAGE_MANAGER_NONE "none"
82 #define PACKAGE_MANAGER_OSTREE "ostree"
83 #define PACKAGE_MANAGER_OSTREEDOCKERAPP "ostree+docker-app"
86 #define PACKAGE_MANAGER_DEFAULT PACKAGE_MANAGER_OSTREE
88 #define PACKAGE_MANAGER_DEFAULT PACKAGE_MANAGER_NONE
92 std::string type{PACKAGE_MANAGER_DEFAULT};
96 boost::filesystem::path sysroot;
97 std::string ostree_server;
98 boost::filesystem::path images_path{
"/var/sota/images"};
99 boost::filesystem::path packages_file{
"/usr/package.manifest"};
102 bool fake_need_reboot{
false};
105 std::map<std::string, std::string> extra;
107 void updateFromPropertyTree(
const boost::property_tree::ptree& pt);
108 void writeToStream(std::ostream& out_stream)
const;
112 StorageType type{StorageType::kSqlite};
113 boost::filesystem::path path{
"/var/sota"};
126 void updateFromPropertyTree(
const boost::property_tree::ptree& pt);
127 void writeToStream(std::ostream& out_stream)
const;
131 boost::filesystem::path base_path{
"/var/sota/import"};
138 void updateFromPropertyTree(
const boost::property_tree::ptree& pt);
139 void writeToStream(std::ostream& out_stream)
const;
147 bool report_network{
true};
148 bool report_config{
true};
149 void updateFromPropertyTree(
const boost::property_tree::ptree& pt);
150 void writeToStream(std::ostream& out_stream)
const;
153 enum class RollbackMode { kBootloaderNone = 0, kUbootGeneric, kUbootMasked };
154 std::ostream& operator<<(std::ostream& os, RollbackMode mode);
157 RollbackMode rollback_mode{RollbackMode::kBootloaderNone};
158 boost::filesystem::path reboot_sentinel_dir{
"/var/run/aktualizr-session"};
159 boost::filesystem::path reboot_sentinel_name{
"need_reboot"};
160 std::string reboot_command{
"/sbin/reboot"};
162 void updateFromPropertyTree(
const boost::property_tree::ptree& pt);
163 void writeToStream(std::ostream& out_stream)
const;
171 CryptoSource tls_ca_source;
172 CryptoSource tls_pkey_source;
173 CryptoSource tls_cert_source;
174 KeyType uptane_key_type;
175 CryptoSource uptane_key_source;
184 void updateFromToml(
const boost::filesystem::path& filename);
185 virtual void updateFromPropertyTree(
const boost::property_tree::ptree& pt) = 0;
188 void updateFromDirs(
const std::vector<boost::filesystem::path>& configs);
190 static void checkDirs(
const std::vector<boost::filesystem::path>& configs) {
191 for (
const auto& config : configs) {
192 if (!boost::filesystem::exists(config)) {
193 throw std::runtime_error(
"Config directory " + config.string() +
" does not exist.");
198 std::vector<boost::filesystem::path> config_dirs_ = {
"/usr/lib/sota/conf.d",
"/etc/sota/conf.d/"};
211 explicit Config(
const boost::program_options::variables_map& cmd);
212 explicit Config(
const boost::filesystem::path& filename);
213 explicit Config(
const std::vector<boost::filesystem::path>& config_dirs);
217 void updateFromTomlString(
const std::string& contents);
218 void postUpdateValues();
219 void writeToStream(std::ostream& sink)
const;
235 void updateFromPropertyTree(
const boost::property_tree::ptree& pt)
override;
236 void updateFromCommandLine(
const boost::program_options::variables_map& cmd);
237 bool loglevel_from_cmdline{
false};
240 std::ostream& operator<<(std::ostream& os,
const Config& cfg);