summaryrefslogtreecommitdiffstats
path: root/ipaserver/install
diff options
context:
space:
mode:
Diffstat (limited to 'ipaserver/install')
-rw-r--r--ipaserver/install/dsinstance.py60
-rw-r--r--ipaserver/install/installutils.py49
2 files changed, 69 insertions, 40 deletions
diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py
index 50060832e..7ca5db216 100644
--- a/ipaserver/install/dsinstance.py
+++ b/ipaserver/install/dsinstance.py
@@ -66,42 +66,24 @@ def schema_dirname(serverid):
return config_dirname(serverid) + "/schema/"
def erase_ds_instance_data(serverid):
- try:
- shutil.rmtree("/etc/dirsrv/slapd-%s" % serverid)
- except:
- pass
- try:
- shutil.rmtree("/usr/lib/dirsrv/slapd-%s" % serverid)
- except:
- pass
- try:
- shutil.rmtree("/usr/lib64/dirsrv/slapd-%s" % serverid)
- except:
- pass
- try:
- shutil.rmtree("/var/lib/dirsrv/slapd-%s" % serverid)
- except:
- pass
- try:
- shutil.rmtree("/var/lock/dirsrv/slapd-%s" % serverid)
- except:
- pass
- try:
- os.unlink("/var/run/slapd-%s.socket" % serverid)
- except:
- pass
- try:
- shutil.rmtree("/var/lib/dirsrv/scripts-%s" % serverid)
- except:
- pass
- try:
- os.unlink("/etc/dirsrv/ds.keytab")
- except:
- pass
- try:
- os.unlink("/etc/sysconfig/dirsrv-%s" % serverid)
- except:
- pass
+ installutils.rmtree("/etc/dirsrv/slapd-%s" % serverid)
+
+ installutils.rmtree("/usr/lib/dirsrv/slapd-%s" % serverid)
+
+ installutils.rmtree("/usr/lib64/dirsrv/slapd-%s" % serverid)
+
+ installutils.rmtree("/var/lib/dirsrv/slapd-%s" % serverid)
+
+ installutils.rmtree("/var/lock/dirsrv/slapd-%s" % serverid)
+
+ installutils.remove_file("/var/run/slapd-%s.socket" % serverid)
+
+ installutils.rmtree("/var/lib/dirsrv/scripts-%s" % serverid)
+
+ installutils.remove_file("/etc/dirsrv/ds.keytab")
+
+ installutils.remove_file("/etc/sysconfig/dirsrv-%s" % serverid)
+
# try:
# shutil.rmtree("/var/log/dirsrv/slapd-%s" % serverid)
# except:
@@ -114,6 +96,7 @@ def check_existing_installation():
serverids = []
for d in dirs:
+ logging.debug('Found existing 389-ds instance %s' % d)
serverids.append(os.path.basename(d).split("slapd-", 1)[1])
return serverids
@@ -672,10 +655,7 @@ class DsInstance(service.Service):
if user_exists == False:
pent = pwd.getpwnam(DS_USER)
- try:
- os.unlink("/var/tmp/ldap_%d" % pent.pw_uid)
- except:
- pass
+ installutils.remove_file("/var/tmp/ldap_%d" % pent.pw_uid)
try:
ipautil.run(["/usr/sbin/userdel", DS_USER])
except ipautil.CalledProcessError, e:
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py
index df63b8e8c..d7eb65104 100644
--- a/ipaserver/install/installutils.py
+++ b/ipaserver/install/installutils.py
@@ -30,10 +30,14 @@ import fcntl
import netaddr
import time
import tempfile
+import shutil
from ConfigParser import SafeConfigParser
from ipapython import ipautil, dnsclient, sysrestore
+# Used to determine install status
+IPA_MODULES = ['httpd', 'ipa_kpasswd', 'dirsrv', 'pki-cad', 'pkids', 'install', 'krb5kdc', 'ntpd', 'named']
+
class HostnameLocalhost(Exception):
pass
@@ -508,3 +512,48 @@ def check_server_configuration():
server_fstore = sysrestore.FileStore('/var/lib/ipa/sysrestore')
if not server_fstore.has_files():
raise RuntimeError("IPA is not configured on this system.")
+
+def remove_file(filename):
+ """
+ Remove a file and log any exceptions raised.
+ """
+ try:
+ if os.path.exists(filename):
+ os.unlink(filename)
+ except Exception, e:
+ logging.error('Error removing %s: %s' % (filename, str(e)))
+
+def rmtree(path):
+ """
+ Remove a directory structure and log any exceptions raised.
+ """
+ try:
+ if os.path.exists(path):
+ shutil.rmtree(path)
+ except Exception, e:
+ logging.error('Error removing %s: %s' % (path, str(e)))
+
+def is_ipa_configured():
+ """
+ Using the state and index install files determine if IPA is already
+ configured.
+ """
+ installed = False
+
+ sstore = sysrestore.StateFile('/var/lib/ipa/sysrestore')
+ fstore = sysrestore.FileStore('/var/lib/ipa/sysrestore')
+
+ for module in IPA_MODULES:
+ if sstore.has_state(module):
+ logging.debug('%s is configured' % module)
+ installed = True
+ else:
+ logging.debug('%s is not configured' % module)
+
+ if fstore.has_files():
+ logging.debug('filestore has files')
+ installed = True
+ else:
+ logging.debug('filestore is tracking no files')
+
+ return installed