summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Admin
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2009-11-05 04:49:55 +0000
committerNarayan Desai <desai@mcs.anl.gov>2009-11-05 04:49:55 +0000
commit4b866e4d510f83404425a5ffad3b6149627b273a (patch)
tree1a8241d95b2b5bb014121ee443ca21a48494cc59 /src/lib/Server/Admin
parent336b8734c5246808de6e30ec72b65d804a8b2636 (diff)
downloadbcfg2-4b866e4d510f83404425a5ffad3b6149627b273a.tar.gz
bcfg2-4b866e4d510f83404425a5ffad3b6149627b273a.tar.bz2
bcfg2-4b866e4d510f83404425a5ffad3b6149627b273a.zip
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
Diffstat (limited to 'src/lib/Server/Admin')
-rw-r--r--src/lib/Server/Admin/Init.py24
1 files changed, 13 insertions, 11 deletions
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):