import.c revision 0c7bf33a989a58922b3eb9aaa96abd773c8754c4
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering/***
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering This file is part of systemd.
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering Copyright 2014 Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering systemd is free software; you can redistribute it and/or modify it
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering under the terms of the GNU Lesser General Public License as published by
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering (at your option) any later version.
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering systemd is distributed in the hope that it will be useful, but
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering Lesser General Public License for more details.
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering You should have received a copy of the GNU Lesser General Public License
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering***/
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering#include <getopt.h>
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering#include "sd-event.h"
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering#include "event-util.h"
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering#include "verbs.h"
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering#include "build.h"
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering#include "import-dkr.h"
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringstatic bool arg_force = false;
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
b5efdb8af40ea759a1ea584c1bc44ecc81dd00ceLennart Poetteringstatic const char* arg_dkr_index_url = DEFAULT_DKR_INDEX_URL;
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringstatic void on_finished(DkrImport *import, int error, void *userdata) {
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poettering sd_event *event = userdata;
0d39fa9c69b97a2ceb156053deef69c0866c2b97Lennart Poettering assert(import);
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering if (error == 0)
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering log_info("Operation completed successfully.");
5f311f8c0e51e2f13773823feb6a71f7c6f2838cLennart Poettering else
9bf3b53533cdc9b95c921b71da755401f223f765Lennart Poettering log_info_errno(error, "Operation failed: %m");
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering sd_event_exit(event, error);
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering}
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poetteringstatic int pull_dkr(int argc, char *argv[], void *userdata) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering _cleanup_(dkr_import_unrefp) DkrImport *import = NULL;
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek _cleanup_event_unref_ sd_event *event = NULL;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering const char *name, *tag, *local;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering int r;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (!arg_dkr_index_url) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering log_error("Please specify an index URL with --dkr-index-url=");
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering return -EINVAL;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering }
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering tag = strchr(argv[1], ':');
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (tag) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering name = strndupa(argv[1], tag - argv[1]);
83f6936a018b08880670838756e0f4e9ea98b4a7Lennart Poettering tag++;
83f6936a018b08880670838756e0f4e9ea98b4a7Lennart Poettering } else {
83f6936a018b08880670838756e0f4e9ea98b4a7Lennart Poettering name = argv[1];
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering tag = "latest";
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering }
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (argc >= 3)
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering local = argv[2];
83f6936a018b08880670838756e0f4e9ea98b4a7Lennart Poettering else {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering local = strchr(name, '/');
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (local)
b826ab586c9e0a9c0d438a75c28cf3a8ab485929Tom Gundersen local++;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering else
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering local = name;
b826ab586c9e0a9c0d438a75c28cf3a8ab485929Tom Gundersen }
b826ab586c9e0a9c0d438a75c28cf3a8ab485929Tom Gundersen
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (isempty(local) || streq(local, "-"))
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering local = NULL;
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidt
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (!dkr_name_is_valid(name)) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering log_error("Remote name '%s' is not valid.", name);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering return -EINVAL;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering }
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (!dkr_tag_is_valid(tag)) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering log_error("Tag name '%s' is not valid.", tag);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering return -EINVAL;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering }
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
18cd5fe99f70a55a2d6f2303d6ee0624942695b1Zbigniew Jędrzejewski-Szmek if (local) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering const char *p;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidt if (!machine_name_is_valid(local)) {
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidt log_error("Local image name '%s' is not valid.", local);
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidt return -EINVAL;
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidt }
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidt
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering p = strappenda("/var/lib/container/", local);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (laccess(p, F_OK) >= 0) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (!arg_force) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering log_info("Image '%s' already exists.", local);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering return 0;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering }
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering } else if (errno != ENOENT)
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering return log_error_errno(errno, "Can't check if image '%s' already exists: %m", local);
e3b9d9c8027a7c4c55cf1614e0fe9423fad69e8fZbigniew Jędrzejewski-Szmek
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering log_info("Pulling '%s' with tag '%s', saving as '%s'.", name, tag, local);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering } else
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering log_info("Pulling '%s' with tag '%s'.", name, tag);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering r = sd_event_default(&event);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (r < 0)
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering return log_error_errno(r, "Failed to allocate event loop: %m");
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering sd_event_add_signal(event, NULL, SIGTERM, NULL, NULL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering sd_event_add_signal(event, NULL, SIGINT, NULL, NULL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering r = dkr_import_new(&import, event, arg_dkr_index_url, on_dkr_finished, event);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (r < 0)
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering return log_error_errno(r, "Failed to allocate importer: %m");
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek r = dkr_import_pull(import, name, tag, local, arg_force);
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek if (r < 0)
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek return log_error_errno(r, "Failed to pull image: %m");
83f6936a018b08880670838756e0f4e9ea98b4a7Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering r = sd_event_loop(event);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (r < 0)
e3b9d9c8027a7c4c55cf1614e0fe9423fad69e8fZbigniew Jędrzejewski-Szmek return log_error_errno(r, "Failed to run event loop: %m");
18cd5fe99f70a55a2d6f2303d6ee0624942695b1Zbigniew Jędrzejewski-Szmek
18cd5fe99f70a55a2d6f2303d6ee0624942695b1Zbigniew Jędrzejewski-Szmek log_info("Exiting.");
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
e3b9d9c8027a7c4c55cf1614e0fe9423fad69e8fZbigniew Jędrzejewski-Szmek return 0;
e3b9d9c8027a7c4c55cf1614e0fe9423fad69e8fZbigniew Jędrzejewski-Szmek}
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
e3b9d9c8027a7c4c55cf1614e0fe9423fad69e8fZbigniew Jędrzejewski-Szmekstatic int help(int argc, char *argv[], void *userdata) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering printf("%s [OPTIONS...] {COMMAND} ...\n\n"
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering "Import container or virtual machine image.\n\n"
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek " -h --help Show this help\n"
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek " --version Show package version\n"
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek " --force Force creation of image\n"
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek " --dkr-index-url=URL Specify index URL to use for downloads\n\n"
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek "Commands:\n"
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek " pull-dkr REMOTE [NAME] Download an image\n",
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek program_invocation_short_name);
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek
4b8268f843b0da1cfe1995d93a0b1f95faccc454Zbigniew Jędrzejewski-Szmek return 0;
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek}
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek
4b8268f843b0da1cfe1995d93a0b1f95faccc454Zbigniew Jędrzejewski-Szmekstatic int parse_argv(int argc, char *argv[]) {
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek enum {
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek ARG_VERSION = 0x100,
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek ARG_FORCE,
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek ARG_DKR_INDEX_URL,
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek };
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek static const struct option options[] = {
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek { "help", no_argument, NULL, 'h' },
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek { "version", no_argument, NULL, ARG_VERSION },
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek { "force", no_argument, NULL, ARG_FORCE },
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek { "dkr-index-url", required_argument, NULL, ARG_DKR_INDEX_URL },
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek {}
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek };
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek int c;
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek assert(argc >= 0);
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek assert(argv);
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0)
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek switch (c) {
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek case 'h':
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek return help(0, NULL, NULL);
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek case ARG_VERSION:
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek puts(PACKAGE_STRING);
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek puts(SYSTEMD_FEATURES);
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek return 0;
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek case ARG_FORCE:
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek arg_force = true;
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek break;
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek case ARG_DKR_INDEX_URL:
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek if (!dkr_url_is_valid(optarg)) {
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek log_error("Index URL is not valid: %s", optarg);
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek return -EINVAL;
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek }
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering arg_dkr_index_url = optarg;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering break;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering case '?':
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek return -EINVAL;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering default:
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_not_reached("Unhandled option");
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering }
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering return 1;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering}
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4fMichal Schmidtstatic int import_main(int argc, char *argv[]) {
4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4fMichal Schmidt
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering static const Verb verbs[] = {
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek { "help", VERB_ANY, VERB_ANY, 0, help },
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek { "pull-dkr", 2, 3, 0, pull_dkr },
709f6e46a35ec492b70eb92943d82a8d838ce918Michal Schmidt {}
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek };
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek return dispatch_verb(argc, argv, verbs, NULL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering}
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint main(int argc, char *argv[]) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering int r;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering setlocale(LC_ALL, "");
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering log_parse_environment();
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering log_open();
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
56f64d95763a799ba4475daf44d8e9f72a1bd474Michal Schmidt r = parse_argv(argc, argv);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (r <= 0)
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering goto finish;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering r = import_main(argc, argv);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringfinish:
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering}
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering