From 9317e5dc2764088e98bd03d23861356328690618 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Wed, 11 Sep 2013 11:00:15 +0200 Subject: [PATCH] Make tools/users-setup explain its actions first Before doing any changes, make tools/users-setup explain its actions first, and ask the user for confirmation. If the first argument is --yes-do-it, this step will be skipped. Signed-off-by: Klaus Aehlig Reviewed-by: Michele Tartara --- Makefile.am | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Makefile.am b/Makefile.am index 2fd79b9..0f8941f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1384,6 +1384,19 @@ tools/kvm-ifup: tools/kvm-ifup.in $(REPLACE_VARS_SED) tools/users-setup: Makefile $(userspecs) set -e; \ { echo '#!/bin/sh'; \ + echo 'if [ "x$$1" != "x--yes-do-it" ];'; \ + echo 'then echo "This will do the following changes"'; \ + $(AWK) -- '{print "echo + Will add group ",$$1; count++}\ + END {if (count == 0) {print "echo + No groups to add"}}' doc/users/groups; \ + $(AWK) -- '{if (NF > 1) {print "echo + Will add user",$$1,"with primary group",$$2} \ + else {print "echo + Will add user",$$1}; count++}\ + END {if (count == 0) {print "echo + No users to add"}}' doc/users/users; \ + $(AWK) -- '{print "echo + Will add user",$$1,"to group",$$2}' doc/users/groupmemberships; \ + echo 'echo'; \ + echo 'echo "OK? (y/n)"'; \ + echo 'read confirm'; \ + echo 'if [ "x$$confirm" != "xy" ]; then exit 0; fi'; \ + echo 'fi'; \ $(AWK) -- '{print "addgroup --system",$$1}' doc/users/groups; \ $(AWK) -- '{if (NF > 1) {print "adduser --system --ingroup",$$2,$$1} else {print "adduser --system",$$1}}' doc/users/users; \ $(AWK) -- '{print "adduser",$$1,$$2}' doc/users/groupmemberships; \ -- 1.7.10.4