| #include <string> | |
| #include "absl/flags/flag.h" | |
| #include "absl/flags/parse.h" | |
| #include "absl/log/log.h" | |
| #include "install/installer.h" | |
| ABSL_FLAG(std::string, inventory_dir, "/run/install/inventory", | |
| "Directory where firmware inventory is stored."); | |
| ABSL_FLAG(std::string, install_lock_file, "/run/install/install_ongoing", | |
| "Lock file to indicate an installation is in progress."); | |
| ABSL_FLAG(std::string, bundle_tar_file, | |
| "/mnt/luks-mmcblk0_fs/firmware_bundle.tar.gz", | |
| "File path where firmware bundle gets stored by Redfish update. The " | |
| "untarred files will be stored in the same directory under " | |
| "`firmware_bundle` folder."); | |
| ABSL_FLAG(std::string, activation_check_dir, "/var/google/firmware_bundle/", | |
| "Directory where activation check scripts are persisted."); | |
| ABSL_FLAG(std::string, public_key_file, "", | |
| "File path for the public key used to verify the firmware bundle."); | |
| ABSL_FLAG(std::string, mode, "post_install", | |
| "The mode of the installer. Can be `post_install`, " | |
| "`activation_check`, `signature_check`, or `check_dev_keys_enabled`"); | |
| ABSL_FLAG(std::string, dev_keys_config_path, | |
| "/var/volatile/owner-verification/config.textproto", | |
| "File path to the owner configuration, which dictates if using dev " | |
| "keys for bundle verification is allowed."); | |
| namespace { | |
| using ::bloom_install::ActivationMain; | |
| using ::bloom_install::CheckDevKeysEnabledMain; | |
| using ::bloom_install::PostInstallMain; | |
| using ::bloom_install::SignatureCheckMain; | |
| } // namespace | |
| int main(int argc, char* argv[]) { | |
| absl::ParseCommandLine(argc, argv); | |
| std::string mode = absl::GetFlag(FLAGS_mode); | |
| if (mode != "post_install" && mode != "activation_check" && | |
| mode != "signature_check" && mode != "check_dev_keys_enabled") { | |
| LOG(ERROR) << "Invalid mode: " << mode; | |
| return 1; | |
| } | |
| if (mode == "check_dev_keys_enabled") { | |
| return CheckDevKeysEnabledMain(absl::GetFlag(FLAGS_dev_keys_config_path)); | |
| } | |
| if (mode == "activation_check") { | |
| return ActivationMain(absl::GetFlag(FLAGS_activation_check_dir)); | |
| } | |
| if (mode == "signature_check") { | |
| return SignatureCheckMain(absl::GetFlag(FLAGS_bundle_tar_file), | |
| absl::GetFlag(FLAGS_public_key_file)); | |
| } | |
| return PostInstallMain(absl::GetFlag(FLAGS_inventory_dir), | |
| absl::GetFlag(FLAGS_install_lock_file), | |
| absl::GetFlag(FLAGS_bundle_tar_file), | |
| absl::GetFlag(FLAGS_activation_check_dir)); | |
| } |