From 60e7a02a2438fe51241c12cb3c26c9b7a2ed6152 Mon Sep 17 00:00:00 2001
From: Abhishek Koneru <akoneru@redhat.com>
Date: Thu, 18 Apr 2013 10:24:26 -0400
Subject: [PATCH] Minor fixes in a few configuration UI panels of RA and TPS.

Changed the status check and restart commands to systemctl.
The text $errorString will not be seen when the security domain login panel
is launched for the first time.

Ticket #452
---
 .../netscape/cms/servlet/csadmin/SecurityDomainLogin.java  |    1 +
 .../ra/apache/docroot/ra/admin/console/config/donepanel.vm |    3 +--
 .../docroot/ra/admin/console/config/securitydomainpanel.vm |    2 +-
 base/ra/lib/perl/PKI/RA/DonePanel.pm                       |    8 ++++----
 base/ra/lib/perl/PKI/RA/SecurityDomainPanel.pm             |   12 ++++++------
 .../apache/docroot/tps/admin/console/config/donepanel.vm   |   11 +----------
 .../tps/admin/console/config/securitydomainpanel.vm        |    2 +-
 base/tps/lib/perl/PKI/TPS/DonePanel.pm                     |    8 ++++----
 base/tps/lib/perl/PKI/TPS/SecurityDomainPanel.pm           |   12 ++++++------
 9 files changed, 25 insertions(+), 34 deletions(-)

diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/SecurityDomainLogin.java b/base/common/src/com/netscape/cms/servlet/csadmin/SecurityDomainLogin.java
index 42165b08f3daabc902ae04eb1d2da65e1c4997d2..ed242f6913e70dca9a66c4ca1d7afc51d2e3bf5b 100644
--- a/base/common/src/com/netscape/cms/servlet/csadmin/SecurityDomainLogin.java
+++ b/base/common/src/com/netscape/cms/servlet/csadmin/SecurityDomainLogin.java
@@ -67,6 +67,7 @@ public class SecurityDomainLogin extends BaseServlet {
             context.put("sd_pwd", "");
             context.put("url", url);
             context.put("host", u.getHost());
+            context.put("errorString", "");
             context.put("sdhost", CMS.getEESSLHost());
             if (subsystem.equals("KRA")) {
                 subsystem = "DRM";
diff --git a/base/ra/apache/docroot/ra/admin/console/config/donepanel.vm b/base/ra/apache/docroot/ra/admin/console/config/donepanel.vm
index 86e4068ea343d3078384df8e43d3657095d2da2d..dcfe08ed46642edd24c51938c30c49c3903d8d61 100644
--- a/base/ra/apache/docroot/ra/admin/console/config/donepanel.vm
+++ b/base/ra/apache/docroot/ra/admin/console/config/donepanel.vm
@@ -32,8 +32,7 @@ function performPanel() {
 #if ($errorString != "")
 <img src="/pki/images/icon_crit_update.gif">&nbsp;<font color="red">$errorString</font>
 #end
-As 'root', restart the server on the command line by typing "$initCommand
- restart $instanceID". After performing this restart, the server should become operational.
+As 'root', restart the server on the command line by typing "$restartCommand". After performing this restart, the server should become operational.
 <br/>
 Please go to the <A href="https://$host:$non_clientauth_port"><b>services page</b></A> to access all of the available interfaces.
 <br/>
diff --git a/base/ra/apache/docroot/ra/admin/console/config/securitydomainpanel.vm b/base/ra/apache/docroot/ra/admin/console/config/securitydomainpanel.vm
index f67f7b2424f9414d119ea00f5df4fa87e97af319..39c3af9929e3b2789a17ac18184e2c38e78b08cd 100644
--- a/base/ra/apache/docroot/ra/admin/console/config/securitydomainpanel.vm
+++ b/base/ra/apache/docroot/ra/admin/console/config/securitydomainpanel.vm
@@ -109,7 +109,7 @@ Enter the URL to an existing security domain.
 <table>
 <tr>
 <td valign="top"><b>NOTE:&nbsp;&nbsp; </b></td>
-<td>Since a Security Domain MUST be a CA (although all CAs are NOT necessarily Security Domains), an appropriate value for this URL may be obtained by logging into the machine which hosts the desired Security Domain CA as 'root' and running the command "$initCommand status $instanceID" from the command-line.</td>
+<td>Since a Security Domain MUST be a CA (although all CAs are NOT necessarily Security Domains), an appropriate value for this URL may be obtained by logging into the machine which hosts the desired Security Domain CA as 'root' and running the command "$statusCommand" from the command-line.</td>
 </tr>
 </table>
 <br/>
diff --git a/base/ra/lib/perl/PKI/RA/DonePanel.pm b/base/ra/lib/perl/PKI/RA/DonePanel.pm
index 4a32a8270ea92d05ecb845cde36dda66372407bd..721718afa242a4f50c7bc9499b52c1a66ba93a87 100755
--- a/base/ra/lib/perl/PKI/RA/DonePanel.pm
+++ b/base/ra/lib/perl/PKI/RA/DonePanel.pm
@@ -367,19 +367,19 @@ sub display
     my $instanceID = $::config->get("service.instanceID");
 
     my $initDaemon = "pki-rad";
-    my $initCommand = "";
+    my $restartCommand = "";
     if( $^O eq "linux" ) {
-        $initCommand = "/sbin/service $initDaemon";
+        $restartCommand = "systemctl restart $intiDaemon\@$instanceID.service";
     } else {
         ## default case:  e. g. - ( $^O eq "solaris" )
-        $initCommand  = "/etc/init.d/$initDaemon";
+        $restartCommand  = "/etc/init.d/$initDaemon restart $instanceID";
     }
 
     $::symbol{host}  = $machineName;
     $::symbol{unsecurePort}  = $unsecurePort;
     $::symbol{port}  = $securePort;
     $::symbol{non_clientauth_port}  = $non_clientauth_securePort;
-    $::symbol{initCommand}  = $initCommand;
+    $::symbol{restartCommand}  = $restartCommand;
     $::symbol{instanceID}  = $instanceID;
 
     $::config->deleteSubstore("preop.");
diff --git a/base/ra/lib/perl/PKI/RA/SecurityDomainPanel.pm b/base/ra/lib/perl/PKI/RA/SecurityDomainPanel.pm
index 114b19ef0c0a16e6906e332801249ef5d9dad730..3370b9d2572de05f6050eeb54550f003d4322998 100755
--- a/base/ra/lib/perl/PKI/RA/SecurityDomainPanel.pm
+++ b/base/ra/lib/perl/PKI/RA/SecurityDomainPanel.pm
@@ -134,16 +134,16 @@ sub display
     $::symbol{sdomainAdminURL} = "https://" . $hostname . ":"
                                . $default_https_admin_port;
 
-    my $initDaemon = "pki-cad";
-    my $initCommand = "";
-    my $instanceID ="&lt;security_domain_instance_name&gt; ";
+    my $initDaemon = "pki-tomcatd";
+    my $statusCommand = "";
+    my $instanceID ="&lt;security_domain_instance_name&gt;";
     if( $^O eq "linux" ) {
-        $initCommand = "/sbin/service $initDaemon";
+        $statusCommand = "systemctl status $initDaemon\@$instanceID.service";
     } else {
         ## default case:  e. g. - ( $^O eq "solaris" )
-        $initCommand  = "/etc/init.d/$initDaemon";
+        $statusCommand  = "/etc/init.d/$initDaemon status $instanceID";
     }
-    $::symbol{initCommand} = $initCommand;
+    $::symbol{statusCommand} = $statusCommand;
     $::symbol{instanceID} = $instanceID;
     return 1;
 }
diff --git a/base/tps/apache/docroot/tps/admin/console/config/donepanel.vm b/base/tps/apache/docroot/tps/admin/console/config/donepanel.vm
index 2aa76ff0c8cb874330f1e5a36e2eaad44acf4133..3df605d694cccb465d9efd3252e3a1f5ac42fb18 100644
--- a/base/tps/apache/docroot/tps/admin/console/config/donepanel.vm
+++ b/base/tps/apache/docroot/tps/admin/console/config/donepanel.vm
@@ -31,21 +31,12 @@ function performPanel() {
 #if ($errorString != "")
 <img src="/pki/images/icon_crit_update.gif">&nbsp;<font color="red">$errorString</font>
 #end
-#if ($systemType == "tks")
-As 'root', restart the server on the command line by typing "$initCommand restart $instanceID". After performing this restart, the server should become operational. 
-#else
-#if ($externalCA == "true" && $systemType == "kra")
-As 'root', restart the server on the command line by typing "$initCommand restart $instanceID". Startup the administration console to add the peer CA to the Trusted Manager's Group. Make sure to add the transport certificate and connector information to the peer CA. After performing this restart, the server should become operational.
-#else
-As 'root', restart the server on the command line by typing "$initCommand
- restart $instanceID". After performing this restart, the server should become operational.
+As 'root', restart the server on the command line by typing "$restartCommand". After performing this restart, the server should become operational.
 <br/>
 Please go to the <A href="https://$host:$non_clientauth_port">services page</A> to access all of the available interfaces.
 <br/>
 Each Enterprise Security Client (ESC) talks to a TPS config URL for token management functions located at <A href="http://$host:$unsecurePort/cgi-bin/home/index.cgi">http://$host:$unsecurePort/cgi-bin/home/index.cgi</A>.
 <br/>
-#end
-#end
 <br/>
 To create additional instances, type "/usr/bin/pkicreate" on the command line.
 <br/>
diff --git a/base/tps/apache/docroot/tps/admin/console/config/securitydomainpanel.vm b/base/tps/apache/docroot/tps/admin/console/config/securitydomainpanel.vm
index 6f651f3885170490c03e4ccf303e7c69b2c317cb..adb45cff69953c03707aee9b4920c8b253861461 100644
--- a/base/tps/apache/docroot/tps/admin/console/config/securitydomainpanel.vm
+++ b/base/tps/apache/docroot/tps/admin/console/config/securitydomainpanel.vm
@@ -108,7 +108,7 @@ Enter the URL to an existing security domain.
 <table>
 <tr>
 <td valign="top"><b>NOTE:&nbsp;&nbsp; </b></td>
-<td>Since a Security Domain MUST be a CA (although all CAs are NOT necessarily Security Domains), an appropriate value for this URL may be obtained by logging into the machine which hosts the desired Security Domain CA as 'root' and running the command "$initCommand status $instanceID" from the command-line.</td>
+<td>Since a Security Domain MUST be a CA (although all CAs are NOT necessarily Security Domains), an appropriate value for this URL may be obtained by logging into the machine which hosts the desired Security Domain CA as 'root' and running the command "$statusCommand" from the command-line.</td>
 </tr>
 </table>
 <br/>
diff --git a/base/tps/lib/perl/PKI/TPS/DonePanel.pm b/base/tps/lib/perl/PKI/TPS/DonePanel.pm
index 3d897fca994fdfd48625e8c86b0b5e7da55dd830..06c30646ea7371a60e3b28b79c84db447ff7f318 100755
--- a/base/tps/lib/perl/PKI/TPS/DonePanel.pm
+++ b/base/tps/lib/perl/PKI/TPS/DonePanel.pm
@@ -401,19 +401,19 @@ sub display
     my $instanceID = $::config->get("service.instanceID");
 
     my $initDaemon = "pki-tpsd";
-    my $initCommand = "";
+    my $restartCommand = "";
     if( $^O eq "linux" ) {
-        $initCommand = "/sbin/service $initDaemon";
+        $restartCommand = "systemctl restart $initDaemon\@$instanceID";
     } else {
         ## default case:  e. g. - ( $^O eq "solaris" )
-        $initCommand  = "/etc/init.d/$initDaemon";
+        $restartCommand  = "/etc/init.d/$initDaemon restart $instanceID";
     }
 
     $::symbol{host}  = $machineName;
     $::symbol{unsecurePort}  = $unsecurePort;
     $::symbol{port}  = $securePort;
     $::symbol{non_clientauth_port}  = $non_clientauth_securePort;
-    $::symbol{initCommand}  = $initCommand;
+    $::symbol{restartCommand}  = $restartCommand;
     $::symbol{instanceID}  = $instanceID;
 
     $::config->deleteSubstore("preop.");
diff --git a/base/tps/lib/perl/PKI/TPS/SecurityDomainPanel.pm b/base/tps/lib/perl/PKI/TPS/SecurityDomainPanel.pm
index 5301d13693ecd835577dd2b4b0073fc37901b662..8c52d8b406a1e476d829c5f540bfbfe407477c7f 100755
--- a/base/tps/lib/perl/PKI/TPS/SecurityDomainPanel.pm
+++ b/base/tps/lib/perl/PKI/TPS/SecurityDomainPanel.pm
@@ -133,16 +133,16 @@ sub display
     $::symbol{sdomainAdminURL} = "https://" . $hostname . ":"
                                . $default_https_admin_port;
 
-    my $initDaemon = "pki-cad";
-    my $initCommand = "";
-    my $instanceID = "&lt;security_domain_instance_name&gt; ";
+    my $initDaemon = "pki-tomcatd";
+    my $statusCommand = "";
+    my $instanceID = "&lt;security_domain_instance_name&gt;";
     if( $^O eq "linux" ) {
-        $initCommand = "/sbin/service $initDaemon";
+        $statusCommand = "systemctl status $initDaemon\@$instanceID.service";
     } else {
         ## default case:  e. g. - ( $^O eq "solaris" )
-        $initCommand  = "/etc/init.d/$initDaemon";
+        $statusCommand  = "/etc/init.d/$initDaemon status $instanceID";
     }
-    $::symbol{initCommand} = $initCommand;
+    $::symbol{statusCommand} = $statusCommand;
     $::symbol{instanceID}  = $instanceID;
     return 1;
 }
-- 
1.7.10.2

