summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2009-09-02 17:59:36 -0400
committerRob Crittenden <rcritten@redhat.com>2009-09-04 14:32:53 -0400
commite19a8d0259b3b0670cf7f4272d4be4d7eb7b4e49 (patch)
tree2c654027610c383513dbb036df50222f08347c60
parent70820dc343f96a1abd570b99e036101429f3262c (diff)
downloadfreeipa-e19a8d0259b3b0670cf7f4272d4be4d7eb7b4e49.tar.gz
freeipa-e19a8d0259b3b0670cf7f4272d4be4d7eb7b4e49.tar.xz
freeipa-e19a8d0259b3b0670cf7f4272d4be4d7eb7b4e49.zip
Better upgrade detection so we don't print spurious errors
Also add copyright 519414
-rw-r--r--ipa-server/ipa-upgradeconfig55
1 files changed, 40 insertions, 15 deletions
diff --git a/ipa-server/ipa-upgradeconfig b/ipa-server/ipa-upgradeconfig
index 48c4117d..837f42a9 100644
--- a/ipa-server/ipa-upgradeconfig
+++ b/ipa-server/ipa-upgradeconfig
@@ -1,6 +1,27 @@
#!/usr/bin/python
#
-# Upgrade configuration files to a newer template.
+# Authors:
+# Rob Crittenden <rcritten@redhat.com>
+#
+# Copyright (C) 2009 Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; version 2 only
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+"""
+Upgrade configuration files to a newer template.
+"""
import sys
try:
@@ -42,6 +63,10 @@ def update_conf(sub_dict, filename, template_filename):
def find_hostname():
"""Find the hostname currently configured in ipa-rewrite.conf"""
filename="/etc/httpd/conf.d/ipa-rewrite.conf"
+
+ if not ipautil.file_exists(filename):
+ return None
+
pattern = "^[\s#]*.*https:\/\/([A-Za-z0-9\.\-]*)\/.*"
p = re.compile(pattern)
for line in fileinput.input(filename):
@@ -50,7 +75,7 @@ def find_hostname():
return p.search(line).group(1)
fileinput.close()
- return None
+ raise RuntimeError("Unable to determine the fully qualified hostname from %s" % filename)
def find_version(filename):
"""Find the version of a configuration file"""
@@ -95,26 +120,26 @@ def check_certs(realm_name):
print "You should place a copy of the CA certificate in /usr/share/ipa/html/ca.crt"
def main():
+ """
+ Get some basics about the system. If getting those basics fail then
+ this is likely because the machine isn't currently an IPA server so
+ exit gracefully.
+ """
+
try:
krbctx = krbV.default_context()
except krbV.Krb5Error, e:
- print "Unable to get default kerberos realm: %s" % e[1]
- sys.exit(1)
-
- try:
- check_certs(krbctx.default_realm)
- except Error, e:
- print "Failed to check CA certificate: %s" % e
+ # Unable to get default kerberos realm
+ sys.exit(0)
- try:
- fqdn = find_hostname()
- except IOError:
+ fqdn = find_hostname()
+ if fqdn is None:
# ipa-rewrite.conf doesn't exist, nothing to do
sys.exit(0)
- if fqdn is None:
- print "Unable to determine hostname from ipa-rewrite.conf"
- sys.exit(1)
+ # Ok, we are an IPA server, do the additional tests
+
+ check_certs(krbctx.default_realm)
sub_dict = { "REALM" : krbctx.default_realm, "FQDN": fqdn }