summaryrefslogtreecommitdiff
path: root/src/machine-id-setup/machine-id-setup-main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/machine-id-setup/machine-id-setup-main.c')
-rw-r--r--src/machine-id-setup/machine-id-setup-main.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/machine-id-setup/machine-id-setup-main.c b/src/machine-id-setup/machine-id-setup-main.c
index e5606c9a03..a9c4e3fadf 100644
--- a/src/machine-id-setup/machine-id-setup-main.c
+++ b/src/machine-id-setup/machine-id-setup-main.c
@@ -28,15 +28,17 @@
#include "machine-id-setup.h"
#include "util.h"
-static const char *arg_root = "";
+static const char *arg_root = NULL;
+static bool arg_commit = false;
static void help(void) {
printf("%s [OPTIONS...]\n\n"
"Initialize /etc/machine-id from a random source.\n\n"
" -h --help Show this help\n"
" --version Show package version\n"
- " --root=ROOT Filesystem root\n",
- program_invocation_short_name);
+ " --root=ROOT Filesystem root\n"
+ " --commit Commit transient ID\n"
+ , program_invocation_short_name);
}
static int parse_argv(int argc, char *argv[]) {
@@ -44,12 +46,14 @@ static int parse_argv(int argc, char *argv[]) {
enum {
ARG_VERSION = 0x100,
ARG_ROOT,
+ ARG_COMMIT,
};
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, ARG_VERSION },
{ "root", required_argument, NULL, ARG_ROOT },
+ { "commit", no_argument, NULL, ARG_COMMIT },
{}
};
@@ -73,6 +77,10 @@ static int parse_argv(int argc, char *argv[]) {
arg_root = optarg;
break;
+ case ARG_COMMIT:
+ arg_commit = true;
+ break;
+
case '?':
return -EINVAL;
@@ -98,5 +106,11 @@ int main(int argc, char *argv[]) {
if (r <= 0)
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
- return machine_id_setup(arg_root) < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
+ if (arg_commit)
+ r = machine_id_commit(arg_root);
+ else
+ r = machine_id_setup(arg_root);
+
+
+ return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}