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