summaryrefslogtreecommitdiff
path: root/src/machine-id-setup/machine-id-setup-main.c
diff options
context:
space:
mode:
authorDaniel Mack <github@zonque.org>2015-09-29 22:10:40 +0200
committerDaniel Mack <github@zonque.org>2015-09-29 22:10:40 +0200
commit2ea69f8d5e4a83397c5050914adf6452cafa9559 (patch)
tree0906a2b4440a0262d9ef2b3d79977e6b33ea74e6 /src/machine-id-setup/machine-id-setup-main.c
parent41d5895f80962ab91472f5ec86fa55da60e14551 (diff)
parent7f96539d45028650f2ba9452095473a9c455d84b (diff)
Merge pull request #1408 from poettering/systemctl-and-more
Systemctl and more
Diffstat (limited to 'src/machine-id-setup/machine-id-setup-main.c')
-rw-r--r--src/machine-id-setup/machine-id-setup-main.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/machine-id-setup/machine-id-setup-main.c b/src/machine-id-setup/machine-id-setup-main.c
index 20cb60b804..a9c4e3fadf 100644
--- a/src/machine-id-setup/machine-id-setup-main.c
+++ b/src/machine-id-setup/machine-id-setup-main.c
@@ -19,24 +19,26 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <stdlib.h>
-#include <stdio.h>
-#include <getopt.h>
#include <errno.h>
+#include <getopt.h>
+#include <stdio.h>
+#include <stdlib.h>
-#include "machine-id-setup.h"
#include "log.h"
-#include "build.h"
+#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 },
{}
};
@@ -67,14 +71,16 @@ static int parse_argv(int argc, char *argv[]) {
return 0;
case ARG_VERSION:
- puts(PACKAGE_STRING);
- puts(SYSTEMD_FEATURES);
- return 0;
+ return version();
case ARG_ROOT:
arg_root = optarg;
break;
+ case ARG_COMMIT:
+ arg_commit = true;
+ break;
+
case '?':
return -EINVAL;
@@ -100,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;
}