[csw-devel] SF.net SVN: gar:[4430] csw/mgar/pkg/cswclassutils/trunk
bonivart at users.sourceforge.net
bonivart at users.sourceforge.net
Tue Apr 21 18:26:56 CEST 2009
Revision: 4430
http://gar.svn.sourceforge.net/gar/?rev=4430&view=rev
Author: bonivart
Date: 2009-04-21 16:26:56 +0000 (Tue, 21 Apr 2009)
Log Message:
-----------
cswclassutils: fix bug 3632, 3633, 3634
Modified Paths:
--------------
csw/mgar/pkg/cswclassutils/trunk/Makefile
csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.i.cswinitsmf
csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswinitsmf
Modified: csw/mgar/pkg/cswclassutils/trunk/Makefile
===================================================================
--- csw/mgar/pkg/cswclassutils/trunk/Makefile 2009-04-21 15:46:20 UTC (rev 4429)
+++ csw/mgar/pkg/cswclassutils/trunk/Makefile 2009-04-21 16:26:56 UTC (rev 4430)
@@ -1,5 +1,5 @@
GARNAME = cswclassutils
-GARVERSION = 1.5
+GARVERSION = 1.6
CATEGORIES = utils
DESCRIPTION = CSW class action utilities
Modified: csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.i.cswinitsmf
===================================================================
--- csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.i.cswinitsmf 2009-04-21 15:46:20 UTC (rev 4429)
+++ csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.i.cswinitsmf 2009-04-21 16:26:56 UTC (rev 4430)
@@ -7,10 +7,28 @@
#
# 2008-04-21 First release
# 2009-03-28 Added support for refresh
+# 2009-04-21 Do not create rc links unless enabled (Bug ID 0003633),
+ Persistent state across upgrades (Bug ID 0003634)
DEBUG= # clear to disable debug, set to anything to enable
SVCDIR=/var/opt/csw/svc
+SMF_STATE_DIR="$PKG_INSTALL_ROOT/etc/opt/csw/preserve/$PKG"
+SMF_STATE_FILE="$SMF_STATE_DIR/smf.state"
+
+# retrieve the previous state of a service identified by the given FRMI
+load_smf_service_state ()
+{
+ SMF_STATE="disabled"
+
+ if [ -f "$SMF_STATE_FILE" ]; then
+ set -- `/usr/bin/awk " \\\$1 == \"$1\" { print \\\$2 } " "$SMF_STATE_FILE"`
+ if [ "$1" = "enabled" ]; then
+ SMF_STATE="enabled"
+ fi
+ fi
+}
+
# Source csw.conf, if it exists
if [ -f $PKG_INSTALL_ROOT/opt/csw/etc/csw.conf ] ; then
. $PKG_INSTALL_ROOT/opt/csw/etc/csw.conf
@@ -34,6 +52,19 @@
echo PACKAGE: $PKGINST SMF: $smf
fi
+# Determine if service should be started or not
+daemon=yes
+
+if [ "$autoenable_daemons" = "no" ]; then
+ daemon=no
+fi
+
+if [ "$autoenable_$service" = "no" ]; then
+ daemon=no
+elif [ "$autoenable_$service" = "yes" ]; then
+ daemon=yes
+fi
+
# Copy files, set up SMF
echo "Installing class <cswinitsmf> ..."
@@ -176,74 +207,66 @@
/usr/bin/ln -s $dest /etc/init.d/$service
/usr/sbin/installf -c cswinitsmf $PKGINST /etc/init.d/$service=$dest s
- # Create rc-symlinks
- RC_KNUM=
- if [ "`grep '^#RC_KNUM' $dest`" ]; then
- RC_KNUM=`grep '^#RC_KNUM' $dest | awk '{print $2}'`
+ # Create rc-symlinks if enabled
+ if [ "$daemon" = "yes" ]; then
+ RC_KNUM=
+ if [ "`grep '^#RC_KNUM' $dest`" ]; then
+ RC_KNUM=`grep '^#RC_KNUM' $dest | awk '{print $2}'`
+ fi
+ RC_SNUM=
+ if [ "`grep '^#RC_SNUM' $dest`" ]; then
+ RC_SNUM=`grep '^#RC_SNUM' $dest | awk '{print $2}'`
+ fi
+ RC_KLEV=
+ if [ "`grep '^#RC_KLEV' $dest`" ]; then
+ RC_KLEV=`grep '^#RC_KLEV' $dest | awk '{print $2}'`
+ RC_KLEV=`echo $RC_KLEV | sed 's/,/ /g'`
+ fi
+ RC_SLEV=
+ if [ "`grep '^#RC_SLEV' $dest`" ]; then
+ RC_SLEV=`grep '^#RC_SLEV' $dest | awk '{print $2}'`
+ RC_SLEV=`echo $RC_SLEV | sed 's/,/ /g'`
+ fi
+ if [ ! "$RC_KNUM" ]; then
+ RC_KNUM=20
+ fi
+ if [ ! "$RC_SNUM" ]; then
+ RC_SNUM=80
+ fi
+ if [ ! "$RC_KLEV" ]; then
+ RC_KLEV="0 1 2 S"
+ fi
+ if [ ! "$RC_SLEV" ]; then
+ RC_SLEV=3
+ fi
+ if [ "$DEBUG" ]; then
+ echo RC_KNUM: $RC_KNUM
+ echo RC_SNUM: $RC_SNUM
+ echo RC_KLEV: $RC_KLEV
+ echo RC_SLEV: $RC_SLEV
+ fi
+ for i in $RC_KLEV; do
+ echo /etc/rc$i.d/K$RC_KNUM$service
+ /usr/sbin/installf -c cswinitsmf $PKGINST /etc/rc$i.d/K$RC_KNUM$service=/etc/init.d/$service s
+ /bin/ln -s /etc/init.d/$service /etc/rc$i.d/K$RC_KNUM$service
+ done
+ for i in $RC_SLEV; do
+ echo /etc/rc$i.d/S$RC_SNUM$service
+ /usr/sbin/installf -c cswinitsmf $PKGINST /etc/rc$i.d/S$RC_SNUM$service=/etc/init.d/$service s
+ /bin/ln -s /etc/init.d/$service /etc/rc$i.d/S$RC_SNUM$service
+ done
fi
- RC_SNUM=
- if [ "`grep '^#RC_SNUM' $dest`" ]; then
- RC_SNUM=`grep '^#RC_SNUM' $dest | awk '{print $2}'`
- fi
- RC_KLEV=
- if [ "`grep '^#RC_KLEV' $dest`" ]; then
- RC_KLEV=`grep '^#RC_KLEV' $dest | awk '{print $2}'`
- RC_KLEV=`echo $RC_KLEV | sed 's/,/ /g'`
- fi
- RC_SLEV=
- if [ "`grep '^#RC_SLEV' $dest`" ]; then
- RC_SLEV=`grep '^#RC_SLEV' $dest | awk '{print $2}'`
- RC_SLEV=`echo $RC_SLEV | sed 's/,/ /g'`
- fi
- if [ ! "$RC_KNUM" ]; then
- RC_KNUM=20
- fi
- if [ ! "$RC_SNUM" ]; then
- RC_SNUM=80
- fi
- if [ ! "$RC_KLEV" ]; then
- RC_KLEV="0 1 2 S"
- fi
- if [ ! "$RC_SLEV" ]; then
- RC_SLEV=3
- fi
- if [ "$DEBUG" ]; then
- echo RC_KNUM: $RC_KNUM
- echo RC_SNUM: $RC_SNUM
- echo RC_KLEV: $RC_KLEV
- echo RC_SLEV: $RC_SLEV
- fi
- for i in $RC_KLEV; do
- echo /etc/rc$i.d/K$RC_KNUM$service
- /usr/sbin/installf -c cswinitsmf $PKGINST /etc/rc$i.d/K$RC_KNUM$service=/etc/init.d/$service s
- /bin/ln -s /etc/init.d/$service /etc/rc$i.d/K$RC_KNUM$service
- done
- for i in $RC_SLEV; do
- echo /etc/rc$i.d/S$RC_SNUM$service
- /usr/sbin/installf -c cswinitsmf $PKGINST /etc/rc$i.d/S$RC_SNUM$service=/etc/init.d/$service s
- /bin/ln -s /etc/init.d/$service /etc/rc$i.d/S$RC_SNUM$service
- done
fi
done
-# Determine if service should be started or not
-daemon=yes
-
-if [ "$autoenable_daemons" = "no" ]; then
- daemon=no
-fi
-
-if [ "$autoenable_$service" = "no" ]; then
- daemon=no
-elif [ "$autoenable_$service" = "yes" ]; then
- daemon=yes
-fi
-
# Start service
if [ "$daemon" = "yes" ]; then
echo Starting $PKGINST ...
if [ "$smf" = "yes" ]; then
- /usr/sbin/svcadm enable svc:/$FMRI/$service > /dev/null 2>&1
+ load_smf_service_state "$FMRI/$service"
+ if [ "$SMF_STATE" = "enabled" ]; then
+ /usr/sbin/svcadm enable svc:/$FMRI/$service > /dev/null 2>&1
+ fi
else
# fix permissions temporarily since 644 is used until verification
/usr/bin/chmod 744 /etc/init.d/$service
@@ -251,6 +274,9 @@
fi
fi
+# we delete the smf state file as we don't need it anymore
+rm -f "$SMF_STATE_FILE"
+
/usr/sbin/installf -f $PKGINST
exit 0
Modified: csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswinitsmf
===================================================================
--- csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswinitsmf 2009-04-21 15:46:20 UTC (rev 4429)
+++ csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswinitsmf 2009-04-21 16:26:56 UTC (rev 4430)
@@ -8,9 +8,35 @@
# 2008-04-21 First release
# 2008-11-23 Fixed grep bug for FMRI
# 2009-01-07 Fixed bug with multiple services per package
+# 2009-04-21 Added -s to svcadm disable, removed sleep (Bug ID 0003632),
+ Persistent state across upgrades (Bug ID 0003634)
DEBUG= # clear to disable debug, set to anything to enable
+# The following file is used to save the state of smf service upon
+# package removal
+# This allows to restore the service state across package upgrades.
+SMF_STATE_DIR="$PKG_INSTALL_ROOT/etc/opt/csw/preserve/$PKG"
+SMF_STATE_FILE="$SMF_STATE_DIR/smf.state"
+
+# The smf state file shouldn't be there at this time but we
+# delete it to be sure
+rm -f "$SMF_STATE_FILE"
+
+# save the current service state for the given frmi
+save_smf_state ()
+{
+ SMF_STATE=`/usr/sbin/svccfg -s "$1:default" listprop general/enabled | /usr/bin/awk '{ print $3 }'`
+ if [ "$SMF_STATE" != "true" ]; then
+ SMF_STATE="disabled"
+ else
+ SMF_STATE="enabled"
+ fi
+ [ -d "$SMF_STATE_DIR" ] || mkdir -p "$SMF_STATE_DIR"
+ echo "$1 $SMF_STATE" >> "$SMF_STATE_FILE"
+}
+
+
# Source csw.conf, if it exists
if [ -f $PKG_INSTALL_ROOT/opt/csw/etc/csw.conf ] ; then
. $PKG_INSTALL_ROOT/opt/csw/etc/csw.conf
@@ -41,8 +67,8 @@
for i in `echo $FMRI | tr '\n' ' '`
do
if [ "$smf" = "yes" ]; then
- /usr/sbin/svcadm disable svc:/$i
- sleep 1
+ save_smf_state
+ /usr/sbin/svcadm -s disable svc:/$i
# Unregister with SMF
echo Unregister svc:/${i}:default with SMF ...
/usr/sbin/svccfg delete -f svc:/${i}:default
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list