blob: f2e200039928928e15ff3b272dd6679f387a22fc [file] [log] [blame]
// Copyright 2018 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <cstdlib>
#include <string>
#include <base/at_exit.h>
#include <base/command_line.h>
#include <base/logging.h>
#include <base/memory/ref_counted.h>
#include <brillo/syslog_logging.h>
#include "shill/rpc_task.h"
#include "shill/shims/environment.h"
#include "shill/shims/task_proxy.h"
using shill::shims::Environment;
using std::map;
using std::string;
int main(int argc, char** argv) {
base::AtExitManager exit_manager;
base::CommandLine::Init(argc, argv);
brillo::InitLog(brillo::kLogToSyslog | brillo::kLogHeader);
Environment* environment = Environment::GetInstance();
string service, path, reason;
if (!environment->GetVariable(shill::kRpcTaskServiceVariable, &service) ||
!environment->GetVariable(shill::kRpcTaskPathVariable, &path) ||
!environment->GetVariable("script_type", &reason)) {
LOG(ERROR) << "Environment variables not available.";
return EXIT_FAILURE;
}
scoped_refptr<dbus::Bus> bus;
dbus::Bus::Options options;
options.bus_type = dbus::Bus::SYSTEM;
bus = new dbus::Bus(options);
CHECK(bus->Connect());
shill::shims::TaskProxy proxy(bus, path, service);
map<string, string> env = environment->AsMap();
proxy.Notify(reason, env);
if (bus) {
bus->ShutdownAndBlock();
}
return EXIT_SUCCESS;
}