1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2014 Didier Roche
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
28 #include "machine-id-setup.h"
32 static const char *arg_root = "";
34 static void help(void) {
35 printf("%s [OPTIONS...]\n\n"
36 "Commit a transient /etc/machine-id on disk if writable.\n\n"
37 " -h --help Show this help\n"
38 " --version Show package version\n"
39 " --root=ROOT Filesystem root\n",
40 program_invocation_short_name);
43 static int parse_argv(int argc, char *argv[]) {
50 static const struct option options[] = {
51 { "help", no_argument, NULL, 'h' },
52 { "version", no_argument, NULL, ARG_VERSION },
53 { "root", required_argument, NULL, ARG_ROOT },
62 while ((c = getopt_long(argc, argv, "hqcv", options, NULL)) >= 0)
71 puts(SYSTEMD_FEATURES);
82 assert_not_reached("Unhandled option");
86 log_error("Extraneous arguments");
93 int main(int argc, char *argv[]) {
96 log_set_target(LOG_TARGET_AUTO);
97 log_parse_environment();
100 r = parse_argv(argc, argv);
102 return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
104 return machine_id_commit(arg_root) < 0 ? EXIT_FAILURE : EXIT_SUCCESS;