Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame^] | 1 | // |
| 2 | // Copyright (C) 2012 The Android Open Source Project |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | // |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 16 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 17 | #include <inttypes.h> |
| 18 | #include <sysexits.h> |
| 19 | #include <unistd.h> |
| 20 | |
Darin Petkov | 5a7f565 | 2010-07-22 21:40:09 -0700 | [diff] [blame] | 21 | #include <string> |
| 22 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 23 | #include <base/bind.h> |
Alex Deymo | 8ce80d6 | 2015-01-27 15:10:43 -0800 | [diff] [blame] | 24 | #include <base/command_line.h> |
Alex Deymo | 44666f9 | 2014-07-22 20:29:24 -0700 | [diff] [blame] | 25 | #include <base/logging.h> |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 26 | #include <base/macros.h> |
| 27 | #include <chromeos/daemons/dbus_daemon.h> |
David Zeuthen | 9d73a72 | 2014-04-04 14:52:46 -0700 | [diff] [blame] | 28 | #include <chromeos/dbus/service_constants.h> |
Steve Fung | 97b6f5a | 2014-10-07 12:39:51 -0700 | [diff] [blame] | 29 | #include <chromeos/flag_helper.h> |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 30 | #include <dbus/bus.h> |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 31 | |
| 32 | #include "update_engine/dbus_constants.h" |
Alex Deymo | d2956cc | 2015-08-17 15:39:40 -0700 | [diff] [blame] | 33 | #include "update_engine/dbus-proxies.h" |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 34 | |
David Zeuthen | 75a4c3e | 2013-09-06 11:36:59 -0700 | [diff] [blame] | 35 | using chromeos_update_engine::kAttemptUpdateFlagNonInteractive; |
Alex Deymo | 44666f9 | 2014-07-22 20:29:24 -0700 | [diff] [blame] | 36 | using chromeos_update_engine::kUpdateEngineServiceName; |
Darin Petkov | 5a7f565 | 2010-07-22 21:40:09 -0700 | [diff] [blame] | 37 | using std::string; |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 38 | |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 39 | namespace { |
| 40 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 41 | // Constant to signal that we need to continue running the daemon after |
| 42 | // initialization. |
| 43 | const int kContinueRunning = -1; |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 44 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 45 | class UpdateEngineClient : public chromeos::DBusDaemon { |
| 46 | public: |
| 47 | UpdateEngineClient(int argc, char** argv) : argc_(argc), argv_(argv) {} |
| 48 | ~UpdateEngineClient() override = default; |
| 49 | |
| 50 | protected: |
| 51 | int OnInit() override { |
| 52 | int ret = DBusDaemon::OnInit(); |
| 53 | if (ret != EX_OK) |
| 54 | return ret; |
| 55 | if (!InitProxy()) |
| 56 | return 1; |
Alex Deymo | 13e0dd6 | 2015-06-30 23:11:44 -0700 | [diff] [blame] | 57 | // Wait for the UpdateEngine to be available or timeout. |
| 58 | proxy_->GetObjectProxy()->WaitForServiceToBeAvailable( |
| 59 | base::Bind(&UpdateEngineClient::OnServiceAvailable, |
| 60 | base::Unretained(this))); |
| 61 | base::MessageLoop::current()->PostDelayedTask( |
| 62 | FROM_HERE, |
| 63 | base::Bind(&UpdateEngineClient::OnServiceAvailableTimeout, |
| 64 | base::Unretained(this)), |
| 65 | base::TimeDelta::FromSeconds(10)); |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 66 | return EX_OK; |
Andrew de los Reyes | 68ab6ed | 2011-08-09 14:46:39 -0700 | [diff] [blame] | 67 | } |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 68 | |
| 69 | private: |
| 70 | bool InitProxy(); |
| 71 | |
Alex Deymo | 13e0dd6 | 2015-06-30 23:11:44 -0700 | [diff] [blame] | 72 | // Callback called when the UpdateEngine service becomes available. |
| 73 | void OnServiceAvailable(bool service_is_available); |
| 74 | |
| 75 | // Callback called when the UpdateEngine service doesn't become available |
| 76 | // after a timeout. |
| 77 | void OnServiceAvailableTimeout(); |
| 78 | |
| 79 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 80 | // Callback called when a StatusUpdate signal is received. |
| 81 | void OnStatusUpdateSignal(int64_t last_checked_time, |
| 82 | double progress, |
| 83 | const string& current_operation, |
| 84 | const string& new_version, |
| 85 | int64_t new_size); |
| 86 | // Callback called when the OnStatusUpdateSignal() handler is registered. |
| 87 | void OnStatusUpdateSignalRegistration(const string& interface, |
| 88 | const string& signal_name, |
| 89 | bool success); |
| 90 | |
| 91 | // Registers a callback that prints on stderr the received StatusUpdate |
| 92 | // signals. |
| 93 | // The daemon should continue running for this to work. |
| 94 | void WatchForUpdates(); |
| 95 | |
| 96 | void ResetStatus(); |
| 97 | |
| 98 | // Show the status of the update engine in stdout. |
| 99 | // Blocking call. Exits the program with error 1 in case of an error. |
| 100 | void ShowStatus(); |
| 101 | |
| 102 | // Return the current operation status, such as UPDATE_STATUS_IDLE. |
| 103 | // Blocking call. Exits the program with error 1 in case of an error. |
| 104 | string GetCurrentOperation(); |
| 105 | |
| 106 | void Rollback(bool rollback); |
| 107 | string GetRollbackPartition(); |
| 108 | string GetKernelDevices(); |
| 109 | void CheckForUpdates(const string& app_version, |
| 110 | const string& omaha_url, |
| 111 | bool interactive); |
| 112 | |
| 113 | // Reboot the device if a reboot is needed. |
| 114 | // Blocking call. Ignores failures. |
| 115 | void RebootIfNeeded(); |
| 116 | |
| 117 | // Getter and setter for the target channel. If |get_current_channel| is true, |
| 118 | // the current channel instead of the target channel will be returned. |
| 119 | // Blocking call. Exits the program with error 1 in case of an error. |
| 120 | void SetTargetChannel(const string& target_channel, bool allow_powerwash); |
| 121 | string GetChannel(bool get_current_channel); |
| 122 | |
| 123 | // Getter and setter for the updates over cellular connections. |
| 124 | // Blocking call. Exits the program with error 1 in case of an error. |
| 125 | void SetUpdateOverCellularPermission(bool allowed); |
| 126 | bool GetUpdateOverCellularPermission(); |
| 127 | |
| 128 | // Getter and setter for the updates from P2P permission. |
| 129 | // Blocking call. Exits the program with error 1 in case of an error. |
| 130 | void SetP2PUpdatePermission(bool enabled); |
| 131 | bool GetP2PUpdatePermission(); |
| 132 | |
| 133 | // This is similar to watching for updates but rather than registering |
| 134 | // a signal watch, actively poll the daemon just in case it stops |
| 135 | // sending notifications. |
| 136 | void WaitForUpdateComplete(); |
| 137 | void OnUpdateCompleteCheck(int64_t last_checked_time, |
| 138 | double progress, |
| 139 | const string& current_operation, |
| 140 | const string& new_version, |
| 141 | int64_t new_size); |
| 142 | |
| 143 | // Blocking call. Exits the program with error 1 in case of an error. |
| 144 | void ShowPrevVersion(); |
| 145 | |
| 146 | // Returns whether the current status is such that a reboot is needed. |
| 147 | // Blocking call. Exits the program with error 1 in case of an error. |
| 148 | bool GetIsRebootNeeded(); |
| 149 | |
| 150 | // Blocks until a reboot is needed. If the reboot is needed, exits the program |
| 151 | // with 0. Otherwise it exits the program with 1 if an error occurs before |
| 152 | // the reboot is needed. |
| 153 | void WaitForRebootNeeded(); |
| 154 | void OnRebootNeededCheck(int64_t last_checked_time, |
| 155 | double progress, |
| 156 | const string& current_operation, |
| 157 | const string& new_version, |
| 158 | int64_t new_size); |
| 159 | // Callback called when the OnRebootNeededCheck() handler is registered. This |
| 160 | // is useful to check at this point if the reboot is needed, without loosing |
| 161 | // any StatusUpdate signals and avoiding the race condition. |
| 162 | void OnRebootNeededCheckRegistration(const string& interface, |
| 163 | const string& signal_name, |
| 164 | bool success); |
| 165 | |
| 166 | // Main method that parses and triggers all the actions based on the passed |
| 167 | // flags. |
| 168 | int ProcessFlags(); |
| 169 | |
| 170 | // DBus Proxy to the update_engine daemon object used for all the calls. |
| 171 | std::unique_ptr<org::chromium::UpdateEngineInterfaceProxy> proxy_; |
| 172 | |
| 173 | // Copy of argc and argv passed to main(). |
| 174 | int argc_; |
| 175 | char** argv_; |
| 176 | |
Alex Deymo | 13e0dd6 | 2015-06-30 23:11:44 -0700 | [diff] [blame] | 177 | // Tell whether the UpdateEngine service is available after startup. |
| 178 | bool service_is_available_{false}; |
| 179 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 180 | DISALLOW_COPY_AND_ASSIGN(UpdateEngineClient); |
| 181 | }; |
| 182 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 183 | bool UpdateEngineClient::InitProxy() { |
| 184 | proxy_.reset(new org::chromium::UpdateEngineInterfaceProxy(bus_)); |
| 185 | |
| 186 | if (!proxy_->GetObjectProxy()) { |
| 187 | LOG(ERROR) << "Error getting dbus proxy for " << kUpdateEngineServiceName; |
| 188 | return false; |
Richard Barnette | d793606 | 2013-01-18 13:38:51 -0800 | [diff] [blame] | 189 | } |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 190 | return true; |
| 191 | } |
| 192 | |
Alex Deymo | 13e0dd6 | 2015-06-30 23:11:44 -0700 | [diff] [blame] | 193 | void UpdateEngineClient::OnServiceAvailable(bool service_is_available) { |
| 194 | service_is_available_ = service_is_available; |
| 195 | if (!service_is_available) { |
| 196 | LOG(ERROR) << "UpdateEngineService not available."; |
| 197 | QuitWithExitCode(-1); |
| 198 | } |
| 199 | int ret = ProcessFlags(); |
| 200 | if (ret != kContinueRunning) |
| 201 | QuitWithExitCode(ret); |
| 202 | } |
| 203 | |
| 204 | void UpdateEngineClient::OnServiceAvailableTimeout() { |
| 205 | if (!service_is_available_) { |
| 206 | LOG(ERROR) << "Waiting for UpdateEngineService timeout. Is update_engine " |
| 207 | "daemon running?"; |
| 208 | QuitWithExitCode(-1); |
| 209 | } |
| 210 | } |
| 211 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 212 | void UpdateEngineClient::OnStatusUpdateSignal( |
| 213 | int64_t last_checked_time, |
| 214 | double progress, |
| 215 | const string& current_operation, |
| 216 | const string& new_version, |
| 217 | int64_t new_size) { |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 218 | LOG(INFO) << "Got status update:"; |
| 219 | LOG(INFO) << " last_checked_time: " << last_checked_time; |
| 220 | LOG(INFO) << " progress: " << progress; |
| 221 | LOG(INFO) << " current_operation: " << current_operation; |
| 222 | LOG(INFO) << " new_version: " << new_version; |
| 223 | LOG(INFO) << " new_size: " << new_size; |
| 224 | } |
| 225 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 226 | void UpdateEngineClient::OnStatusUpdateSignalRegistration( |
| 227 | const string& interface, |
| 228 | const string& signal_name, |
| 229 | bool success) { |
| 230 | VLOG(1) << "OnStatusUpdateSignalRegistration(" << interface << ", " |
| 231 | << signal_name << ", " << success << ");"; |
| 232 | if (!success) { |
| 233 | LOG(ERROR) << "Couldn't connect to the " << signal_name << " signal."; |
| 234 | exit(1); |
| 235 | } |
Jay Srinivasan | c1ba09a | 2012-08-14 14:15:57 -0700 | [diff] [blame] | 236 | } |
| 237 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 238 | void UpdateEngineClient::WatchForUpdates() { |
| 239 | proxy_->RegisterStatusUpdateSignalHandler( |
| 240 | base::Bind(&UpdateEngineClient::OnStatusUpdateSignal, |
| 241 | base::Unretained(this)), |
| 242 | base::Bind(&UpdateEngineClient::OnStatusUpdateSignalRegistration, |
| 243 | base::Unretained(this))); |
| 244 | } |
Jay Srinivasan | c1ba09a | 2012-08-14 14:15:57 -0700 | [diff] [blame] | 245 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 246 | void UpdateEngineClient::ResetStatus() { |
| 247 | bool ret = proxy_->ResetStatus(nullptr); |
| 248 | CHECK(ret) << "ResetStatus() failed."; |
| 249 | } |
Andrew de los Reyes | ada4220 | 2010-07-15 22:23:20 -0700 | [diff] [blame] | 250 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 251 | void UpdateEngineClient::ShowStatus() { |
| 252 | int64_t last_checked_time = 0; |
| 253 | double progress = 0.0; |
| 254 | string current_op; |
| 255 | string new_version; |
| 256 | int64_t new_size = 0; |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 257 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 258 | bool ret = proxy_->GetStatus( |
| 259 | &last_checked_time, &progress, ¤t_op, &new_version, &new_size, |
| 260 | nullptr); |
| 261 | CHECK(ret) << "GetStatus() failed"; |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 262 | printf("LAST_CHECKED_TIME=%" PRIi64 "\nPROGRESS=%f\nCURRENT_OP=%s\n" |
| 263 | "NEW_VERSION=%s\nNEW_SIZE=%" PRIi64 "\n", |
| 264 | last_checked_time, |
| 265 | progress, |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 266 | current_op.c_str(), |
| 267 | new_version.c_str(), |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 268 | new_size); |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | string UpdateEngineClient::GetCurrentOperation() { |
| 272 | int64_t last_checked_time = 0; |
| 273 | double progress = 0.0; |
| 274 | string current_op; |
| 275 | string new_version; |
| 276 | int64_t new_size = 0; |
| 277 | |
| 278 | bool ret = proxy_->GetStatus( |
| 279 | &last_checked_time, &progress, ¤t_op, &new_version, &new_size, |
| 280 | nullptr); |
| 281 | CHECK(ret) << "GetStatus() failed"; |
| 282 | return current_op; |
| 283 | } |
| 284 | |
| 285 | void UpdateEngineClient::Rollback(bool rollback) { |
| 286 | bool ret = proxy_->AttemptRollback(rollback, nullptr); |
| 287 | CHECK(ret) << "Rollback request failed."; |
| 288 | } |
| 289 | |
| 290 | string UpdateEngineClient::GetRollbackPartition() { |
| 291 | string rollback_partition; |
| 292 | bool ret = proxy_->GetRollbackPartition(&rollback_partition, nullptr); |
| 293 | CHECK(ret) << "Error while querying rollback partition availabilty."; |
| 294 | return rollback_partition; |
| 295 | } |
| 296 | |
| 297 | string UpdateEngineClient::GetKernelDevices() { |
| 298 | string kernel_devices; |
| 299 | bool ret = proxy_->GetKernelDevices(&kernel_devices, nullptr); |
| 300 | CHECK(ret) << "Error while getting a list of kernel devices"; |
| 301 | return kernel_devices; |
| 302 | } |
| 303 | |
| 304 | void UpdateEngineClient::CheckForUpdates(const string& app_version, |
| 305 | const string& omaha_url, |
| 306 | bool interactive) { |
| 307 | int32_t flags = interactive ? 0 : kAttemptUpdateFlagNonInteractive; |
| 308 | bool ret = proxy_->AttemptUpdateWithFlags(app_version, omaha_url, flags, |
| 309 | nullptr); |
| 310 | CHECK(ret) << "Error checking for update."; |
| 311 | } |
| 312 | |
| 313 | void UpdateEngineClient::RebootIfNeeded() { |
| 314 | bool ret = proxy_->RebootIfNeeded(nullptr); |
| 315 | if (!ret) { |
| 316 | // Reboot error code doesn't necessarily mean that a reboot |
| 317 | // failed. For example, D-Bus may be shutdown before we receive the |
| 318 | // result. |
| 319 | LOG(INFO) << "RebootIfNeeded() failure ignored."; |
Darin Petkov | 58529db | 2010-08-13 09:19:47 -0700 | [diff] [blame] | 320 | } |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 321 | } |
| 322 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 323 | void UpdateEngineClient::SetTargetChannel(const string& target_channel, |
| 324 | bool allow_powerwash) { |
| 325 | bool ret = proxy_->SetChannel(target_channel, allow_powerwash, nullptr); |
| 326 | CHECK(ret) << "Error setting the channel."; |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 327 | LOG(INFO) << "Channel permanently set to: " << target_channel; |
Darin Petkov | 8daa324 | 2010-10-25 13:28:47 -0700 | [diff] [blame] | 328 | } |
| 329 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 330 | string UpdateEngineClient::GetChannel(bool get_current_channel) { |
| 331 | string channel; |
| 332 | bool ret = proxy_->GetChannel(get_current_channel, &channel, nullptr); |
| 333 | CHECK(ret) << "Error getting the channel."; |
| 334 | return channel; |
Satoru Takabayashi | 583667b | 2010-10-27 13:09:57 +0900 | [diff] [blame] | 335 | } |
| 336 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 337 | void UpdateEngineClient::SetUpdateOverCellularPermission(bool allowed) { |
| 338 | bool ret = proxy_->SetUpdateOverCellularPermission(allowed, nullptr); |
| 339 | CHECK(ret) << "Error setting the update over cellular setting."; |
Alex Deymo | f4867c4 | 2013-06-28 14:41:39 -0700 | [diff] [blame] | 340 | } |
| 341 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 342 | bool UpdateEngineClient::GetUpdateOverCellularPermission() { |
| 343 | bool allowed; |
| 344 | bool ret = proxy_->GetUpdateOverCellularPermission(&allowed, nullptr); |
| 345 | CHECK(ret) << "Error getting the update over cellular setting."; |
Alex Deymo | f4867c4 | 2013-06-28 14:41:39 -0700 | [diff] [blame] | 346 | return allowed; |
| 347 | } |
| 348 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 349 | void UpdateEngineClient::SetP2PUpdatePermission(bool enabled) { |
| 350 | bool ret = proxy_->SetP2PUpdatePermission(enabled, nullptr); |
| 351 | CHECK(ret) << "Error setting the peer-to-peer update setting."; |
Alex Deymo | 5fdf776 | 2013-07-17 20:01:40 -0700 | [diff] [blame] | 352 | } |
| 353 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 354 | bool UpdateEngineClient::GetP2PUpdatePermission() { |
| 355 | bool enabled; |
| 356 | bool ret = proxy_->GetP2PUpdatePermission(&enabled, nullptr); |
| 357 | CHECK(ret) << "Error getting the peer-to-peer update setting."; |
Alex Deymo | 5fdf776 | 2013-07-17 20:01:40 -0700 | [diff] [blame] | 358 | return enabled; |
| 359 | } |
| 360 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 361 | void UpdateEngineClient::OnUpdateCompleteCheck( |
| 362 | int64_t /* last_checked_time */, |
| 363 | double /* progress */, |
| 364 | const string& current_operation, |
| 365 | const string& /* new_version */, |
| 366 | int64_t /* new_size */) { |
| 367 | if (current_operation == update_engine::kUpdateStatusIdle) { |
| 368 | LOG(ERROR) << "Update failed, current operations is " << current_operation; |
Darin Petkov | 58529db | 2010-08-13 09:19:47 -0700 | [diff] [blame] | 369 | exit(1); |
| 370 | } |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 371 | if (current_operation == update_engine::kUpdateStatusUpdatedNeedReboot) { |
Darin Petkov | 58529db | 2010-08-13 09:19:47 -0700 | [diff] [blame] | 372 | LOG(INFO) << "Update succeeded -- reboot needed."; |
| 373 | exit(0); |
| 374 | } |
Darin Petkov | 58529db | 2010-08-13 09:19:47 -0700 | [diff] [blame] | 375 | } |
| 376 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 377 | void UpdateEngineClient::WaitForUpdateComplete() { |
| 378 | proxy_->RegisterStatusUpdateSignalHandler( |
| 379 | base::Bind(&UpdateEngineClient::OnUpdateCompleteCheck, |
| 380 | base::Unretained(this)), |
| 381 | base::Bind(&UpdateEngineClient::OnStatusUpdateSignalRegistration, |
| 382 | base::Unretained(this))); |
Darin Petkov | 58529db | 2010-08-13 09:19:47 -0700 | [diff] [blame] | 383 | } |
| 384 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 385 | void UpdateEngineClient::ShowPrevVersion() { |
| 386 | string prev_version = nullptr; |
Alex Vakulenko | dea2eac | 2014-03-14 15:56:59 -0700 | [diff] [blame] | 387 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 388 | bool ret = proxy_->GetPrevVersion(&prev_version, nullptr);; |
| 389 | if (!ret) { |
| 390 | LOG(ERROR) << "Error getting previous version."; |
Alex Vakulenko | dea2eac | 2014-03-14 15:56:59 -0700 | [diff] [blame] | 391 | } else { |
| 392 | LOG(INFO) << "Previous version = " << prev_version; |
Alex Vakulenko | dea2eac | 2014-03-14 15:56:59 -0700 | [diff] [blame] | 393 | } |
| 394 | } |
| 395 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 396 | bool UpdateEngineClient::GetIsRebootNeeded() { |
| 397 | return GetCurrentOperation() == update_engine::kUpdateStatusUpdatedNeedReboot; |
David Zeuthen | 9d73a72 | 2014-04-04 14:52:46 -0700 | [diff] [blame] | 398 | } |
| 399 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 400 | void UpdateEngineClient::OnRebootNeededCheck( |
| 401 | int64_t /* last_checked_time */, |
| 402 | double /* progress */, |
| 403 | const string& current_operation, |
| 404 | const string& /* new_version */, |
| 405 | int64_t /* new_size */) { |
| 406 | if (current_operation == update_engine::kUpdateStatusUpdatedNeedReboot) { |
| 407 | LOG(INFO) << "Reboot needed."; |
| 408 | exit(0); |
David Zeuthen | 9d73a72 | 2014-04-04 14:52:46 -0700 | [diff] [blame] | 409 | } |
| 410 | } |
| 411 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 412 | void UpdateEngineClient::OnRebootNeededCheckRegistration( |
| 413 | const string& interface, |
| 414 | const string& signal_name, |
| 415 | bool success) { |
| 416 | if (GetIsRebootNeeded()) |
| 417 | exit(0); |
| 418 | if (!success) { |
| 419 | LOG(ERROR) << "Couldn't connect to the " << signal_name << " signal."; |
| 420 | exit(1); |
| 421 | } |
David Zeuthen | 9d73a72 | 2014-04-04 14:52:46 -0700 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | // Blocks until a reboot is needed. Returns true if waiting succeeded, |
| 425 | // false if an error occurred. |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 426 | void UpdateEngineClient::WaitForRebootNeeded() { |
| 427 | proxy_->RegisterStatusUpdateSignalHandler( |
| 428 | base::Bind(&UpdateEngineClient::OnUpdateCompleteCheck, |
| 429 | base::Unretained(this)), |
| 430 | base::Bind(&UpdateEngineClient::OnStatusUpdateSignalRegistration, |
| 431 | base::Unretained(this))); |
| 432 | if (GetIsRebootNeeded()) |
| 433 | exit(0); |
David Zeuthen | 9d73a72 | 2014-04-04 14:52:46 -0700 | [diff] [blame] | 434 | } |
| 435 | |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 436 | int UpdateEngineClient::ProcessFlags() { |
Steve Fung | 97b6f5a | 2014-10-07 12:39:51 -0700 | [diff] [blame] | 437 | DEFINE_string(app_version, "", "Force the current app version."); |
| 438 | DEFINE_string(channel, "", |
| 439 | "Set the target channel. The device will be powerwashed if the " |
| 440 | "target channel is more stable than the current channel unless " |
| 441 | "--nopowerwash is specified."); |
| 442 | DEFINE_bool(check_for_update, false, "Initiate check for updates."); |
| 443 | DEFINE_bool(follow, false, "Wait for any update operations to complete." |
| 444 | "Exit status is 0 if the update succeeded, and 1 otherwise."); |
| 445 | DEFINE_bool(interactive, true, "Mark the update request as interactive."); |
| 446 | DEFINE_string(omaha_url, "", "The URL of the Omaha update server."); |
| 447 | DEFINE_string(p2p_update, "", |
| 448 | "Enables (\"yes\") or disables (\"no\") the peer-to-peer update" |
| 449 | " sharing."); |
| 450 | DEFINE_bool(powerwash, true, "When performing rollback or channel change, " |
| 451 | "do a powerwash or allow it respectively."); |
| 452 | DEFINE_bool(reboot, false, "Initiate a reboot if needed."); |
| 453 | DEFINE_bool(is_reboot_needed, false, "Exit status 0 if reboot is needed, " |
| 454 | "2 if reboot is not needed or 1 if an error occurred."); |
| 455 | DEFINE_bool(block_until_reboot_is_needed, false, "Blocks until reboot is " |
| 456 | "needed. Returns non-zero exit status if an error occurred."); |
| 457 | DEFINE_bool(reset_status, false, "Sets the status in update_engine to idle."); |
Alex Deymo | 1ac8b59 | 2015-01-26 13:22:58 -0800 | [diff] [blame] | 458 | DEFINE_bool(rollback, false, |
| 459 | "Perform a rollback to the previous partition. The device will " |
| 460 | "be powerwashed unless --nopowerwash is specified."); |
Steve Fung | 97b6f5a | 2014-10-07 12:39:51 -0700 | [diff] [blame] | 461 | DEFINE_bool(can_rollback, false, "Shows whether rollback partition " |
| 462 | "is available."); |
| 463 | DEFINE_bool(show_channel, false, "Show the current and target channels."); |
| 464 | DEFINE_bool(show_p2p_update, false, |
| 465 | "Show the current setting for peer-to-peer update sharing."); |
| 466 | DEFINE_bool(show_update_over_cellular, false, |
| 467 | "Show the current setting for updates over cellular networks."); |
| 468 | DEFINE_bool(status, false, "Print the status to stdout."); |
| 469 | DEFINE_bool(update, false, "Forces an update and waits for it to complete. " |
| 470 | "Implies --follow."); |
| 471 | DEFINE_string(update_over_cellular, "", |
| 472 | "Enables (\"yes\") or disables (\"no\") the updates over " |
| 473 | "cellular networks."); |
| 474 | DEFINE_bool(watch_for_updates, false, |
| 475 | "Listen for status updates and print them to the screen."); |
| 476 | DEFINE_bool(prev_version, false, |
| 477 | "Show the previous OS version used before the update reboot."); |
| 478 | DEFINE_bool(show_kernels, false, "Show the list of kernel patritions and " |
| 479 | "whether each of them is bootable or not"); |
| 480 | |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 481 | // Boilerplate init commands. |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 482 | base::CommandLine::Init(argc_, argv_); |
| 483 | chromeos::FlagHelper::Init(argc_, argv_, "Chromium OS Update Engine Client"); |
Andrew de los Reyes | ada4220 | 2010-07-15 22:23:20 -0700 | [diff] [blame] | 484 | |
Alex Deymo | 8ce80d6 | 2015-01-27 15:10:43 -0800 | [diff] [blame] | 485 | // Ensure there are no positional arguments. |
| 486 | const std::vector<string> positional_args = |
| 487 | base::CommandLine::ForCurrentProcess()->GetArgs(); |
| 488 | if (!positional_args.empty()) { |
| 489 | LOG(ERROR) << "Found a positional argument '" << positional_args.front() |
| 490 | << "'. If you want to pass a value to a flag, pass it as " |
| 491 | "--flag=value."; |
| 492 | return 1; |
| 493 | } |
| 494 | |
Jay Srinivasan | c1ba09a | 2012-08-14 14:15:57 -0700 | [diff] [blame] | 495 | // Update the status if requested. |
| 496 | if (FLAGS_reset_status) { |
| 497 | LOG(INFO) << "Setting Update Engine status to idle ..."; |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 498 | ResetStatus(); |
Gilad Arnold | 50c6063 | 2013-01-25 10:27:19 -0800 | [diff] [blame] | 499 | LOG(INFO) << "ResetStatus succeeded; to undo partition table changes run:\n" |
| 500 | "(D=$(rootdev -d) P=$(rootdev -s); cgpt p -i$(($(echo ${P#$D} " |
| 501 | "| sed 's/^[^0-9]*//')-1)) $D;)"; |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 502 | } |
Darin Petkov | 58529db | 2010-08-13 09:19:47 -0700 | [diff] [blame] | 503 | |
Alex Deymo | f4867c4 | 2013-06-28 14:41:39 -0700 | [diff] [blame] | 504 | // Changes the current update over cellular network setting. |
| 505 | if (!FLAGS_update_over_cellular.empty()) { |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 506 | bool allowed = FLAGS_update_over_cellular == "yes"; |
Alex Deymo | f4867c4 | 2013-06-28 14:41:39 -0700 | [diff] [blame] | 507 | if (!allowed && FLAGS_update_over_cellular != "no") { |
| 508 | LOG(ERROR) << "Unknown option: \"" << FLAGS_update_over_cellular |
| 509 | << "\". Please specify \"yes\" or \"no\"."; |
| 510 | } else { |
| 511 | SetUpdateOverCellularPermission(allowed); |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | // Show the current update over cellular network setting. |
| 516 | if (FLAGS_show_update_over_cellular) { |
| 517 | bool allowed = GetUpdateOverCellularPermission(); |
| 518 | LOG(INFO) << "Current update over cellular network setting: " |
| 519 | << (allowed ? "ENABLED" : "DISABLED"); |
| 520 | } |
| 521 | |
Chris Sosa | cb7fa88 | 2013-07-25 17:02:59 -0700 | [diff] [blame] | 522 | if (!FLAGS_powerwash && !FLAGS_rollback && FLAGS_channel.empty()) { |
Chris Sosa | 192449e | 2013-10-28 14:16:19 -0700 | [diff] [blame] | 523 | LOG(ERROR) << "powerwash flag only makes sense rollback or channel change"; |
Chris Sosa | cb7fa88 | 2013-07-25 17:02:59 -0700 | [diff] [blame] | 524 | return 1; |
| 525 | } |
| 526 | |
Alex Deymo | 5fdf776 | 2013-07-17 20:01:40 -0700 | [diff] [blame] | 527 | // Change the P2P enabled setting. |
| 528 | if (!FLAGS_p2p_update.empty()) { |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 529 | bool enabled = FLAGS_p2p_update == "yes"; |
Alex Deymo | 5fdf776 | 2013-07-17 20:01:40 -0700 | [diff] [blame] | 530 | if (!enabled && FLAGS_p2p_update != "no") { |
| 531 | LOG(ERROR) << "Unknown option: \"" << FLAGS_p2p_update |
| 532 | << "\". Please specify \"yes\" or \"no\"."; |
| 533 | } else { |
| 534 | SetP2PUpdatePermission(enabled); |
| 535 | } |
| 536 | } |
| 537 | |
Alex Vakulenko | 59e253e | 2014-02-24 10:40:21 -0800 | [diff] [blame] | 538 | // Show the rollback availability. |
| 539 | if (FLAGS_can_rollback) { |
Alex Deymo | f329b93 | 2014-10-30 01:37:48 -0700 | [diff] [blame] | 540 | string rollback_partition = GetRollbackPartition(); |
Chris Sosa | f5c0b9c | 2014-04-17 16:12:03 -0700 | [diff] [blame] | 541 | bool can_rollback = true; |
| 542 | if (rollback_partition.empty()) { |
Alex Vakulenko | 2bddadd | 2014-03-27 13:23:46 -0700 | [diff] [blame] | 543 | rollback_partition = "UNAVAILABLE"; |
Chris Sosa | f5c0b9c | 2014-04-17 16:12:03 -0700 | [diff] [blame] | 544 | can_rollback = false; |
Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 545 | } else { |
Alex Vakulenko | 2bddadd | 2014-03-27 13:23:46 -0700 | [diff] [blame] | 546 | rollback_partition = "AVAILABLE: " + rollback_partition; |
Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 547 | } |
Alex Vakulenko | 2bddadd | 2014-03-27 13:23:46 -0700 | [diff] [blame] | 548 | |
| 549 | LOG(INFO) << "Rollback partition: " << rollback_partition; |
Chris Sosa | f5c0b9c | 2014-04-17 16:12:03 -0700 | [diff] [blame] | 550 | if (!can_rollback) { |
| 551 | return 1; |
| 552 | } |
Alex Vakulenko | 59e253e | 2014-02-24 10:40:21 -0800 | [diff] [blame] | 553 | } |
| 554 | |
Alex Deymo | 5fdf776 | 2013-07-17 20:01:40 -0700 | [diff] [blame] | 555 | // Show the current P2P enabled setting. |
| 556 | if (FLAGS_show_p2p_update) { |
| 557 | bool enabled = GetP2PUpdatePermission(); |
| 558 | LOG(INFO) << "Current update using P2P setting: " |
| 559 | << (enabled ? "ENABLED" : "DISABLED"); |
| 560 | } |
| 561 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 562 | // First, update the target channel if requested. |
| 563 | if (!FLAGS_channel.empty()) |
Chris Sosa | cb7fa88 | 2013-07-25 17:02:59 -0700 | [diff] [blame] | 564 | SetTargetChannel(FLAGS_channel, FLAGS_powerwash); |
Darin Petkov | 8daa324 | 2010-10-25 13:28:47 -0700 | [diff] [blame] | 565 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 566 | // Show the current and target channels if requested. |
| 567 | if (FLAGS_show_channel) { |
| 568 | string current_channel = GetChannel(true); |
| 569 | LOG(INFO) << "Current Channel: " << current_channel; |
| 570 | |
| 571 | string target_channel = GetChannel(false); |
| 572 | if (!target_channel.empty()) |
| 573 | LOG(INFO) << "Target Channel (pending update): " << target_channel; |
Satoru Takabayashi | 583667b | 2010-10-27 13:09:57 +0900 | [diff] [blame] | 574 | } |
| 575 | |
Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 576 | bool do_update_request = FLAGS_check_for_update | FLAGS_update | |
| 577 | !FLAGS_app_version.empty() | !FLAGS_omaha_url.empty(); |
Chris Sosa | 192449e | 2013-10-28 14:16:19 -0700 | [diff] [blame] | 578 | if (FLAGS_update) |
| 579 | FLAGS_follow = true; |
Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 580 | |
Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 581 | if (do_update_request && FLAGS_rollback) { |
Chris Sosa | 192449e | 2013-10-28 14:16:19 -0700 | [diff] [blame] | 582 | LOG(ERROR) << "Incompatible flags specified with rollback." |
| 583 | << "Rollback should not include update-related flags."; |
Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 584 | return 1; |
| 585 | } |
| 586 | |
Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 587 | if (FLAGS_rollback) { |
Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 588 | LOG(INFO) << "Requesting rollback."; |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 589 | Rollback(FLAGS_powerwash); |
Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 590 | } |
| 591 | |
Darin Petkov | 58529db | 2010-08-13 09:19:47 -0700 | [diff] [blame] | 592 | // Initiate an update check, if necessary. |
Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 593 | if (do_update_request) { |
Darin Petkov | 296889c | 2010-07-23 16:20:54 -0700 | [diff] [blame] | 594 | LOG_IF(WARNING, FLAGS_reboot) << "-reboot flag ignored."; |
Darin Petkov | 58529db | 2010-08-13 09:19:47 -0700 | [diff] [blame] | 595 | string app_version = FLAGS_app_version; |
| 596 | if (FLAGS_update && app_version.empty()) { |
| 597 | app_version = "ForcedUpdate"; |
| 598 | LOG(INFO) << "Forcing an update by setting app_version to ForcedUpdate."; |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 599 | } |
Darin Petkov | 58529db | 2010-08-13 09:19:47 -0700 | [diff] [blame] | 600 | LOG(INFO) << "Initiating update check and install."; |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 601 | CheckForUpdates(app_version, FLAGS_omaha_url, FLAGS_interactive); |
Chris Sosa | 192449e | 2013-10-28 14:16:19 -0700 | [diff] [blame] | 602 | } |
Darin Petkov | 58529db | 2010-08-13 09:19:47 -0700 | [diff] [blame] | 603 | |
Chris Sosa | 192449e | 2013-10-28 14:16:19 -0700 | [diff] [blame] | 604 | // These final options are all mutually exclusive with one another. |
David Zeuthen | 9d73a72 | 2014-04-04 14:52:46 -0700 | [diff] [blame] | 605 | if (FLAGS_follow + FLAGS_watch_for_updates + FLAGS_reboot + |
| 606 | FLAGS_status + FLAGS_is_reboot_needed + |
Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 607 | FLAGS_block_until_reboot_is_needed > 1) { |
Chris Sosa | 192449e | 2013-10-28 14:16:19 -0700 | [diff] [blame] | 608 | LOG(ERROR) << "Multiple exclusive options selected. " |
| 609 | << "Select only one of --follow, --watch_for_updates, --reboot, " |
David Zeuthen | 9d73a72 | 2014-04-04 14:52:46 -0700 | [diff] [blame] | 610 | << "--is_reboot_needed, --block_until_reboot_is_needed, " |
Chris Sosa | 192449e | 2013-10-28 14:16:19 -0700 | [diff] [blame] | 611 | << "or --status."; |
| 612 | return 1; |
| 613 | } |
| 614 | |
| 615 | if (FLAGS_status) { |
| 616 | LOG(INFO) << "Querying Update Engine status..."; |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 617 | ShowStatus(); |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 618 | return 0; |
| 619 | } |
Darin Petkov | 58529db | 2010-08-13 09:19:47 -0700 | [diff] [blame] | 620 | |
Chris Sosa | 192449e | 2013-10-28 14:16:19 -0700 | [diff] [blame] | 621 | if (FLAGS_follow) { |
| 622 | LOG(INFO) << "Waiting for update to complete."; |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 623 | WaitForUpdateComplete(); |
| 624 | return kContinueRunning; |
Chris Sosa | 192449e | 2013-10-28 14:16:19 -0700 | [diff] [blame] | 625 | } |
| 626 | |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 627 | if (FLAGS_watch_for_updates) { |
| 628 | LOG(INFO) << "Watching for status updates."; |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 629 | WatchForUpdates(); |
| 630 | return kContinueRunning; |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 631 | } |
Darin Petkov | 58529db | 2010-08-13 09:19:47 -0700 | [diff] [blame] | 632 | |
Darin Petkov | 296889c | 2010-07-23 16:20:54 -0700 | [diff] [blame] | 633 | if (FLAGS_reboot) { |
| 634 | LOG(INFO) << "Requesting a reboot..."; |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 635 | RebootIfNeeded(); |
Darin Petkov | 296889c | 2010-07-23 16:20:54 -0700 | [diff] [blame] | 636 | return 0; |
| 637 | } |
Andrew de los Reyes | ada4220 | 2010-07-15 22:23:20 -0700 | [diff] [blame] | 638 | |
Alex Vakulenko | dea2eac | 2014-03-14 15:56:59 -0700 | [diff] [blame] | 639 | if (FLAGS_prev_version) { |
| 640 | ShowPrevVersion(); |
| 641 | } |
| 642 | |
Alex Vakulenko | 2bddadd | 2014-03-27 13:23:46 -0700 | [diff] [blame] | 643 | if (FLAGS_show_kernels) { |
| 644 | LOG(INFO) << "Kernel partitions:\n" |
| 645 | << GetKernelDevices(); |
| 646 | } |
| 647 | |
David Zeuthen | 9d73a72 | 2014-04-04 14:52:46 -0700 | [diff] [blame] | 648 | if (FLAGS_is_reboot_needed) { |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 649 | // In case of error GetIsRebootNeeded() will exit with 1. |
| 650 | if (GetIsRebootNeeded()) { |
| 651 | return 0; |
| 652 | } else { |
David Zeuthen | 9d73a72 | 2014-04-04 14:52:46 -0700 | [diff] [blame] | 653 | return 2; |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 654 | } |
David Zeuthen | 9d73a72 | 2014-04-04 14:52:46 -0700 | [diff] [blame] | 655 | } |
| 656 | |
| 657 | if (FLAGS_block_until_reboot_is_needed) { |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 658 | WaitForRebootNeeded(); |
| 659 | return kContinueRunning; |
David Zeuthen | 9d73a72 | 2014-04-04 14:52:46 -0700 | [diff] [blame] | 660 | } |
| 661 | |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 662 | return 0; |
| 663 | } |
Alex Deymo | 72aa002 | 2015-06-19 21:16:49 -0700 | [diff] [blame] | 664 | |
| 665 | } // namespace |
| 666 | |
| 667 | int main(int argc, char** argv) { |
| 668 | UpdateEngineClient client(argc, argv); |
| 669 | return client.Run(); |
| 670 | } |