5 #include <openssl/evp.h> 6 #include <openssl/rand.h> 9 #include "utilities/timer.h" 11 using std::make_shared;
12 using std::shared_ptr;
16 sig_ = make_shared<boost::signals2::signal<void(shared_ptr<event::BaseEvent>)>>();
17 storage_ = INvStorage::newStorage(config_.storage);
18 storage_->importData(config_.import);
19 uptane_client_ = SotaUptaneClient::newDefaultClient(config_, storage_, sig_);
23 std::shared_ptr<SotaUptaneClient> uptane_client_in, std::shared_ptr<event::Channel> sig_in)
26 storage_ = std::move(storage_in);
27 uptane_client_ = std::move(uptane_client_in);
28 sig_ = std::move(sig_in);
31 void Aktualizr::systemSetup() {
32 if (sodium_init() == -1) {
33 throw std::runtime_error(
"Unable to initialize libsodium");
36 LOG_TRACE <<
"Seeding random number generator from /dev/urandom...";
39 std::ifstream urandom(
"/dev/urandom", std::ios::in | std::ios::binary);
40 urandom.read(reinterpret_cast<char *>(&seed),
sizeof(seed));
43 LOG_TRACE <<
"... seeding complete in " << timer;
46 void Aktualizr::Initialize() { uptane_client_->initialize(); }
49 RunningMode running_mode = config_.uptane.running_mode;
55 uptane_client_->putManifest();
61 download_result.updates.size() == 0) {
65 Install(download_result.updates);
66 uptane_client_->putManifest();
73 std::this_thread::sleep_for(std::chrono::seconds(config_.uptane.polling_sec));
79 uptane_client_->addNewSecondary(secondary);
93 return uptane_client_->downloadImages(updates);
97 return uptane_client_->uptaneInstall(updates);
105 return sig_->connect(handler);
110 return storage_->openTargetFile(filename);
112 return std::unique_ptr<StorageTargetRHandle>();
void CampaignAccept(const std::string &campaign_id)
Accept a campaign for the current device.
Elapsed time measurement.
Download any available updates and then shut down.
void AddSecondary(const std::shared_ptr< Uptane::SecondaryInterface > &secondary)
Add new secondary to aktualizr.
PauseResult
Result of an attempt to pause or resume a download.
boost::signals2::connection SetSignalHandler(std::function< void(std::shared_ptr< event::BaseEvent >)> &handler)
Provide a function to receive event notifications.
void SendDeviceData()
Send local device data to the server.
PauseResult Resume()
Resume a paused download.
void UptaneCycle()
Synchronously run an uptane cycle.
RunningMode
Execution mode to run aktualizr in.
Container for information about downloading an update.
Configuration object for an aktualizr instance running on a primary ECU.
void Shutdown()
Asynchronously shut aktualizr down if it is running indefinitely with the Full RunningMode.
Container for information about available campaigns.
InstallResult Install(const std::vector< Uptane::Target > &updates)
Install targets.
int RunForever()
Run aktualizr indefinitely until Shutdown is called.
UpdateCheckResult CheckUpdates()
Fetch Uptane metadata and check for updates.
Container for information about available updates.
Aktualizr(Config &config)
Aktualizr requires a configuration object.
PauseResult Pause()
Pause a download current in progress.
DownloadResult Download(const std::vector< Uptane::Target > &updates)
Download targets.
CampaignCheckResult CampaignCheck()
Check for campaigns.
Container for information about installing an update.
std::unique_ptr< StorageTargetRHandle > GetStoredTarget(const std::string &filename)
Get target downloaded in Download call.
Install any available updates and then shut down.