>From b617598d1c2bcedc94fbc98a3381a5f8dbc05a4a Mon Sep 17 00:00:00 2001
From: Ade Lee <alee@redhat.com>
Date: Fri, 3 Aug 2012 11:31:15 -0400
Subject: [PATCH] Fixed operations to operate on correct number of instances

Reverted previous fix to pkidaemon and operations.  Now, as
expected, systemctl start/stop pki-tomcatd@foo.service will stop
instance foo, whereas pki-tomcatd.target will affect all tomcatd
instances.
---
 base/deploy/scripts/operations | 102 +----------------------------------------
 base/deploy/scripts/pkidaemon  |  14 ------
 2 files changed, 2 insertions(+), 114 deletions(-)

diff --git a/base/deploy/scripts/operations b/base/deploy/scripts/operations
index 23e5e2184386fa123db5748ca45e1838f639a5b4..4f89c1a197991d42d6df6345ee203e1bf163cb89 100644
--- a/base/deploy/scripts/operations
+++ b/base/deploy/scripts/operations
@@ -40,10 +40,6 @@ case $command in
         # 1 generic or unspecified error (current practice)
         default_error=1
         ;;
-    start_all|stop_all|restart_all)
-        # 1 generic or unspecified error (current practice)
-        default_error=1
-        ;;
     reload)
         default_error=3
         ;;
@@ -138,8 +134,8 @@ done
 # Execute the specified registered instance of this PKI web server type
 if [ -n "${pki_instance_id}" ]; then
     for INSTANCE in ${PKI_REGISTRY_ENTRIES}; do
-        if [ "${PKI_REGISTRY}/${pki_instance_id}" = "$INSTANCE" ]; then
-            PKI_REGISTRY_ENTRIES="${PKI_REGISTRY}/${pki_instance_id}"
+        if [ "`basename ${INSTANCE}`" == "${pki_instance_id}" ]; then
+            PKI_REGISTRY_ENTRIES="${INSTANCE}"
             TOTAL_PKI_REGISTRY_ENTRIES=1
             break
         fi
@@ -152,9 +148,6 @@ usage()
     echo -n "{start"
     echo -n "|stop"
     echo -n "|restart"
-    echo -n "|start_all"
-    echo -n "|stop_all"
-    echo -n "|restart_all"
     echo -n "|condrestart"
     echo -n "|force-restart"
     echo -n "|try-restart"
@@ -171,9 +164,6 @@ usage_systemd()
     echo -n "{start"
     echo -n "|stop"
     echo -n "|restart"
-    echo -n "|start_all"
-    echo -n "|stop_all"
-    echo -n "|restart_all"
     echo -n "|condrestart"
     echo -n "|force-restart"
     echo -n "|try-restart"
@@ -931,54 +921,6 @@ start()
         return 5
     fi
 
-    # Source values associated with this particular PKI instance
-    [ -f ${PKI_REGISTRY_ENTRY} ] &&
-    . ${PKI_REGISTRY_ENTRY}
-
-    start_instance
-    rv=$?
-    if [ $rv = 6 ] ; then
-        # Since at least ONE configuration error exists, then there
-        # is at least ONE unconfigured instance from the PKI point
-        # of view.
-        #
-        # However, it must still be considered that the
-        # instance is "running" from the point of view of other
-        # OS programs such as 'chkconfig'.
-        #
-        # Therefore, ignore non-zero return codes resulting
-        # from configuration errors.
-        #
-
-        config_errors=`expr $config_errors + 1`
-        rv=0
-    elif [ $rv != 0 ] ; then
-        errors=`expr $errors + 1`
-        error_rv=$rv
-    fi
-
-    if [ ${TOTAL_PKI_REGISTRY_ENTRIES} -gt ${errors} ] ; then
-        touch ${lockfile}
-        chmod 00600 ${lockfile}
-    fi
-
-    return $rv
-}
-
-start_all()
-{
-    error_rv=0
-    rv=0
-    config_errors=0
-    errors=0
-
-    if [ ${TOTAL_PKI_REGISTRY_ENTRIES} -eq 0 ]; then
-        echo
-        echo "ERROR:  No '${PKI_TYPE}' instances installed!"
-        # 5 program is not installed
-        return 5
-    fi
-
     if [ ${TOTAL_PKI_REGISTRY_ENTRIES} -gt 1 ]; then
         echo "BEGIN STARTING '${PKI_TYPE}' INSTANCES:"
     fi
@@ -1069,37 +1011,6 @@ stop()
         return 5
     fi
 
-    # Source values associated with this particular PKI instance
-    [ -f ${PKI_REGISTRY_ENTRY} ] &&
-    . ${PKI_REGISTRY_ENTRY}
-
-    stop_instance
-    rv=$?
-    if [ $rv != 0 ] ; then
-        errors=`expr $errors + 1`
-        error_rv=$rv
-    fi
-
-    if [ ${errors} -eq 0 ] ; then
-        rm -f ${lockfile}
-    fi
-
-    return $rv
-}
-
-stop_all()
-{
-    error_rv=0
-    rv=0
-    errors=0
-
-    if [ ${TOTAL_PKI_REGISTRY_ENTRIES} -eq 0 ]; then
-        echo
-        echo "ERROR:  No '${PKI_TYPE}' instances installed!"
-        # 5 program is not installed
-        return 5
-    fi
-
     if [ ${TOTAL_PKI_REGISTRY_ENTRIES} -gt 1 ] ; then
         echo "BEGIN SHUTTING DOWN '${PKI_TYPE}' INSTANCE(S):"
     fi
@@ -1161,15 +1072,6 @@ restart()
     return $?
 }
 
-restart_all()
-{
-    stop_all
-    sleep 2
-    start_all
-
-    return $?
-}
-
 registry_status()
 {
     error_rv=0
diff --git a/base/deploy/scripts/pkidaemon b/base/deploy/scripts/pkidaemon
index 74f69e968adddea6decb98582cd5dcfc9fc6d81e..02b02370f44cbb575b152c548e4b019017396294 100755
--- a/base/deploy/scripts/pkidaemon
+++ b/base/deploy/scripts/pkidaemon
@@ -56,20 +56,6 @@ case $command in
         stop
         exit $?
         ;;
-    start_all)
-        start_all
-        exit $?
-        ;;
-    restart_all)
-        restart_all
-        exit $?
-        ;;
-    stop_all)
-        echo "An exit status of '143' refers to the 'systemd' method of using"\
-             "'SIGTERM' to shutdown a Java process and can safely be ignored."
-        stop_all
-        exit $?
-        ;;
     condrestart|force-restart|try-restart)
         [ ! -f ${lockfile} ] || restart
         echo "The '${command}' action is TBD."
-- 
1.7.11.2

