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_DEBIAN "debian" 84 #define PACKAGE_MANAGER_ANDROID "android" 85 #define PACKAGE_MANAGER_OSTREEDOCKERAPP "ostree+docker-app" 88 #define PACKAGE_MANAGER_DEFAULT PACKAGE_MANAGER_OSTREE 90 #define PACKAGE_MANAGER_DEFAULT PACKAGE_MANAGER_NONE 94 std::string type{PACKAGE_MANAGER_DEFAULT};
98 boost::filesystem::path sysroot;
99 std::string ostree_server;
100 boost::filesystem::path images_path{
"/var/sota/images"};
101 boost::filesystem::path packages_file{
"/usr/package.manifest"};
104 bool fake_need_reboot{
false};
107 std::map<std::string, std::string> extra;
109 void updateFromPropertyTree(
const boost::property_tree::ptree& pt);
110 void writeToStream(std::ostream& out_stream)
const;
114 StorageType type{StorageType::kSqlite};
115 boost::filesystem::path path{
"/var/sota"};
128 void updateFromPropertyTree(
const boost::property_tree::ptree& pt);
129 void writeToStream(std::ostream& out_stream)
const;
133 boost::filesystem::path base_path{
"/var/sota/import"};
140 void updateFromPropertyTree(
const boost::property_tree::ptree& pt);
141 void writeToStream(std::ostream& out_stream)
const;
149 bool report_network{
true};
150 bool report_config{
true};
151 void updateFromPropertyTree(
const boost::property_tree::ptree& pt);
152 void writeToStream(std::ostream& out_stream)
const;
155 enum class RollbackMode { kBootloaderNone = 0, kUbootGeneric, kUbootMasked };
156 std::ostream& operator<<(std::ostream& os, RollbackMode mode);
159 RollbackMode rollback_mode{RollbackMode::kBootloaderNone};
160 boost::filesystem::path reboot_sentinel_dir{
"/var/run/aktualizr-session"};
161 boost::filesystem::path reboot_sentinel_name{
"need_reboot"};
162 std::string reboot_command{
"/sbin/reboot"};
164 void updateFromPropertyTree(
const boost::property_tree::ptree& pt);
165 void writeToStream(std::ostream& out_stream)
const;
173 CryptoSource tls_ca_source;
174 CryptoSource tls_pkey_source;
175 CryptoSource tls_cert_source;
176 KeyType uptane_key_type;
177 CryptoSource uptane_key_source;
186 void updateFromToml(
const boost::filesystem::path& filename);
187 virtual void updateFromPropertyTree(
const boost::property_tree::ptree& pt) = 0;
190 void updateFromDirs(
const std::vector<boost::filesystem::path>& configs);
192 static void checkDirs(
const std::vector<boost::filesystem::path>& configs) {
193 for (
const auto& config : configs) {
194 if (!boost::filesystem::exists(config)) {
195 throw std::runtime_error(
"Config directory " + config.string() +
" does not exist.");
200 std::vector<boost::filesystem::path> config_dirs_ = {
"/usr/lib/sota/conf.d",
"/etc/sota/conf.d/"};
213 explicit Config(
const boost::program_options::variables_map& cmd);
214 explicit Config(
const boost::filesystem::path& filename);
215 explicit Config(
const std::vector<boost::filesystem::path>& config_dirs);
219 void updateFromTomlString(
const std::string& contents);
220 void postUpdateValues();
221 void writeToStream(std::ostream& sink)
const;
237 void updateFromPropertyTree(
const boost::property_tree::ptree& pt)
override;
238 void updateFromCommandLine(
const boost::program_options::variables_map& cmd);
239 bool loglevel_from_cmdline{
false};
242 std::ostream& operator<<(std::ostream& os,
const Config& cfg);
Configuration object for an aktualizr instance running on a Primary ECU.
The TelemetryConfig struct Report device network information: IP address, hostname, MAC address.
The BasedPath class Can represent an absolute or relative path, only readable through the BasePath::g...