From 4b866e4d510f83404425a5ffad3b6149627b273a Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Thu, 5 Nov 2009 04:49:55 +0000 Subject: bcfg2-admin init: prompt in case of pre-existing bcfg2.conf (Resolves Ticket #777) (patch from cory lueninghoener) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5528 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Admin/Init.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/lib') diff --git a/src/lib/Server/Admin/Init.py b/src/lib/Server/Admin/Init.py index 9fc2a23fe..f65bdd792 100644 --- a/src/lib/Server/Admin/Init.py +++ b/src/lib/Server/Admin/Init.py @@ -104,17 +104,19 @@ def create_key(keypath): def create_conf(confpath, confdata): # don't overwrite existing bcfg2.conf file if os.path.exists(confpath): - print("\nWarning: %s already exists. Will not be " - "overwritten...\n" % confpath) - else: - try: - open(confpath, "w").write(confdata) - os.chmod(confpath, 0600) - except Exception, e: - print("Error %s occured while trying to write configuration " - "file to '%s'\n" % - (e, confpath)) - raise SystemExit(1) + result = raw_input("\nWarning: %s already exists. " + "Overwrite? [y/N]: " % confpath) + if result not in ['Y', 'y']: + print("Leaving %s unchanged" % confpath) + return + try: + open(confpath, "w").write(confdata) + os.chmod(confpath, 0600) + except Exception, e: + print("Error %s occured while trying to write configuration " + "file to '%s'\n" % + (e, confpath)) + raise SystemExit(1) class Init(Bcfg2.Server.Admin.Mode): -- cgit v1.2.3-1-g7c22