2 This file is part of systemd.
4 Copyright 2010 Lennart Poettering
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
26 #include "machine-id-setup.h"
27 #include "path-util.h"
30 static char *arg_root
= NULL
;
31 static bool arg_commit
= false;
33 static void help(void) {
34 printf("%s [OPTIONS...]\n\n"
35 "Initialize /etc/machine-id from a random source.\n\n"
36 " -h --help Show this help\n"
37 " --version Show package version\n"
38 " --root=ROOT Filesystem root\n"
39 " --commit Commit transient ID\n"
40 , program_invocation_short_name
);
43 static int parse_argv(int argc
, char *argv
[]) {
51 static const struct option options
[] = {
52 { "help", no_argument
, NULL
, 'h' },
53 { "version", no_argument
, NULL
, ARG_VERSION
},
54 { "root", required_argument
, NULL
, ARG_ROOT
},
55 { "commit", no_argument
, NULL
, ARG_COMMIT
},
64 while ((c
= getopt_long(argc
, argv
, "hqcv", options
, NULL
)) >= 0)
76 r
= parse_path_argument_and_warn(optarg
, true, &arg_root
);
89 assert_not_reached("Unhandled option");
93 log_error("Extraneous arguments");
100 int main(int argc
, char *argv
[]) {
103 log_parse_environment();
106 r
= parse_argv(argc
, argv
);
111 r
= machine_id_commit(arg_root
);
113 r
= machine_id_setup(arg_root
, SD_ID128_NULL
);
117 return r
< 0 ? EXIT_FAILURE
: EXIT_SUCCESS
;