Add action statement to ldap.conf update

Move imports into try/except so that ctrl-C can always be caught
Fix typo
This commit is contained in:
Rob Crittenden 2008-02-27 16:17:38 -05:00
parent 999bd4fb1e
commit 6533bc1a84

View File

@ -21,17 +21,6 @@
VERSION = "%prog .1" VERSION = "%prog .1"
import sys
import krbV
import socket
import logging
from optparse import OptionParser
import ipaclient.ipadiscovery
import ipaclient.ipachangeconf
import ipaclient.ntpconf
from ipa.ipautil import run
def parse_options(): def parse_options():
parser = OptionParser(version=VERSION) parser = OptionParser(version=VERSION)
parser.add_option("--domain", dest="domain", help="domain name") parser.add_option("--domain", dest="domain", help="domain name")
@ -184,7 +173,7 @@ def main():
ldapconf.newConf("/etc/ldap.conf", opts) ldapconf.newConf("/etc/ldap.conf", opts)
print "Configured /etc/ldap.conf" print "Configured /etc/ldap.conf"
except Exception, e: except Exception, e:
print "Configuration failed: " + str(e) print "Creation of /etc/ldap.conf: " + str(e)
return 1 return 1
#Check if kerberos is already configured properly #Check if kerberos is already configured properly
@ -254,15 +243,15 @@ def main():
try: try:
run(["getent", "passwd", "admin"]) run(["getent", "passwd", "admin"])
except Exception, e: except Exception, e:
print "nss_ldap is not able to use DNS disccovery!" print "nss_ldap is not able to use DNS discovery!"
print "Changing configuration to use hardcoded server name: " + ds.getServerName() print "Changing configuration to use hardcoded server name: " + ds.getServerName()
opts = [{'name':'uri', 'type':'option', 'value':'ldap://'+ds.getServerName()}, opts = [{'name':'uri', 'type':'option', 'action':'set', 'value':'ldap://'+ds.getServerName()},
{'name':'empty', 'type':'empty'}] {'name':'empty', 'type':'empty'}]
try: try:
ldapconf.changeConf("/etc/ldap.conf", opts) ldapconf.changeConf("/etc/ldap.conf", opts)
except Exception, e: except Exception, e:
print "Configuration failed: " + str(e) print "Adding hardcoded server name to /etc/ldap.conf failed: " + str(e)
return 1 return 1
#Modify pam to add pam_krb5 #Modify pam to add pam_krb5
@ -278,6 +267,17 @@ def main():
return 0 return 0
try: try:
import sys
import krbV
import socket
import logging
from optparse import OptionParser
import ipaclient.ipadiscovery
import ipaclient.ipachangeconf
import ipaclient.ntpconf
from ipa.ipautil import run
sys.exit(main()) sys.exit(main())
except KeyboardInterrupt: except KeyboardInterrupt:
sys.exit(1) sys.exit(1)