summaryrefslogtreecommitdiffstats
path: root/pki/base/common/scripts
diff options
context:
space:
mode:
authorjdennis <jdennis@c9f7a03b-bd48-0410-a16d-cbbf54688b0b>2010-11-19 20:59:35 +0000
committerjdennis <jdennis@c9f7a03b-bd48-0410-a16d-cbbf54688b0b>2010-11-19 20:59:35 +0000
commitd221194fa0a8c50d32b0b99b307ed395d7c0dc9d (patch)
tree7355f4321d14f800dd77b2e63719baf980a109ee /pki/base/common/scripts
parent974cf6d6b5c55d031dfb756f73e22b119637f662 (diff)
downloadpki-d221194fa0a8c50d32b0b99b307ed395d7c0dc9d.tar.gz
pki-d221194fa0a8c50d32b0b99b307ed395d7c0dc9d.tar.xz
pki-d221194fa0a8c50d32b0b99b307ed395d7c0dc9d.zip
Make the instance initscript local to the instance
Earlier in the patch series a change was introduced with respect to the initscripts. A per instance initscript was created in /etc/init.d for each instance. This was simply a symlink to the tomcat6 initscript (using the instance name). The uber initscript, pki-cad, would iterate over the installed instances and invoke the per instance initscript. However during the review process it was pointed out that when removing (erasing) an rpm the per instance initscripts would not be removed because they are not in the rpm file manifest. This would leave dangling initscripts. Also it was felt the per instance initscript in /etc/init.d was confusing when combined with the uber initscript. This patch moves the per instance initscript from /etc/init.d to the instance directory. It retains the same name (i.e. the instance name). Now instead of the the uber initscript invoking the per instance initscript in /etc/init.d via the service command it instead directly invokes initscript in the instance directory. This patch also fixes a bug discovered from reading the shell code invoked by the uber initscript (in the pki "functions" library). The test to determine if a supplied instance name was vaid was incorrect. The code did this: if [ "${PKI_REGISTRY}/${pki_instance}" != "${PKI_REGISTRY_ENTRIES}" ] however $PKI_REGISTRY_ENTRIES is a space separated list of all registry instance files, thus the test only succeeds if there is a single instance. The test was modified to iterate over the all the entries in $PKI_REGISTRY_ENTRIES. This patch also fixed the list_intances() function to list only the instance name, not the full path the to instance configuration file. We also replaced the use of /bin/ls with a shell glob. This patch also moves some variables which had been identically defined in both pkicreate and pkiremove into the pkicommon library for consistency and maintenance sake. git-svn-id: svn+ssh://svn.fedorahosted.org/svn/pki/trunk@1572 c9f7a03b-bd48-0410-a16d-cbbf54688b0b
Diffstat (limited to 'pki/base/common/scripts')
-rw-r--r--pki/base/common/scripts/functions28
1 files changed, 18 insertions, 10 deletions
diff --git a/pki/base/common/scripts/functions b/pki/base/common/scripts/functions
index 19d071e68..68a15c3dc 100644
--- a/pki/base/common/scripts/functions
+++ b/pki/base/common/scripts/functions
@@ -103,10 +103,9 @@ TOTAL_PKI_REGISTRY_ENTRIES=0
TOTAL_UNCONFIGURED_PKI_ENTRIES=0
# Gather ALL registered instances of this PKI subsystem type
-for FILE in `/bin/ls -1 ${PKI_REGISTRY}/* 2>/dev/null`; do
+for FILE in ${PKI_REGISTRY}/*; do
if [ -f "$FILE" ] ; then
- inst=`echo "$FILE"`
- PKI_REGISTRY_ENTRIES="${PKI_REGISTRY_ENTRIES} $inst"
+ PKI_REGISTRY_ENTRIES="${PKI_REGISTRY_ENTRIES} $FILE"
TOTAL_PKI_REGISTRY_ENTRIES=`expr ${TOTAL_PKI_REGISTRY_ENTRIES} + 1`
fi
done
@@ -140,8 +139,9 @@ usage()
list_instances()
{
echo
- for FILE in `/bin/ls -1 ${PKI_REGISTRY}/* 2>/dev/null`; do
- echo " ${FILE}"
+ for PKI_REGISTRY_ENTRY in $PKI_REGISTRY_ENTRIES; do
+ instance_name=`basename $PKI_REGISTRY_ENTRY`
+ echo " $instance_name"
done
echo
}
@@ -181,7 +181,15 @@ fi
# If an "instance" was supplied, check that it is a "valid" instance
if [ -n "${pki_instance}" ]; then
- if [ "${PKI_REGISTRY}/${pki_instance}" != "${PKI_REGISTRY_ENTRIES}" ]; then
+ valid=0
+ for PKI_REGISTRY_ENTRY in $PKI_REGISTRY_ENTRIES; do
+ instance_name=`basename $PKI_REGISTRY_ENTRY`
+ if [ $pki_instance == $instance_name ]; then
+ valid=1
+ break
+ fi
+ done
+ if [ $valid -eq 0 ]; then
echo -n "${pki_instance} is an invalid '${PKI_TYPE}' instance"
echo_failure
echo
@@ -512,13 +520,13 @@ display_instance_status()
rv=0
# Verify there is an initscript for this instance
- if [ ! -f /etc/init.d/${PKI_INSTANCE_ID} ]; then
+ if [ ! -f $PKI_INSTANCE_INITSCRIPT ]; then
# 4 program or service status is unknown
return 4
fi
# Invoke the initscript for this instance
- $SERVICE_PROG $PKI_INSTANCE_ID status
+ $PKI_INSTANCE_INITSCRIPT status
rv=$?
if [ $rv -eq 0 ] ; then
@@ -537,7 +545,7 @@ start_instance()
fi
# Invoke the initscript for this instance
- $SERVICE_PROG $PKI_INSTANCE_ID start
+ $PKI_INSTANCE_INITSCRIPT start
rv=$?
if [ $rv -eq 0 ] ; then
@@ -567,7 +575,7 @@ stop_instance()
rv=0
# Invoke the initscript for this instance
- $SERVICE_PROG $PKI_INSTANCE_ID stop
+ $PKI_INSTANCE_INITSCRIPT stop
rv=$?
return $rv