From b57d1419321026e219f309553e8492bd53fa6d4a Mon Sep 17 00:00:00 2001
From: Matthew Harmsen <mharmsen@redhat.com>
Date: Fri, 17 Jul 2015 09:27:31 -0600
Subject: [PATCH] Removed extraneous tomcat argument from pkidaemon

---
 .../cms/servlet/csadmin/SecurityDomainPanel.java   |  4 +-
 base/server/man/man8/pkispawn.8                    |  4 +-
 base/server/scripts/operations                     | 75 +++-------------------
 base/server/scripts/pkidaemon                      | 17 ++---
 .../systemd/system/pki-tomcatd-nuxwdog@.service    |  2 +-
 .../share/lib/systemd/system/pki-tomcatd@.service  |  2 +-
 6 files changed, 20 insertions(+), 84 deletions(-)

diff --git a/base/server/cms/src/com/netscape/cms/servlet/csadmin/SecurityDomainPanel.java b/base/server/cms/src/com/netscape/cms/servlet/csadmin/SecurityDomainPanel.java
index 3bc8169..70d550f 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/csadmin/SecurityDomainPanel.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/csadmin/SecurityDomainPanel.java
@@ -214,7 +214,7 @@ public class SecurityDomainPanel extends WizardPanelBase {
         if (os.equalsIgnoreCase("Linux")) {
             if (!systemdInstanceId.equals("")) {
                 context.put("initCommand", "/usr/bin/pkidaemon");
-                context.put("instanceId", "tomcat " + systemdInstanceId);
+                context.put("instanceId", systemdInstanceId);
             } else {
                 context.put("initCommand", "/sbin/service " + initDaemon);
                 context.put("instanceId", instanceId);
@@ -465,7 +465,7 @@ public class SecurityDomainPanel extends WizardPanelBase {
         if (os.equalsIgnoreCase("Linux")) {
             if (!systemdInstanceId.equals("")) {
                 context.put("initCommand", "/usr/bin/pkidaemon");
-                context.put("instanceId", "tomcat " + systemdInstanceId);
+                context.put("instanceId", systemdInstanceId);
             } else {
                 context.put("initCommand", "/sbin/service " + initDaemon);
                 context.put("instanceId", instanceId);
diff --git a/base/server/man/man8/pkispawn.8 b/base/server/man/man8/pkispawn.8
index c2ab93e..565b953 100644
--- a/base/server/man/man8/pkispawn.8
+++ b/base/server/man/man8/pkispawn.8
@@ -790,13 +790,13 @@ To obtain the status of a PKI instance named <pki_instance_name>:
 To obtain a detailed status of a Tomcat PKI instance named <pki_instance_name>:
 .IP
 .nf
-\fBpkidaemon status tomcat <pki_instance_name>\fR
+\fBpkidaemon status <pki_instance_name>\fR
 .fi
 .PP
 To obtain a detailed status of all Tomcat PKI instances:
 .IP
 .nf
-\fBpkidaemon status tomcat\fR
+\fBpkidaemon status\fR
 .fi
 
 .SH BUGS
diff --git a/base/server/scripts/operations b/base/server/scripts/operations
index ede5f82..87a417b 100644
--- a/base/server/scripts/operations
+++ b/base/server/scripts/operations
@@ -87,22 +87,12 @@ PKI_OCSP_PATH="/usr/share/pki/ocsp"
 PKI_RA_PATH="/usr/share/pki/ra"
 PKI_TKS_PATH="/usr/share/pki/tks"
 PKI_TPS_PATH="/usr/share/pki/tps"
-if [ '${PKI_TYPE}' == "apache" ] ; then
-    if [ ! -d ${PKI_RA_PATH} ]  &&
-       [ ! -d ${PKI_TPS_PATH} ] ; then
-        echo "This machine is missing all PKI '${PKI_TYPE}' subsystems!"
-        if [ "${command}" != "status" ]; then
-            # 5 program is not installed
-            exit 5
-        else
-            exit ${default_error}
-        fi
-    fi
-elif [ '${PKI_TYPE}' == "tomcat" ] ; then
+if [ '${PKI_TYPE}' == "tomcat" ] ; then
     if [ ! -d ${PKI_CA_PATH} ]   &&
        [ ! -d ${PKI_KRA_PATH} ]  &&
        [ ! -d ${PKI_OCSP_PATH} ] &&
-       [ ! -d ${PKI_TKS_PATH} ] ; then
+       [ ! -d ${PKI_TKS_PATH} ]  &&
+       [ ! -d ${PKI_TPS_PATH} ] ; then
         echo "This machine is missing all PKI '${PKI_TYPE}' subsystems!"
         if [ "${command}" != "status" ]; then
             # 5 program is not installed
@@ -113,7 +103,6 @@ elif [ '${PKI_TYPE}' == "tomcat" ] ; then
     fi
 fi
 
-PKI_INSTANCE_TYPES="apache tomcat"
 PKI_REGISTRY_ENTRIES=""
 PKI_SUBSYSTEMS=""
 TOTAL_PKI_REGISTRY_ENTRIES=0
@@ -150,30 +139,14 @@ usage()
         echo -n "|stop|restart"
     fi
     echo -n "|status} "
-    echo -n "instance-type "
     echo -n "[instance-name]"
     echo
     echo
 }
 
-list_instance_types()
-{
-    echo
-    for PKI_INSTANCE_TYPE in $PKI_INSTANCE_TYPES; do
-        echo "    $PKI_INSTANCE_TYPE"
-    done
-    echo
-}
-
 list_instances()
 {
     echo
-    for INSTANCE in /etc/sysconfig/pki/apache/*; do
-        if [ -d "${INSTANCE}" ] ; then
-            instance_name=`basename ${INSTANCE}`
-            echo "    $instance_name"
-        fi
-    done
     for INSTANCE in /etc/sysconfig/pki/tomcat/*; do
         if [ -d "${INSTANCE}" ] ; then
             instance_name=`basename ${INSTANCE}`
@@ -199,17 +172,6 @@ get_subsystems()
                 fi
             done
             ;;
-        apache)
-            for SUBSYSTEM in ra; do
-                if [ -d ${PKI_INSTANCE_PATH}/conf/${SUBSYSTEM} ]; then
-                    if [ '${PKI_SUBSYSTEMS}' == "" ] ; then
-                        PKI_SUBSYSTEMS="${SUBSYSTEM}"
-                    else
-                        PKI_SUBSYSTEMS="${PKI_SUBSYSTEMS} ${SUBSYSTEM}"
-                    fi
-                fi
-            done
-            ;;
         *)
             echo "Unknown web server type ($PKI_WEB_SERVER_TYPE)"
             exit ${default_error}
@@ -218,14 +180,12 @@ get_subsystems()
 }
 
 # Check arguments
-if [ $# -lt 2 ] ; then
+if [ $# -lt 1 ] ; then
     #     [insufficient arguments]
     echo "$PROG_NAME:  Insufficient arguments!"
     echo
     usage
-    echo "where valid instance types include:"
-    list_instance_types
-    echo "and where valid instance names include:"
+    echo "where valid instance names include:"
     list_instances
     exit 3
 elif [ ${default_error} -eq 2 ] ; then
@@ -233,18 +193,14 @@ elif [ ${default_error} -eq 2 ] ; then
     echo "$PROG_NAME:  Invalid arguments!"
     echo
     usage
-    echo "where valid instance types include:"
-    list_instance_types
-    echo "and where valid instance names include:"
+    echo "where valid instance names include:"
     list_instances
     exit 2
-elif [ $# -gt 3 ] ; then
+elif [ $# -gt 2 ] ; then
     echo "$PROG_NAME:  Excess arguments!"
     echo
     usage
-    echo "where valid instance types include:"
-    list_instance_types
-    echo "and where valid instance names include:"
+    echo "where valid instance names include:"
     list_instances
     if [ "${command}" != "status" ]; then
         # 2 excess arguments
@@ -266,14 +222,6 @@ if [ -n "${pki_instance_id}" ]; then
         fi
     done
     if [ $valid -eq 0 ]; then
-        if [ "${pki_instance_type}" != "apache" ] &&
-           [ "${pki_instance_type}" != "tomcat" ]; then
-            echo -n "unknown instance type (${pki_instance_type})"
-        else
-            echo -n "${pki_instance_id} is an invalid '${PKI_TYPE}' instance"
-        fi
-        echo
-
         if [ "${command}" != "status" ]; then
             # 5 program is not installed
             exit 5
@@ -296,9 +244,6 @@ check_pki_configuration_status()
                 fi
             done
             ;;
-        apache)
-            # TBD
-            ;;
         *)
             echo "Unknown web server type ($PKI_WEB_SERVER_TYPE)"
             exit ${default_error}
@@ -1996,10 +1941,6 @@ registry_status()
                     rv=$?
                 fi
                 ;;
-            apache)
-                display_instance_status
-                rv=$?
-                ;;
         esac
         if [ $rv -ne 0 ] ; then
             errors=`expr $errors + 1`
diff --git a/base/server/scripts/pkidaemon b/base/server/scripts/pkidaemon
index e4bc249..9cedc6a 100755
--- a/base/server/scripts/pkidaemon
+++ b/base/server/scripts/pkidaemon
@@ -24,12 +24,11 @@ SERVICE_NAME="pkidaemon"
 SERVICE_PROG="/bin/systemctl"
 
 command="$1"
-pki_instance_type="$2"
-pki_instance_id="$3"
+pki_instance_id="$2"
 
-PKI_REGISTRY="/etc/sysconfig/pki/${pki_instance_type}"
-PKI_TYPE="${pki_instance_type}"
-PKI_SYSTEMD_TARGET="pki-${pki_instance_type}d"
+PKI_REGISTRY="/etc/sysconfig/pki/tomcat"
+PKI_TYPE="tomcat"
+PKI_SYSTEMD_TARGET="pki-tomcatd"
 
 # Source the PKI function library
 . /usr/share/pki/scripts/operations
@@ -38,9 +37,7 @@ print_usage()
 {
     echo
     usage
-    echo "where valid instance types include:"
-    list_instance_types
-    echo "and where valid instance names include:"
+    echo "where valid instance names include:"
     list_instances
     exit ${default_error}
 }
@@ -75,9 +72,7 @@ case $command in
         echo "unknown action ($command)"
         echo
         usage
-        echo "where valid instance types include:"
-        list_instance_types
-        echo "and where valid instance names include:"
+        echo "where valid instance names include:"
         list_instances
         exit ${default_error}
         ;;
diff --git a/base/server/share/lib/systemd/system/pki-tomcatd-nuxwdog@.service b/base/server/share/lib/systemd/system/pki-tomcatd-nuxwdog@.service
index 3a0ca65..228ba97 100644
--- a/base/server/share/lib/systemd/system/pki-tomcatd-nuxwdog@.service
+++ b/base/server/share/lib/systemd/system/pki-tomcatd-nuxwdog@.service
@@ -8,7 +8,7 @@ EnvironmentFile=/etc/tomcat/tomcat.conf
 Environment="NAME=%i"
 Environment="STARTED_BY_SYSTEMD=1"
 EnvironmentFile=-/etc/sysconfig/%i
-ExecStartPre=/usr/bin/pkidaemon start tomcat %i
+ExecStartPre=/usr/bin/pkidaemon start %i
 ExecStart=/bin/nuxwdog -f /etc/pki/%i/nuxwdog.conf
 SuccessExitStatus=143
 TimeoutStartSec=180
diff --git a/base/server/share/lib/systemd/system/pki-tomcatd@.service b/base/server/share/lib/systemd/system/pki-tomcatd@.service
index be54242..59858c6 100644
--- a/base/server/share/lib/systemd/system/pki-tomcatd@.service
+++ b/base/server/share/lib/systemd/system/pki-tomcatd@.service
@@ -7,7 +7,7 @@ Type=simple
 EnvironmentFile=/etc/tomcat/tomcat.conf
 Environment="NAME=%i"
 EnvironmentFile=-/etc/sysconfig/%i
-ExecStartPre=/usr/bin/pkidaemon start tomcat %i
+ExecStartPre=/usr/bin/pkidaemon start %i
 ExecStart=/usr/libexec/tomcat/server start
 ExecStop=/usr/libexec/tomcat/server stop
 SuccessExitStatus=143
-- 
1.8.3.1

