1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2010 Lennart Poettering
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"
31 static const char *arg_root
= NULL
;
32 static bool arg_commit
= false;
34 static void help(void) {
35 printf("%s [OPTIONS...]\n\n"
36 "Initialize /etc/machine-id from a random source.\n\n"
37 " -h --help Show this help\n"
38 " --version Show package version\n"
39 " --root=ROOT Filesystem root\n"
40 " --commit Commit transient ID\n"
41 , program_invocation_short_name
);
44 static int parse_argv(int argc
, char *argv
[]) {
52 static const struct option options
[] = {
53 { "help", no_argument
, NULL
, 'h' },
54 { "version", no_argument
, NULL
, ARG_VERSION
},
55 { "root", required_argument
, NULL
, ARG_ROOT
},
56 { "commit", no_argument
, NULL
, ARG_COMMIT
},
65 while ((c
= getopt_long(argc
, argv
, "hqcv", options
, NULL
)) >= 0)
88 assert_not_reached("Unhandled option");
92 log_error("Extraneous arguments");
99 int main(int argc
, char *argv
[]) {
102 log_parse_environment();
105 r
= parse_argv(argc
, argv
);
107 return r
< 0 ? EXIT_FAILURE
: EXIT_SUCCESS
;
110 r
= machine_id_commit(arg_root
);
112 r
= machine_id_setup(arg_root
);
115 return r
< 0 ? EXIT_FAILURE
: EXIT_SUCCESS
;