From 5d0fda83a87ba827433b92e4863580325cc6698d Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Tue, 06 Aug 2013 15:23:03 +0000
Subject: [PATCH] CR-2123 OPENDJ-1068 create resources for rpm packaging - added init.d script to RPM package.

---
 opends/resource/rpm/specFile |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/opends/resource/rpm/specFile b/opends/resource/rpm/specFile
index f5465ec..8702a13 100644
--- a/opends/resource/rpm/specFile
+++ b/opends/resource/rpm/specFile
@@ -87,6 +87,10 @@
     rm -r "${RPM_BUILD_ROOT}"%{_prefix}$excludedFiles
 done
 
+# Moves the init.d script.
+mkdir -p "$RPM_BUILD_ROOT"/etc/init.d/
+install -m 755 "$RPM_SOURCE_DIR"/opendj "$RPM_BUILD_ROOT"/etc/init.d/opendj
+
 %clean
 [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf "${RPM_BUILD_ROOT}"
 
@@ -123,6 +127,10 @@
 # -------------------------
 # Post Install
 %post
+# Registers the service
+/sbin/chkconfig --add opendj
+# Symlink to process ID
+ln -s /opt/opendj/logs/server.pid /var/run/opendj.pid 
 if [ "$1" == "1" ] ; then
     echo "Post Install - initial install"
 else if [ "$1" == "2" ] ; then
@@ -165,6 +173,11 @@
 %preun
 if [ "$1" == "0" ] ; then
     echo "Pre Uninstall - uninstall"
+# Stops the service and delete it.    
+    /etc/init.d/opendj stop >/dev/null 2>&1
+    /sbin/chkconfig --del opendj
+    # Unlink the symlink to the process ID.
+    unlink /var/run/opendj.pid 
 # Only if the instance has been configured    
     if [ -e "%{_prefix}"/config/buildinfo ] && [ "$(ls -A "%{_prefix}"/config/archived-configs)" ]
     then
@@ -196,6 +209,9 @@
 # Changelog
 # =========================
 %changelog
+* Tue Aug 6 2013 ForgeRock
+- Added init.d service script.
+
 * Wed Jul 31 2013 ForgeRock
 - Fixed the doc's section.
 - Target no longer fails when build path contains spaces.

--
Gitblit v1.10.0