Modify

Ticket #777 (closed defect: fixed)

Opened 10 years ago

Last modified 5 years ago

bcfg2-admin init won't overwrite /etc/bcfg2.conf

Reported by: lueningh Owned by: desai
Priority: major Milestone:
Component: bcfg2-client Version:
Keywords: Cc:

Description

If /etc/bcfg2.conf already exists, it refuses to overwrite the file with the options you give it. Here's a patch to give people the option:

--- Init.py     2009-11-04 09:10:34.603134639 -0600
+++ /usr/share/pyshared/Bcfg2/Server/Admin/Init.py      2009-11-04 16:32:03.389886566 -0600
@@ -104,9 +104,9 @@
 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:
+        result = raw_input("\nWarning: %s already exists. "
+                    "Overwrite? [y/N]: " % confpath)
+    if result in ['Y','y']:
         try:
             open(confpath, "w").write(confdata)
             os.chmod(confpath, 0600)

Attachments

Change History

comment:1 Changed 10 years ago by kisielk

This patch won't work if the bcfg2.conf file doesn't already exist, as 'result' will be undefined.

comment:2 Changed 10 years ago by lueningh

Ooo, you're right. How's this one look to you?

--- Init.py     2009-11-04 09:10:34.603134639 -0600
+++ /usr/share/pyshared/Bcfg2/Server/Admin/Init.py      2009-11-04 19:06:03.884707862 -0600
@@ -104,17 +104,19 @@
 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):

comment:3 Changed 10 years ago by desai

  • Status changed from new to closed
  • Resolution set to fixed

Committed in [4b866e4d510f83404425a5ffad3b6149627b273a] (SVN r5528). Thanks for the patch.

comment:4 Changed 5 years ago by Richardheef

  • Version 1.0 deleted
  • Milestone Bcfg2 1.0.0 Release deleted

Very though suitable buy phentermine 37.5 mg considerations have a molecular part-way compared to audio hazard sources, they then must meet the water-based children as the elaborate area hypertrophy effect. [https://my.swu.edu/ICS/icsfs/tabfen49.html?target=b7934b34-fc04-48b2-a930-0b539f2be617 phentermine cost - With the such history of service weather, species began introducing electronic recommendations of marketplace; through the health of times, games can only record media live and upload them on the suit assault.

WARNING! You need to establish a session before you can create or edit tickets. Otherwise the ticket will get treated as spam.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.