>From 31131aa9050b9344cc7e51f9dab2049666ccd83e Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata@redhat.com>
Date: Tue, 26 Apr 2016 22:32:41 +0200
Subject: [PATCH] Removed unused variables in deployment scriptlets.

The unused rv instance variables in all deployment scriptlets have
been removed. The spawn() and destroy() are now returning None
instead of error code. If an error happens during execution the
scriptlet will throw an exception which will be caught by pkispawn
or pkidestroy and then displayed to the user.
---
 .../server/deployment/scriptlets/configuration.py  |  9 ++---
 .../server/deployment/scriptlets/finalization.py   |  3 --
 .../deployment/scriptlets/infrastructure_layout.py |  6 +--
 .../server/deployment/scriptlets/initialization.py |  6 +--
 .../deployment/scriptlets/instance_layout.py       |  6 +--
 .../deployment/scriptlets/security_databases.py    |  5 +--
 .../server/deployment/scriptlets/selinux_setup.py  | 18 ++++-----
 .../deployment/scriptlets/slot_substitution.py     |  6 +--
 .../deployment/scriptlets/subsystem_layout.py      |  6 +--
 .../deployment/scriptlets/webapp_deployment.py     |  7 +---
 base/server/sbin/pkidestroy                        | 43 +++++++++++++++++-----
 base/server/sbin/pkispawn                          | 39 ++++++++++----------
 12 files changed, 76 insertions(+), 78 deletions(-)

diff --git a/base/server/python/pki/server/deployment/scriptlets/configuration.py b/base/server/python/pki/server/deployment/scriptlets/configuration.py
index 5f77ac52379be0ca08b1a5dff9f71626c731bd3f..9be9a92f02503fcac0e4e0e3eb9ddd582ba847a3 100644
--- a/base/server/python/pki/server/deployment/scriptlets/configuration.py
+++ b/base/server/python/pki/server/deployment/scriptlets/configuration.py
@@ -36,7 +36,6 @@ import pki.util
 
 # PKI Deployment Configuration Scriptlet
 class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
-    rv = 0
 
     def spawn(self, deployer):
 
@@ -49,7 +48,8 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
         if config.str2bool(deployer.mdict['pki_skip_configuration']):
             config.pki_log.info(log.SKIP_CONFIGURATION_SPAWN_1, __name__,
                                 extra=config.PKI_INDENTATION_LEVEL_1)
-            return self.rv
+            return
+
         config.pki_log.info(log.CONFIGURATION_SPAWN_1, __name__,
                             extra=config.PKI_INDENTATION_LEVEL_1)
 
@@ -234,7 +234,7 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
             nssdb.close()
 
         if external and step_one:
-            return self.rv
+            return
 
         if len(deployer.instance.tomcat_instance_subsystems()) < 2:
 
@@ -326,8 +326,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
         deployer.config_client.configure_pki_data(
             json.dumps(data, cls=pki.encoder.CustomTypeEncoder))
 
-        return self.rv
-
     def destroy(self, deployer):
 
         config.pki_log.info(log.CONFIGURATION_DESTROY_1, __name__,
@@ -336,4 +334,3 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
             if deployer.directory.exists(deployer.mdict['pki_client_dir']):
                 deployer.directory.delete(deployer.mdict['pki_client_dir'])
             deployer.symlink.delete(deployer.mdict['pki_systemd_service_link'])
-        return self.rv
diff --git a/base/server/python/pki/server/deployment/scriptlets/finalization.py b/base/server/python/pki/server/deployment/scriptlets/finalization.py
index c816acd2025fdaff3296bcf978c4df315bea2230..8f8cfe0ac6e91c5332f28ffd8ccbc2a0ad8b056a 100644
--- a/base/server/python/pki/server/deployment/scriptlets/finalization.py
+++ b/base/server/python/pki/server/deployment/scriptlets/finalization.py
@@ -29,7 +29,6 @@ from .. import pkiscriptlet
 
 # PKI Deployment Finalization Scriptlet
 class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
-    rv = 0
 
     def spawn(self, deployer):
 
@@ -93,7 +92,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
                             deployer.mdict['pki_instance_name'],
                             extra=config.PKI_INDENTATION_LEVEL_0)
         deployer.file.modify(deployer.mdict['pki_spawn_log'], silent=True)
-        return self.rv
 
     def destroy(self, deployer):
 
@@ -112,4 +110,3 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
                             deployer.mdict['pki_subsystem'],
                             deployer.mdict['pki_instance_name'],
                             extra=config.PKI_INDENTATION_LEVEL_0)
-        return self.rv
diff --git a/base/server/python/pki/server/deployment/scriptlets/infrastructure_layout.py b/base/server/python/pki/server/deployment/scriptlets/infrastructure_layout.py
index 1334cb03c3233a46168980e4844fbc28d936ec2f..a04ec158bc684661586aa9fc9cdb56ab8bf468f6 100644
--- a/base/server/python/pki/server/deployment/scriptlets/infrastructure_layout.py
+++ b/base/server/python/pki/server/deployment/scriptlets/infrastructure_layout.py
@@ -29,14 +29,14 @@ from .. import pkiscriptlet
 
 # PKI Deployment Top-Level Infrastructure Layout Scriptlet
 class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
-    rv = 0
 
     def spawn(self, deployer):
 
         if config.str2bool(deployer.mdict['pki_skip_installation']):
             config.pki_log.info(log.SKIP_ADMIN_DOMAIN_SPAWN_1, __name__,
                                 extra=config.PKI_INDENTATION_LEVEL_1)
-            return self.rv
+            return
+
         config.pki_log.info(log.ADMIN_DOMAIN_SPAWN_1, __name__,
                             extra=config.PKI_INDENTATION_LEVEL_1)
         # NOTE:  It was determined that since the "pkidestroy" command
@@ -100,7 +100,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
         if deployer.mdict['pki_configuration_path'] != \
            config.PKI_DEPLOYMENT_CONFIGURATION_ROOT:
             deployer.directory.create(deployer.mdict['pki_configuration_path'])
-        return self.rv
 
     def destroy(self, deployer):
 
@@ -125,4 +124,3 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
                     deployer.mdict['pki_configuration_path'])
             # remove top-level infrastructure registry
             deployer.directory.delete(deployer.mdict['pki_registry_path'])
-        return self.rv
diff --git a/base/server/python/pki/server/deployment/scriptlets/initialization.py b/base/server/python/pki/server/deployment/scriptlets/initialization.py
index 634136caf6426667f8f6b0547e9ef5d874ce4f61..0e315431fbeeba5c7db31246029333339c0ac50e 100644
--- a/base/server/python/pki/server/deployment/scriptlets/initialization.py
+++ b/base/server/python/pki/server/deployment/scriptlets/initialization.py
@@ -28,7 +28,6 @@ from .. import pkiscriptlet
 
 # PKI Deployment Initialization Scriptlet
 class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
-    rv = 0
 
     def spawn(self, deployer):
 
@@ -48,7 +47,8 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
         if config.str2bool(deployer.mdict['pki_skip_installation']):
             config.pki_log.info(log.SKIP_INITIALIZATION_SPAWN_1, __name__,
                                 extra=config.PKI_INDENTATION_LEVEL_1)
-            return self.rv
+            return
+
         else:
             config.pki_log.info(log.INITIALIZATION_SPAWN_1, __name__,
                                 extra=config.PKI_INDENTATION_LEVEL_1)
@@ -76,7 +76,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
         deployer.configuration_file.verify_selinux_ports()
         # If secure DS connection is required, verify parameters
         deployer.configuration_file.verify_ds_secure_connection_data()
-        return self.rv
 
     def destroy(self, deployer):
 
@@ -121,4 +120,3 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
         deployer.security_domain.deregister(None)
         # ALWAYS Stop this Tomcat PKI Process
         deployer.systemd.stop()
-        return self.rv
diff --git a/base/server/python/pki/server/deployment/scriptlets/instance_layout.py b/base/server/python/pki/server/deployment/scriptlets/instance_layout.py
index eeca2bc0f9217988f9dcd74179ea1ba7498a4019..2af86bfeb246cf10d297af8ca8d8b8391c55f15a 100644
--- a/base/server/python/pki/server/deployment/scriptlets/instance_layout.py
+++ b/base/server/python/pki/server/deployment/scriptlets/instance_layout.py
@@ -30,14 +30,13 @@ from .. import pkiscriptlet
 
 # PKI Deployment Instance Layout Scriptlet
 class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
-    rv = 0
 
     def spawn(self, deployer):
 
         if config.str2bool(deployer.mdict['pki_skip_installation']):
             config.pki_log.info(log.SKIP_INSTANCE_SPAWN_1, __name__,
                                 extra=config.PKI_INDENTATION_LEVEL_1)
-            return self.rv
+            return
 
         config.pki_log.info(log.INSTANCE_SPAWN_1, __name__,
                             extra=config.PKI_INDENTATION_LEVEL_1)
@@ -293,7 +292,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
                     deployer.symlink.create(
                         deployer.mdict['pki_symkey_jar'],
                         deployer.mdict['pki_symkey_jar_link'])
-        return self.rv
 
     def destroy(self, deployer):
 
@@ -321,8 +319,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
                 deployer.directory.delete(
                     deployer.mdict['pki_instance_type_registry_path'])
 
-        return self.rv
-
 
 # Callback only when the /usr/share/pki/server/conf directory
 # Is getting copied to the etc tree.
diff --git a/base/server/python/pki/server/deployment/scriptlets/security_databases.py b/base/server/python/pki/server/deployment/scriptlets/security_databases.py
index ed8c0ce0981f2d4c09b9cabebaeabf4bfd348d2f..c3ae890907ecbb18c51cf0340543691c16d32fe4 100644
--- a/base/server/python/pki/server/deployment/scriptlets/security_databases.py
+++ b/base/server/python/pki/server/deployment/scriptlets/security_databases.py
@@ -32,14 +32,13 @@ from .. import pkiscriptlet
 
 # PKI Deployment Security Databases Scriptlet
 class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
-    rv = 0
 
     def spawn(self, deployer):
 
         if config.str2bool(deployer.mdict['pki_skip_installation']):
             config.pki_log.info(log.SKIP_SECURITY_DATABASES_SPAWN_1, __name__,
                                 extra=config.PKI_INDENTATION_LEVEL_1)
-            return self.rv
+            return
 
         config.pki_log.info(log.SECURITY_DATABASES_SPAWN_1, __name__,
                             extra=config.PKI_INDENTATION_LEVEL_1)
@@ -158,7 +157,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
 
         # Always delete the temporary 'pfile'
         deployer.file.delete(deployer.mdict['pki_shared_pfile'])
-        return self.rv
 
     def update_external_certs_conf(self, external_path, deployer):
         external_certs = pki.server.PKIInstance.read_external_certs(
@@ -182,4 +180,3 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
             deployer.file.delete(deployer.mdict['pki_key_database'])
             deployer.file.delete(deployer.mdict['pki_secmod_database'])
             deployer.file.delete(deployer.mdict['pki_shared_password_conf'])
-        return self.rv
diff --git a/base/server/python/pki/server/deployment/scriptlets/selinux_setup.py b/base/server/python/pki/server/deployment/scriptlets/selinux_setup.py
index c559370a577d5cc473e3b9a85cbe70e4c8e75c9f..9c926d18ff5d59d3bc2e65f4115836e45c981b7c 100644
--- a/base/server/python/pki/server/deployment/scriptlets/selinux_setup.py
+++ b/base/server/python/pki/server/deployment/scriptlets/selinux_setup.py
@@ -42,7 +42,7 @@ if selinux.is_selinux_enabled():
 
 # PKI Deployment Selinux Setup Scriptlet
 class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
-    rv = 0
+
     suffix = "(/.*)?"
 
     def restore_context(self, mdict):
@@ -56,12 +56,12 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
         if config.str2bool(deployer.mdict['pki_skip_installation']):
             config.pki_log.info(log.SKIP_SELINUX_SPAWN_1, __name__,
                                 extra=config.PKI_INDENTATION_LEVEL_1)
-            return self.rv
+            return
 
         if not selinux.is_selinux_enabled() or seobject is None:
             config.pki_log.info(log.SELINUX_DISABLED_SPAWN_1, __name__,
                                 extra=config.PKI_INDENTATION_LEVEL_1)
-            return self.rv
+            return
 
         config.pki_log.info(log.SELINUX_SPAWN_1, __name__,
                             extra=config.PKI_INDENTATION_LEVEL_1)
@@ -74,7 +74,7 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
                 if len(ports) == 0 and deployer.mdict['pki_instance_name'] == \
                         config.PKI_DEPLOYMENT_DEFAULT_TOMCAT_INSTANCE_NAME:
                     self.restore_context(deployer.mdict)
-                    return self.rv
+                    return
 
                 # add SELinux contexts when adding the first subsystem
                 if len(deployer.instance.tomcat_instance_subsystems()) == 1:
@@ -148,21 +148,21 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
                 else:
                     raise
 
-        return self.rv
-
     def destroy(self, deployer):
 
         if not bool(selinux.is_selinux_enabled()):
             config.pki_log.info(log.SELINUX_DISABLED_DESTROY_1, __name__,
                                 extra=config.PKI_INDENTATION_LEVEL_1)
-            return self.rv
+            return
+
         config.pki_log.info(log.SELINUX_DESTROY_1, __name__,
                             extra=config.PKI_INDENTATION_LEVEL_1)
 
         # check first if any transactions are required
         if (len(ports) == 0 and deployer.mdict['pki_instance_name'] ==
                 config.PKI_DEPLOYMENT_DEFAULT_TOMCAT_INSTANCE_NAME):
-            return self.rv
+            return
+
         # A maximum of 10 tries to delete the SELinux contexts
         counter = 1
         max_tries = 10
@@ -234,5 +234,3 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
                         "Retrying to remove selinux context ...")
                 else:
                     raise
-
-        return self.rv
diff --git a/base/server/python/pki/server/deployment/scriptlets/slot_substitution.py b/base/server/python/pki/server/deployment/scriptlets/slot_substitution.py
index bdee48c1f92b336a9b3a7e4337b0d8f4b2a62832..5a56f6cbbd89b7cdc9316da045a59b5195a35825 100644
--- a/base/server/python/pki/server/deployment/scriptlets/slot_substitution.py
+++ b/base/server/python/pki/server/deployment/scriptlets/slot_substitution.py
@@ -28,14 +28,14 @@ from .. import pkiscriptlet
 
 # PKI Deployment Slot Substitution Scriptlet
 class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
-    rv = 0
 
     def spawn(self, deployer):
 
         if config.str2bool(deployer.mdict['pki_skip_installation']):
             config.pki_log.info(log.SKIP_SLOT_ASSIGNMENT_SPAWN_1, __name__,
                                 extra=config.PKI_INDENTATION_LEVEL_1)
-            return self.rv
+            return
+
         config.pki_log.info(log.SLOT_ASSIGNMENT_SPAWN_1, __name__,
                             extra=config.PKI_INDENTATION_LEVEL_1)
         deployer.file.copy_with_slot_substitution(
@@ -84,11 +84,9 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
             deployer.file.copy_with_slot_substitution(
                 deployer.mdict['pki_source_phone_home_xml'],
                 deployer.mdict['pki_target_phone_home_xml'])
-        return self.rv
 
     def destroy(self, deployer):
         config.pki_log.info(log.SLOT_ASSIGNMENT_DESTROY_1, __name__,
                             extra=config.PKI_INDENTATION_LEVEL_1)
         config.pki_log.info("NOTHING NEEDS TO BE IMPLEMENTED",
                             extra=config.PKI_INDENTATION_LEVEL_2)
-        return self.rv
diff --git a/base/server/python/pki/server/deployment/scriptlets/subsystem_layout.py b/base/server/python/pki/server/deployment/scriptlets/subsystem_layout.py
index 49899da6838126415657b93a763669575d1ba78e..2b2246a728c97514c4394bdc06fea23e6f76f692 100644
--- a/base/server/python/pki/server/deployment/scriptlets/subsystem_layout.py
+++ b/base/server/python/pki/server/deployment/scriptlets/subsystem_layout.py
@@ -28,14 +28,14 @@ from .. import pkiscriptlet
 
 # PKI Deployment Subsystem Layout Scriptlet
 class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
-    rv = 0
 
     def spawn(self, deployer):
 
         if config.str2bool(deployer.mdict['pki_skip_installation']):
             config.pki_log.info(log.SKIP_SUBSYSTEM_SPAWN_1, __name__,
                                 extra=config.PKI_INDENTATION_LEVEL_1)
-            return self.rv
+            return
+
         config.pki_log.info(log.SUBSYSTEM_SPAWN_1, __name__,
                             extra=config.PKI_INDENTATION_LEVEL_1)
         # establish instance-based subsystem logs
@@ -118,7 +118,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
         deployer.symlink.create(
             deployer.mdict['pki_instance_registry_path'],
             deployer.mdict['pki_subsystem_registry_link'])
-        return self.rv
 
     def destroy(self, deployer):
 
@@ -146,4 +145,3 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
         # remove instance-based subsystem registry
         deployer.directory.delete(
             deployer.mdict['pki_subsystem_registry_path'])
-        return self.rv
diff --git a/base/server/python/pki/server/deployment/scriptlets/webapp_deployment.py b/base/server/python/pki/server/deployment/scriptlets/webapp_deployment.py
index f9d0ae9b64165de6a9caabe40981a555520ad4fc..bfa3c32c152a4a001414410ee5939f175f641ca9 100644
--- a/base/server/python/pki/server/deployment/scriptlets/webapp_deployment.py
+++ b/base/server/python/pki/server/deployment/scriptlets/webapp_deployment.py
@@ -30,14 +30,13 @@ from .. import pkiscriptlet
 
 # PKI Web Application Deployment Scriptlet
 class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
-    rv = 0
 
     def spawn(self, deployer):
         if config.str2bool(deployer.mdict['pki_skip_installation']):
             config.pki_log.info(log.SKIP_WEBAPP_DEPLOYMENT_SPAWN_1,
                                 __name__,
                                 extra=config.PKI_INDENTATION_LEVEL_1)
-            return self.rv
+            return
 
         config.pki_log.info(log.WEBAPP_DEPLOYMENT_SPAWN_1, __name__,
                             extra=config.PKI_INDENTATION_LEVEL_1)
@@ -67,8 +66,6 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
                 "localhost",
                 deployer.mdict['pki_subsystem'].lower() + ".xml"))
 
-        return self.rv
-
     def destroy(self, deployer):
         config.pki_log.info(log.WEBAPP_DEPLOYMENT_DESTROY_1, __name__,
                             extra=config.PKI_INDENTATION_LEVEL_1)
@@ -80,5 +77,3 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
                 "Catalina",
                 "localhost",
                 deployer.mdict['pki_subsystem'].lower() + ".xml"))
-
-        return self.rv
diff --git a/base/server/sbin/pkidestroy b/base/server/sbin/pkidestroy
index d7285c7e50e1f3f4e50fd30077eb385fd831f415..404298ba9413135a7107c3777120b2dc7a1169b9 100755
--- a/base/server/sbin/pkidestroy
+++ b/base/server/sbin/pkidestroy
@@ -35,6 +35,7 @@ try:
     import struct
     import subprocess
     import time
+    import traceback
     from time import strftime as date
     from pki.server.deployment import pkiconfig as config
     from pki.server.deployment.pkiparser import PKIConfigParser
@@ -256,15 +257,26 @@ def main(argv):
     # Process the various "scriptlets" to remove the specified PKI subsystem.
     pki_subsystem_scriptlets = parser.mdict['destroy_scriplets'].split()
     deployer = util.PKIDeployer(parser.mdict)
-    rv = 0
-    for scriptlet_name in pki_subsystem_scriptlets:
-        scriptlet_module = __import__(
-            "pki.server.deployment.scriptlets." + scriptlet_name,
-            fromlist=[scriptlet_name])
-        scriptlet = scriptlet_module.PkiScriptlet()
-        rv = scriptlet.destroy(deployer)
-        if rv != 0:
-            sys.exit(1)
+
+    try:
+        for scriptlet_name in pki_subsystem_scriptlets:
+
+            scriptlet_module = __import__(
+                "pki.server.deployment.scriptlets." + scriptlet_name,
+                fromlist=[scriptlet_name])
+
+            scriptlet = scriptlet_module.PkiScriptlet()
+
+            scriptlet.destroy(deployer)
+
+    # pylint: disable=W0703
+    except Exception as e:
+        log_error_details()
+        print()
+        print("Uninstallation failed: %s" % e)
+        print()
+        sys.exit(1)
+
     config.pki_log.debug(log.PKI_DICTIONARY_MASTER,
                          extra=config.PKI_INDENTATION_LEVEL_0)
     config.pki_log.debug(pkilogging.log_format(parser.mdict),
@@ -274,6 +286,19 @@ def main(argv):
     print("Uninstallation complete.")
 
 
+def log_error_details():
+    e_type, e_value, e_stacktrace = sys.exc_info()
+    config.pki_log.debug(
+        "Error Type: " + e_type.__name__, extra=config.PKI_INDENTATION_LEVEL_2)
+    config.pki_log.debug(
+        "Error Message: " + str(e_value), extra=config.PKI_INDENTATION_LEVEL_2)
+    stacktrace_list = traceback.format_list(traceback.extract_tb(e_stacktrace))
+    e_stacktrace = ""
+    for l in stacktrace_list:
+        e_stacktrace += l
+    config.pki_log.debug(e_stacktrace, extra=config.PKI_INDENTATION_LEVEL_2)
+    del e_type, e_value, e_stacktrace
+
 # PKI Deployment Entry Point
 if __name__ == "__main__":
     signal.signal(signal.SIGINT, interrupt_handler)
diff --git a/base/server/sbin/pkispawn b/base/server/sbin/pkispawn
index caa5e9bee474cbb8aa76701f83cc53dab308fc44..21333e72275264535ad9fd3fd0e7b34dc2e3b8e9 100755
--- a/base/server/sbin/pkispawn
+++ b/base/server/sbin/pkispawn
@@ -514,25 +514,26 @@ def main(argv):
     # Process the various "scriptlets" to create the specified PKI subsystem.
     pki_subsystem_scriptlets = parser.mdict['spawn_scriplets'].split()
     deployer = util.PKIDeployer(parser.mdict, parser.slots_dict)
-    rv = 0
-    for scriptlet_name in pki_subsystem_scriptlets:
-        scriptlet_module = __import__(
-            "pki.server.deployment.scriptlets." + scriptlet_name,
-            fromlist=[scriptlet_name])
-        scriptlet = scriptlet_module.PkiScriptlet()
-        try:
-            rv = scriptlet.spawn(deployer)
-        # pylint: disable=W0703
-        except Exception:
-            log_error_details()
-            print()
-            print("Installation failed.")
-            print()
-            sys.exit(1)
-        if rv != 0:
-            print("Nothing here!!!")
-            print("Installation failed.")
-            sys.exit(1)
+
+    try:
+        for scriptlet_name in pki_subsystem_scriptlets:
+
+            scriptlet_module = __import__(
+                "pki.server.deployment.scriptlets." + scriptlet_name,
+                fromlist=[scriptlet_name])
+
+            scriptlet = scriptlet_module.PkiScriptlet()
+
+            scriptlet.spawn(deployer)
+
+    # pylint: disable=W0703
+    except Exception as e:
+        log_error_details()
+        print()
+        print("Installation failed: %s" % e)
+        print()
+        sys.exit(1)
+
     config.pki_log.debug(log.PKI_DICTIONARY_MASTER,
                          extra=config.PKI_INDENTATION_LEVEL_0)
     config.pki_log.debug(pkilogging.log_format(parser.mdict),
-- 
2.5.5

