2 * Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include <sys/prctl.h>
21 #include "anbox/system_configuration.h"
22 #include "anbox/daemon.h"
23 #include "anbox/logger.h"
25 #include "anbox/cmds/container_manager.h"
26 #include "anbox/cmds/session_manager.h"
27 #include "anbox/cmds/system_info.h"
28 #include "anbox/cmds/launch.h"
29 #include "anbox/cmds/version.h"
30 #include "anbox/cmds/wait_ready.h"
31 #include "anbox/cmds/check_features.h"
33 #include <boost/filesystem.hpp>
35 namespace fs = boost::filesystem;
39 : cmd{cli::Name{"anbox"}, cli::Usage{"anbox"},
40 cli::Description{"The Android in a Box runtime"}} {
41 cmd.command(std::make_shared<cmds::Version>())
42 .command(std::make_shared<cmds::SessionManager>())
43 .command(std::make_shared<cmds::Launch>())
44 .command(std::make_shared<cmds::ContainerManager>())
45 .command(std::make_shared<cmds::SystemInfo>())
46 .command(std::make_shared<cmds::WaitReady>())
47 .command(std::make_shared<cmds::CheckFeatures>());
49 Log().Init(anbox::Logger::Severity::kWarning);
51 const auto log_level = utils::get_env_value("ANBOX_LOG_LEVEL", "");
52 if (!log_level.empty() && !Log().SetSeverityFromString(log_level))
53 WARNING("Failed to set logging severity to '%s'", log_level);
56 int Daemon::Run(const std::vector<std::string> &arguments) try {
57 auto argv = arguments;
58 if (arguments.size() == 0) argv = {"help"};
59 return cmd.run({std::cin, std::cout, argv});
60 } catch (std::exception &err) {
61 ERROR("%s", err.what());