diff options
-rw-r--r-- | man/bcfg2.1 | 7 | ||||
-rw-r--r-- | src/lib/Client/Debian.py | 4 | ||||
-rw-r--r-- | src/lib/Client/Toolset.py | 21 | ||||
-rwxr-xr-x | src/sbin/bcfg2 | 6 |
4 files changed, 34 insertions, 4 deletions
diff --git a/man/bcfg2.1 b/man/bcfg2.1 index 4af67efeb..908052df3 100644 --- a/man/bcfg2.1 +++ b/man/bcfg2.1 @@ -3,7 +3,7 @@ bcfg \- reconfigure machine based on settings in BCFG2 .SH SYNOPSIS .B bcfg2 -.I [-d] [-v] [-p] [-c cache file] [-f config file] [-q] [-b bundle] +.I [-d] [-v] [-p] [-c cache file] [-f config file] [-I] [-q] [-b bundle] [-r removal mode] .SH DESCRIPTION .PP @@ -39,6 +39,11 @@ Run bcfg2 in quick mode. Package checksum verification won't be performed. This mode relaxes the constraints of correctness, and thus should only be used in safe conditions. .RE +.B "\-I" +.RS +Run bcfg2 in interactive mode. The user will be prompted before each +change. +.RE .B "\-n" .RS Run bcfg2 in dry-run mode. No changes will be made to the diff --git a/src/lib/Client/Debian.py b/src/lib/Client/Debian.py index 4c13443f0..b431f982d 100644 --- a/src/lib/Client/Debian.py +++ b/src/lib/Client/Debian.py @@ -20,8 +20,8 @@ class ToolsetImpl(Bcfg2.Client.Toolset.Toolset): self.logger.debug('Configuring Debian toolset') os.environ["DEBIAN_FRONTEND"] = 'noninteractive' # dup /dev/null on top of stdin - null = open('/dev/null', 'w+') - os.dup2(null.fileno(), sys.__stdin__.fileno()) + #null = open('/dev/null', 'w+') + #os.dup2(null.fileno(), sys.__stdin__.fileno()) if not self.setup['dryrun']: if self.setup['kevlar']: self.saferun("dpkg --force-confold --configure --pending") diff --git a/src/lib/Client/Toolset.py b/src/lib/Client/Toolset.py index fbf4ae7c4..7aa6a420f 100644 --- a/src/lib/Client/Toolset.py +++ b/src/lib/Client/Toolset.py @@ -555,7 +555,7 @@ class Toolset(object): self.logger.info("Packages to remove:") self.logger.info(self.pkgwork['remove']) if [entry for entry in self.states if not (self.states[entry] or entry.tag == 'Package')]: - self.logger.info("Entries to update:") + self.logger.info("Entries are incorrect:") self.logger.info(["%s: %s" % (entry.tag, entry.get('name')) for entry in self.states if not (self.states[entry] or entry.tag == 'Package')]) @@ -563,6 +563,22 @@ class Toolset(object): self.logger.info("Services to remove:") self.logger.info(self.extra_services) + def PromptUser(self): + '''Prompts user for each entry in interactive mode''' + #get list of entries that need to be updated + #ask user for each entry + work = self.pkgwork['add'] + self.pkgwork['update'] + work += [ent for ent in self.states if ent.tag != 'Package' and not self.states[ent]] + self.iinst = []; + for entry in work: + try: + if raw_input("Would you like to install %s%s? (y/N): " % (entry.tag, entry.get('name'))) in ['y','Y']: + self.iinst.append((entry.tag, entry.get('name'))) + except: + continue + self.logger.info("You chose to install:") + self.logger.info(['%s:%s' % item for item in self.iinst]) + def Install(self): '''Correct detected misconfigurations''' if self.setup['dryrun']: @@ -585,6 +601,9 @@ class Toolset(object): # add non-package entries work += [ent for ent in self.states if ent.tag != 'Package' and not self.states[ent]] + if self.setup['interactive']: + work = [entry for entry in work if (entry.tag, entry.get('name')) in self.iinst] + # Counters ## Packages left to install left = len(work) + len(self.pkgwork['remove']) diff --git a/src/sbin/bcfg2 b/src/sbin/bcfg2 index 909a8360a..e803043c9 100755 --- a/src/sbin/bcfg2 +++ b/src/sbin/bcfg2 @@ -41,6 +41,8 @@ class Client: False, False, False, False), 'file': (('-f', "<configspec>", "configure from a file rather than querying the server"), False, False, False, False), + 'interactive': (('-I', False, "prompt the user for each change"), + False, False, False, True), 'cache': (('-c', "<configspec>", "store the configuration in a file"), False, False, False, False), 'profile': (('-p', '<profile>', "assert the given profile for the host"), @@ -253,6 +255,10 @@ class Client: # summarize current state self.toolset.CondDisplayState('initial') + # run bcfg in interactive mode + if self.setup['interactive']: + self.toolset.PromptUser() + # install incorrect aspects of configuration self.toolset.Install() |