From 070039db940ff446d7e1832ff3ccaca5f99cfffb Mon Sep 17 00:00:00 2001
From: Matthew Harmsen <mharmsen@redhat.com>
Date: Tue, 11 Sep 2012 19:02:02 -0700
Subject: [PATCH] Restart existing instances upon package update

* TRAC Ticket #312 - Dogtag 10: Automatically restart any running instances
  upon RPM "update" . . .
* TRAC Ticket #317 - Dogtag 10: Move "pkispawn"/"pkidestroy"
  from /usr/bin to /usr/sbin . . .
---
 base/deploy/CMakeLists.txt |   12 +++++++++++-
 specs/pki-core.spec        |   24 +++++++++++++++++++++---
 specs/pki-ra.spec          |    9 ++++++++-
 specs/pki-tps.spec         |    9 ++++++++-
 4 files changed, 48 insertions(+), 6 deletions(-)

diff --git a/base/deploy/CMakeLists.txt b/base/deploy/CMakeLists.txt
index e0f6536..9838b03 100644
--- a/base/deploy/CMakeLists.txt
+++ b/base/deploy/CMakeLists.txt
@@ -23,10 +23,20 @@ set(APACHE_SUBSYSTEMS
 
 install(
     FILES
-        scripts/pkidaemon
         src/pkispawn
         src/pkidestroy
     DESTINATION
+        ${SBIN_INSTALL_DIR}
+    PERMISSIONS
+        OWNER_EXECUTE OWNER_WRITE OWNER_READ
+        GROUP_EXECUTE GROUP_READ
+        WORLD_EXECUTE WORLD_READ
+)
+
+install(
+    FILES
+        scripts/pkidaemon
+    DESTINATION
         ${BIN_INSTALL_DIR}
     PERMISSIONS
         OWNER_EXECUTE OWNER_WRITE OWNER_READ
diff --git a/specs/pki-core.spec b/specs/pki-core.spec
index 0986ab3..bae9d0a 100644
--- a/specs/pki-core.spec
+++ b/specs/pki-core.spec
@@ -14,7 +14,7 @@ distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
 
 Name:             pki-core
 Version:          10.0.0
-Release:          %{?relprefix}30%{?prerel}%{?dist}
+Release:          %{?relprefix}31%{?prerel}%{?dist}
 Summary:          Certificate System - PKI Core Components
 URL:              http://pki.fedoraproject.org/
 License:          GPLv2
@@ -866,6 +866,9 @@ if [ -d /etc/sysconfig/pki/ca ]; then
                 echo "pkicreate.systemd.servicename=pki-cad@${inst}.service" >> \
                      /var/lib/${inst}/conf/CS.cfg || :
             fi
+        else
+            # Conditionally restart this Dogtag 9 instance
+            /bin/systemctl condrestart pki-cad@${inst}.service
         fi
     done
 fi
@@ -894,6 +897,9 @@ if [ -d /etc/sysconfig/pki/kra ]; then
                 echo "pkicreate.systemd.servicename=pki-krad@${inst}.service" >> \
                      /var/lib/${inst}/conf/CS.cfg || :
             fi
+        else
+            # Conditionally restart this Dogtag 9 instance
+            /bin/systemctl condrestart pki-krad@${inst}.service
         fi
     done
 fi
@@ -922,6 +928,9 @@ if [ -d /etc/sysconfig/pki/ocsp ]; then
                 echo "pkicreate.systemd.servicename=pki-ocspd@${inst}.service" >> \
                      /var/lib/${inst}/conf/CS.cfg || :
             fi
+        else
+            # Conditionally restart this Dogtag 9 instance
+            /bin/systemctl condrestart pki-ocspd@${inst}.service
         fi
     done
 fi
@@ -950,6 +959,9 @@ if [ -d /etc/sysconfig/pki/tks ]; then
                 echo "pkicreate.systemd.servicename=pki-tksd@${inst}.service" >> \
                      /var/lib/${inst}/conf/CS.cfg || :
             fi
+        else
+            # Conditionally restart this Dogtag 9 instance
+            /bin/systemctl condrestart pki-tksd@${inst}.service
         fi
     done
 fi
@@ -1106,8 +1118,8 @@ fi
 %files -n pki-server
 %defattr(-,root,root,-)
 %doc base/deploy/LICENSE
-%{_bindir}/pkispawn
-%{_bindir}/pkidestroy
+%{_sbindir}/pkispawn
+%{_sbindir}/pkidestroy
 #%{_bindir}/pki-setup-proxy
 %dir %{python_sitelib}/pki
 %{python_sitelib}/pki/_*
@@ -1304,6 +1316,12 @@ fi
 
 
 %changelog
+* Tue Sep 11 2012 Matthew Harmsen <mharmsen@redhat.com> 10.0.0-0.31.a1
+- TRAC Ticket #312 - Dogtag 10: Automatically restart any running instances
+  upon RPM "update" . . .
+- TRAC Ticket #317 - Dogtag 10: Move "pkispawn"/"pkidestroy"
+  from /usr/bin to /usr/sbin . . .
+
 * Tue Sep 11 2012 Endi S. Dewata <edewata@redhat.com> 10.0.0-0.30.a1
 - Added build dependency on redhat-rpm-config.
 
diff --git a/specs/pki-ra.spec b/specs/pki-ra.spec
index 2648333..e0e8186 100644
--- a/specs/pki-ra.spec
+++ b/specs/pki-ra.spec
@@ -7,7 +7,7 @@
 
 Name:             pki-ra
 Version:          10.0.0
-Release:          %{?relprefix}5%{?prerel}%{?dist}
+Release:          %{?relprefix}6%{?prerel}%{?dist}
 Summary:          Certificate System - Registration Authority
 URL:              http://pki.fedoraproject.org/
 License:          GPLv2
@@ -195,6 +195,9 @@ if [ -d /etc/sysconfig/pki/ra ]; then
                 echo "pkicreate.systemd.servicename=pki-rad@${inst}.service" >> \
                      /var/lib/${inst}/conf/CS.cfg || :
             fi
+        else
+            # Conditionally restart this Dogtag 9 instance
+            /bin/systemctl condrestart pki-rad@${inst}.service
         fi
     done
 fi
@@ -243,6 +246,10 @@ fi
 
 
 %changelog
+* Tue Sep 11 2012 Matthew Harmsen <mharmsen@redhat.com> 10.0.0-0.6.a1
+- TRAC Ticket #312 - Dogtag 10: Automatically restart any running instances
+  upon RPM "update" . . .
+
 * Mon Aug 20 2012 Endi S. Dewata <edewata@redhat.com> 10.0.0-0.5.a1
 - Removed direct dependency on 'pki-native-tools'.
 
diff --git a/specs/pki-tps.spec b/specs/pki-tps.spec
index ad3d10b..28035f2 100644
--- a/specs/pki-tps.spec
+++ b/specs/pki-tps.spec
@@ -7,7 +7,7 @@
 
 Name:             pki-tps
 Version:          10.0.0
-Release:          %{?relprefix}5%{?prerel}%{?dist}
+Release:          %{?relprefix}6%{?prerel}%{?dist}
 Summary:          Certificate System - Token Processing System
 URL:              http://pki.fedoraproject.org/
 License:          LGPLv2
@@ -224,6 +224,9 @@ if [ -d /etc/sysconfig/pki/tps ]; then
                 echo "pkicreate.systemd.servicename=pki-tpsd@${inst}.service" >> \
                      /var/lib/${inst}/conf/CS.cfg || :
             fi
+        else
+            # Conditionally restart this Dogtag 9 instance
+            /bin/systemctl condrestart pki-tpsd@${inst}.service
         fi
     done
 fi
@@ -278,6 +281,10 @@ fi
 
 
 %changelog
+* Tue Sep 11 2012 Matthew Harmsen <mharmsen@redhat.com> 10.0.0-0.6.a1
+- TRAC Ticket #312 - Dogtag 10: Automatically restart any running instances
+  upon RPM "update" . . .
+
 * Mon Aug 20 2012 Endi S. Dewata <edewata@redhat.com> 10.0.0-0.5.a1
 - Removed direct dependency on 'pki-native-tools'.
 
-- 
1.7.10.4

