Revision: 2352 http://gar.svn.sourceforge.net/gar/?rev=2352&view=rev Author: bonivart Date: 2008-11-25 08:13:23 +0000 (Tue, 25 Nov 2008)
Log Message: ----------- cswclassutils: moved to gar and updated to 1.1 Added Paths: ----------- csw/trunk/utils/cswclassutils/ csw/trunk/utils/cswclassutils/Makefile csw/trunk/utils/cswclassutils/checksums csw/trunk/utils/cswclassutils/files/ csw/trunk/utils/cswclassutils/files/CSWcswclassutils.README.CSW csw/trunk/utils/cswclassutils/files/CSWcswclassutils.copyright csw/trunk/utils/cswclassutils/files/CSWcswclassutils.csw.smf.sample csw/trunk/utils/cswclassutils/files/CSWcswclassutils.gspec csw/trunk/utils/cswclassutils/files/CSWcswclassutils.i.cswcpsampleconf csw/trunk/utils/cswclassutils/files/CSWcswclassutils.i.cswinitsmf csw/trunk/utils/cswclassutils/files/CSWcswclassutils.i.cswpreserveconf csw/trunk/utils/cswclassutils/files/CSWcswclassutils.prototype csw/trunk/utils/cswclassutils/files/CSWcswclassutils.r.cswcpsampleconf csw/trunk/utils/cswclassutils/files/CSWcswclassutils.r.cswinitsmf csw/trunk/utils/cswclassutils/files/CSWcswclassutils.r.cswpreserveconf Added: csw/trunk/utils/cswclassutils/Makefile =================================================================== --- csw/trunk/utils/cswclassutils/Makefile (rev 0) +++ csw/trunk/utils/cswclassutils/Makefile 2008-11-25 08:13:23 UTC (rev 2352) @@ -0,0 +1,37 @@ +GARNAME = cswclassutils +GARVERSION = 1.1 +CATEGORIES = utils + +DESCRIPTION = CSW class action utilities + +MASTER_SITES = +DISTFILES += $(call admfiles,CSWcswclassutils,prototype) + +CONFIGURE_SCRIPTS = +BUILD_SCRIPTS = +TEST_SCRIPTS = +INSTALL_SCRIPTS = custom + +include ../category.mk + +WORKSRC = $(WORKDIR) +SPKG_SOURCEURL = http://www.opencsw.org/ + +install-custom: + @echo " ==> Installing $(GARNAME)" + @rm -rf $(DESTDIR) + @ginstall -d $(DESTDIR)/etc/opt/csw/init.d + @ginstall -d $(DESTDIR)/opt/csw/share/doc/$(GARNAME) + @ginstall -d $(DESTDIR)/usr/sadm/install/scripts + @ginstall -d $(DESTDIR)/var/opt/csw/svc/manifest + @ginstall -d $(DESTDIR)/var/opt/csw/svc/method + @cp $(FILEDIR)/CSW$(GARNAME).csw.smf.sample $(DESTDIR)/etc/opt/csw/init.d/csw.smf.sample + @cp $(FILEDIR)/CSW$(GARNAME).README.CSW $(DESTDIR)/opt/csw/share/doc/$(GARNAME)/README.CSW + @cp $(FILEDIR)/CSW$(GARNAME).copyright $(DESTDIR)/opt/csw/share/doc/$(GARNAME)/LICENSE + @cp $(FILEDIR)/CSW$(GARNAME).i.cswcpsampleconf $(DESTDIR)/usr/sadm/install/scripts/i.cswcpsampleconf + @cp $(FILEDIR)/CSW$(GARNAME).r.cswcpsampleconf $(DESTDIR)/usr/sadm/install/scripts/r.cswcpsampleconf + @cp $(FILEDIR)/CSW$(GARNAME).i.cswpreserveconf $(DESTDIR)/usr/sadm/install/scripts/i.cswpreserveconf + @cp $(FILEDIR)/CSW$(GARNAME).r.cswpreserveconf $(DESTDIR)/usr/sadm/install/scripts/r.cswpreserveconf + @cp $(FILEDIR)/CSW$(GARNAME).i.cswinitsmf $(DESTDIR)/usr/sadm/install/scripts/i.cswinitsmf + @cp $(FILEDIR)/CSW$(GARNAME).r.cswinitsmf $(DESTDIR)/usr/sadm/install/scripts/r.cswinitsmf + @$(MAKECOOKIE) Added: csw/trunk/utils/cswclassutils/checksums =================================================================== --- csw/trunk/utils/cswclassutils/checksums (rev 0) +++ csw/trunk/utils/cswclassutils/checksums 2008-11-25 08:13:23 UTC (rev 2352) @@ -0,0 +1,2 @@ +15e48f60e16862b94755b3205b666ab8 download/CSWcswclassutils.gspec +847abc46521d2e324518456d783f9235 download/CSWcswclassutils.prototype Added: csw/trunk/utils/cswclassutils/files/CSWcswclassutils.README.CSW =================================================================== --- csw/trunk/utils/cswclassutils/files/CSWcswclassutils.README.CSW (rev 0) +++ csw/trunk/utils/cswclassutils/files/CSWcswclassutils.README.CSW 2008-11-25 08:13:23 UTC (rev 2352) @@ -0,0 +1,30 @@ +CSWcswclassutils +================ + +This package contains class action scripts to simplify doing common tasks in a +consistent manner. They can also be updated to benefit all packages that make +use of them. + +Currently it has: + +- cswinitsmf + + This class takes care of creating/removing init script links for Solaris 8 + and 9. For Solaris 10+ it supports SMF and can create a simple manifest on + the fly at installation time. Read more about how to use it in the sample + init script provided in /etc/opt/csw/init.d/csw.smf.sample. + +- cswcpsampleconf + + This script handles the sample configuration files. If you provide a file + called cswfoo.CSW it will copy it to cswfoo it that file doesn't already + exist. Read more in /usr/sadm/install/scripts/i.cswcpsampleconf and + r.cswcpsampleconf. + +- cswpreserveconf + + This is an enhanced variation of cswcpsampleconf. It moves + user-modified versions of the sample config files, to a preserve + directory when a package is removed, and restores it on the next pkgadd. + Read more in /usr/sadm/install/scripts/i.cswpreserveconf and + r.cswpreserveconf. Added: csw/trunk/utils/cswclassutils/files/CSWcswclassutils.copyright =================================================================== --- csw/trunk/utils/cswclassutils/files/CSWcswclassutils.copyright (rev 0) +++ csw/trunk/utils/cswclassutils/files/CSWcswclassutils.copyright 2008-11-25 08:13:23 UTC (rev 2352) @@ -0,0 +1,5 @@ + +These script(s) are utility scripts used by people who package software +for opencsw.org's Solaris "Community SoftWare" (CSW) effort. The scripts +may be copied free of charge, but may be of limited use to non-opencsw folks. + Added: csw/trunk/utils/cswclassutils/files/CSWcswclassutils.csw.smf.sample =================================================================== --- csw/trunk/utils/cswclassutils/files/CSWcswclassutils.csw.smf.sample (rev 0) +++ csw/trunk/utils/cswclassutils/files/CSWcswclassutils.csw.smf.sample 2008-11-25 08:13:23 UTC (rev 2352) @@ -0,0 +1,73 @@ +#!/bin/sh +# +# Sample init script +# +# Original concept by Philip Brown +# Written by Peter Bonivart +# +# 2008-04-22 First release +# +# Usage +# ----- +# 1. Add CSWcswclassutils in depend +# 2. Add cswinitsmf as the last class in pkginfo, e.g. "CLASSES=none cswinitsmf" +# 3. Add a line in prototype for the init script, it must belong to the +# cswinitsmf class. Also note the path in the example below: +# "f cswinitsmf /etc/opt/csw/init.d/cswfoo 0755 root bin" +# +# NOTE that the SMF service name will be the same as the init script file +# name, in the example above cswfoo. +# +# Requirements +# ------------ +# 1. Your init script must support start and stop. Restart will be supported +# if present. +# +# In-Line tweaks +# -------------- +# In your init script you can have "magic" comments that configure +# the service creation or symlink creation during pkg installation. +# +# These are all OPTIONAL. If you do not set them, then reasonable +# defaults will be chosen. +# +# The line must start with one hash mark to be immediately followed by +# the variable, then whitespace to the value. Comments like in the examples +# below are OK but there must be whitespace after the value. +# +# The examples below, happen to be the default values if you do not +# define them yourself. +# +# RC_KLEV and RC_SLEV supports comma separated lists. +# +# Examples of OPTIONAL tweaks below. +# To use, change '##' to '#', and set your own preferred value(s). +# +##RC_KNUM 20 # Number used for kill script symlink, e.g. K20cswfoo +##RC_SNUM 80 # Number used for start script symlink, e.g. S80cswfoo +##RC_KLEV 0,1,2,S # Run levels that should have a kill script symlink +##RC_SLEV 3 # Run levels that should have a start script symlink +##FMRI network # FMRI path for service (S10+), the example would give +# an FMRI of "svc:/network/cswfoo:default" + +case "$1" in + start) + echo "Starting cswfoo ..." + /opt/csw/bin/cswfoo + ;; + stop) + echo "Stopping cswfoo ..." + pkill cswfoo + ;; + restart) + $0 stop + sleep 1 # or explicitly check that service has stopped + $0 start + ;; + *) + echo "Usage: $0 { start | stop | restart }" + exit 1 + ;; +esac + +exit 0 Property changes on: csw/trunk/utils/cswclassutils/files/CSWcswclassutils.csw.smf.sample ___________________________________________________________________ Added: svn:executable + * Added: csw/trunk/utils/cswclassutils/files/CSWcswclassutils.gspec =================================================================== --- csw/trunk/utils/cswclassutils/files/CSWcswclassutils.gspec (rev 0) +++ csw/trunk/utils/cswclassutils/files/CSWcswclassutils.gspec 2008-11-25 08:13:23 UTC (rev 2352) @@ -0,0 +1,11 @@ +%var bitname cswclassutils +%var pkgname CSWcswclassutils +%var arch all +%include url file://%{PKGLIB}/csw_vars.gspec +%pkginfo url file://%{PKGLIB}/csw/pkginfo +%include url file://%{PKGLIB}/csw_prototype.gspec +%depend +%copyright + +Please see /opt/csw/share/doc/cswclassutils/LICENSE for license information. + Added: csw/trunk/utils/cswclassutils/files/CSWcswclassutils.i.cswcpsampleconf =================================================================== --- csw/trunk/utils/cswclassutils/files/CSWcswclassutils.i.cswcpsampleconf (rev 0) +++ csw/trunk/utils/cswclassutils/files/CSWcswclassutils.i.cswcpsampleconf 2008-11-25 08:13:23 UTC (rev 2352) @@ -0,0 +1,38 @@ +#!/bin/sh + +# This "class" is meant to be used with a sample configuration file. +# eg: f cswcpsampleconf /etc/opt/csw/myprog.conf.csw +# +# It will copy myprog.conf.csw to myprog.conf, IF AND ONLY IF +# there is no pre-existing "myprog.conf" file +# +# Author: Philip Brown 2008 +# May be used/copied freely +# + +while read src dest ; do + # reminder: $dest will already have $PKG_INSTALL_ROOT prepended for us + cp $src $dest + + case $dest in + *.csw) + confdest=`echo $dest |sed 's/.csw$//'` + ;; + *.CSW) + confdest=`echo $dest |sed 's/.CSW$//'` + ;; + *) + echo ERROR: unrecognized sample conf file .ext $dest + exit 1 + ;; + esac + + if [ -f $confdest ] ; then + echo $confdest already exists. Not overwriting + else + echo Copying sample config to $confdest + cp $dest $confdest + fi +done + +echo "" Added: csw/trunk/utils/cswclassutils/files/CSWcswclassutils.i.cswinitsmf =================================================================== --- csw/trunk/utils/cswclassutils/files/CSWcswclassutils.i.cswinitsmf (rev 0) +++ csw/trunk/utils/cswclassutils/files/CSWcswclassutils.i.cswinitsmf 2008-11-25 08:13:23 UTC (rev 2352) @@ -0,0 +1,242 @@ +#!/bin/sh +# +# i.cswinitsmf - Class action script for CSW SMF support +# +# Original concept by Philip Brown +# Written by Peter Bonivart +# +# 2008-04-21 First release + +DEBUG= # clear to disable debug, set to anything to enable +SVCDIR=/var/opt/csw/svc + +# 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 +fi +if [ -f $PKG_INSTALL_ROOT/etc/opt/csw/csw.conf ] ; then + . $PKG_INSTALL_ROOT/etc/opt/csw/csw.conf +fi + +# Determine if SMF should be used or not +smf=no + +if [ -f /usr/sbin/svccfg -a -f /usr/sbin/svcadm ]; then + smf=yes +fi + +if [ "$use_smf" = "no" ]; then + smf=no +fi + +if [ "$DEBUG" ]; then + echo PACKAGE: $PKGINST SMF: $smf +fi + +# Copy files, set up SMF +echo "Installing class <cswinitsmf> ..." + +while read src dest +do + if [ "$DEBUG" ]; then + echo SRC: $src DEST: $dest + fi + service="`basename $dest`" + if [ "$smf" = "yes" ]; then + # Copy the service script + /usr/bin/cp $src $dest || exit 2 + FMRI= + if [ "`grep '^#FMRI' $dest`" ]; then + FMRI=`grep '^#FMRI' $dest | awk '{print $2}'` + fi + if [ ! "$FMRI" ]; then + FMRI=network + fi + # Creating FMRI path on system if needed + testpath=$SVCDIR/manifest + for i in `echo $FMRI | sed 's/\// /g'`; do + testpath=$testpath/$i + if [ ! -d $testpath ]; then + echo Creating $testpath ... + /usr/bin/mkdir $testpath + /usr/bin/chown root:bin $testpath + /usr/bin/chmod 755 $testpath + /usr/sbin/installf -c cswinitsmf $PKGINST $testpath d 755 root bin + fi + done + if [ "$DEBUG" ]; then + echo FMRI: $FMRI + fi + echo Creating service script in $SVCDIR/method/svc-$service ... + /usr/bin/ln -s $dest $SVCDIR/method/svc-$service + /usr/sbin/installf -c cswinitsmf $PKGINST $SVCDIR/method/svc-$service=$dest s + /usr/bin/chmod 755 $SVCDIR/method/svc-$service + /usr/bin/chown root:bin $SVCDIR/method/svc-$service + + # Creating manifest + echo Creating manifest ... + # Add first part of manifest + cat > $SVCDIR/manifest/$FMRI/$service.xml << EOF +<?xml version='1.0'?> +<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'> +<!-- +Service manifest for $service +Autogenerated by CSWinitsmf +2008-04-21 Peter Bonivart +--> + +<service_bundle type='manifest' name='$service:$service'> + +<service + name='$FMRI/$service' + type='service' + version='1'> + <create_default_instance enabled='false' /> + <single_instance /> + + <dependency name='fs' + grouping='require_all' + restart_on='none' + type='service'> + <service_fmri value='svc:/system/filesystem/local' /> + </dependency> + + <dependency name='net' + grouping='require_all' + restart_on='none' + type='service'> + <service_fmri value='svc:/network/loopback' /> + </dependency> + + <exec_method + type='method' + name='start' + exec='$SVCDIR/method/svc-$service start' + timeout_seconds='-1'> + </exec_method> + + <exec_method + type='method' + name='stop' + exec='$SVCDIR/method/svc-$service stop' + timeout_seconds='-1'> + </exec_method> + +EOF + + # Add restart option to manifest if service script supports it + if [ "`/usr/bin/egrep 'restart.?\)' $SVCDIR/method/svc-$service`" ]; then + cat >> $SVCDIR/manifest/$FMRI/$service.xml << EOF + <exec_method + type='method' + name='restart' + exec='$SVCDIR/method/svc-$service restart' + timeout_seconds='-1'> + </exec_method> + +EOF + fi + + # Add last part of manifest + cat >> $SVCDIR/manifest/$FMRI/$service.xml << EOF +</service> + +</service_bundle> +EOF + /usr/sbin/installf -c cswinitsmf $PKGINST $SVCDIR/manifest/$FMRI/$service.xml f 644 root bin + /usr/bin/chmod 644 $SVCDIR/manifest/$FMRI/$service.xml + /usr/bin/chown root:bin $SVCDIR/manifest/$FMRI/$service.xml + + # Register with SMF + echo Configuring service in SMF ... + /usr/sbin/svccfg import $SVCDIR/manifest/$FMRI/$service.xml > /dev/null 2>&1 + /usr/sbin/svcadm disable svc:/$FMRI/$service > /dev/null 2>&1 + echo $PKGINST is using Service Management Facility. The FMRI is svc:/$FMRI/$service:default + else + # Copy the service script + echo $dest + /usr/bin/cp $src $dest || exit 2 + + # Create link to /etc/init.d + echo /etc/init.d/$service + /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}'` + 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 + else + # fix permissions temporarily since 644 is used until verification + /usr/bin/chmod 744 /etc/init.d/$service + /etc/init.d/$service start > /dev/null 2>&1 + fi +fi + +/usr/sbin/installf -f $PKGINST + +exit 0 Added: csw/trunk/utils/cswclassutils/files/CSWcswclassutils.i.cswpreserveconf =================================================================== --- csw/trunk/utils/cswclassutils/files/CSWcswclassutils.i.cswpreserveconf (rev 0) +++ csw/trunk/utils/cswclassutils/files/CSWcswclassutils.i.cswpreserveconf 2008-11-25 08:13:23 UTC (rev 2352) @@ -0,0 +1,46 @@ +#!/bin/sh + +# This script is similar yet different, to cswcpsampleconf +# It should probably replace the former in all cases, but... +# not sure yet. +# +# See README for package, for documentation +# +# Author: Philip Brown 2008 +# May be used/copied freely +# + + +while read src dest ; do + cp $src $dest + + # reminder: $dest will already have $PKG_INSTALL_ROOT prepended for us + + case $dest in + *.csw) + confdest=`echo $dest |sed 's/.csw$//'` + ;; + *.CSW) + confdest=`echo $dest |sed 's/.CSW$//'` + ;; + *) + echo ERROR: unrecognized sample conf file .ext $dest + exit 1 + ;; + esac + preservedir=$PKG_INSTALL_ROOT/etc/opt/csw/preserve/$PKG + confbasename=`basename $confdest` + preservedconf=$preservedir/$confbasename + + if [ -f $preservedconf ] ; then + echo Restoring $preservedconf + cp $preservedconf $confdest + elif [ -f $confdest ] ; then + echo $confdest already exists. Not overwriting + else + echo Copying sample config to $confdest + cp $dest $confdest + fi +done + +echo "" Added: csw/trunk/utils/cswclassutils/files/CSWcswclassutils.prototype =================================================================== --- csw/trunk/utils/cswclassutils/files/CSWcswclassutils.prototype (rev 0) +++ csw/trunk/utils/cswclassutils/files/CSWcswclassutils.prototype 2008-11-25 08:13:23 UTC (rev 2352) @@ -0,0 +1,20 @@ +i pkginfo=CSWcswclassutils.pkginfo +i copyright=CSWcswclassutils.copyright +d none /etc/opt/csw 0755 root bin +d none /etc/opt/csw/init.d 0755 root bin +f none /etc/opt/csw/init.d/csw.smf.sample 0755 root bin +d none /var/opt/csw 0755 root bin +d none /var/opt/csw/svc 0755 root bin +d none /var/opt/csw/svc/manifest 0755 root bin +d none /var/opt/csw/svc/method 0755 root bin +f none /usr/sadm/install/scripts/i.cswinitsmf 0555 root sys +f none /usr/sadm/install/scripts/r.cswinitsmf 0555 root sys +f none /usr/sadm/install/scripts/i.cswcpsampleconf 0555 root sys +f none /usr/sadm/install/scripts/r.cswcpsampleconf 0555 root sys +f none /usr/sadm/install/scripts/i.cswpreserveconf 0555 root sys +f none /usr/sadm/install/scripts/r.cswpreserveconf 0555 root sys +d none /opt/csw/share 0755 root bin +d none /opt/csw/share/doc 0755 root bin +d none /opt/csw/share/doc/cswclassutils 0755 root bin +f none /opt/csw/share/doc/cswclassutils/README.CSW 0444 root bin +f none /opt/csw/share/doc/cswclassutils/LICENSE 0444 root bin Added: csw/trunk/utils/cswclassutils/files/CSWcswclassutils.r.cswcpsampleconf =================================================================== --- csw/trunk/utils/cswclassutils/files/CSWcswclassutils.r.cswcpsampleconf (rev 0) +++ csw/trunk/utils/cswclassutils/files/CSWcswclassutils.r.cswcpsampleconf 2008-11-25 08:13:23 UTC (rev 2352) @@ -0,0 +1,29 @@ +#!/bin/sh +# +# Author: Philip Brown 2008 +# May be used/copied freely +# + +while read dest ; do + # reminder: $dest will already have $PKG_INSTALL_ROOT prepended for us + + case $dest in + *.csw) + confdest=`echo $dest |sed 's/.csw$//'` + ;; + *.CSW) + confdest=`echo $dest |sed 's/.CSW$//'` + ;; + *) + echo ERROR: unrecognized sample conf file .ext $dest + exit 1 + ;; + esac + + if cmp $confdest $dest >/dev/null ; then + echo $confdest is identical to sample config file $dest + echo Removing $confdest + rm $confdest + fi + rm $dest +done Added: csw/trunk/utils/cswclassutils/files/CSWcswclassutils.r.cswinitsmf =================================================================== --- csw/trunk/utils/cswclassutils/files/CSWcswclassutils.r.cswinitsmf (rev 0) +++ csw/trunk/utils/cswclassutils/files/CSWcswclassutils.r.cswinitsmf 2008-11-25 08:13:23 UTC (rev 2352) @@ -0,0 +1,61 @@ +#!/bin/sh +# +# r.cswinitsmf - Class action script for CSW SMF support +# +# Original concept by Philip Brown +# Written by Peter Bonivart +# +# 2008-04-21 First release +# 2008-11-23 Fixed grep bug for FMRI + +DEBUG= # clear to disable debug, set to anything to enable + +# 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 +fi +if [ -f $PKG_INSTALL_ROOT/etc/opt/csw/csw.conf ] ; then + . $PKG_INSTALL_ROOT/etc/opt/csw/csw.conf +fi + +# Determine if SMF should be used or not +smf=no + +if [ -f /usr/sbin/svccfg -a -f /usr/sbin/svcadm ]; then + smf=yes +fi + +if [ "$use_smf" = "no" ]; then + smf=no +fi + +if [ "$DEBUG" ]; then + echo PACKAGE: $PKGINST SMF: $smf +fi + +# Stop service +echo Stopping $PKGINST ... +if [ "$smf" = "yes" ]; then + # Find out FMRI complete with service name + FMRI=`grep ${PKGINST}$ /var/sadm/install/contents | grep "^/var/opt/csw/svc/manifest" | egrep '\.xml ' | cut -d'/' -f7- | awk -F'.xml' '{print $1}'` + /usr/sbin/svcadm disable svc:/$FMRI > /dev/null 2>&1 + # Unregister with SMF + echo Unregister svc:/${FMRI}:default with SMF ... + /usr/sbin/svccfg delete svc:/${FMRI}:default >/dev/null 2>&1 +else + /etc/init.d/$service stop > /dev/null 2>&1 +fi + +# Remove files in class cswinitsmf +echo "Removing class <cswinitsmf> ..." +while read file +do + echo $file + if [ -d $file ]; then + /usr/bin/rm -rf $file || exit 2 + else + /usr/bin/rm -f $file || exit 2 + fi +done + +exit 0 Added: csw/trunk/utils/cswclassutils/files/CSWcswclassutils.r.cswpreserveconf =================================================================== --- csw/trunk/utils/cswclassutils/files/CSWcswclassutils.r.cswpreserveconf (rev 0) +++ csw/trunk/utils/cswclassutils/files/CSWcswclassutils.r.cswpreserveconf 2008-11-25 08:13:23 UTC (rev 2352) @@ -0,0 +1,41 @@ +#!/bin/sh +# +# Author: Philip Brown 2008 +# May be used/copied freely +# + +while read dest ; do + # reminder: $dest will already have $PKG_INSTALL_ROOT prepended for us + + case $dest in + *.csw) + confdest=`echo $dest |sed 's/.csw$//'` + ;; + *.CSW) + confdest=`echo $dest |sed 's/.CSW$//'` + ;; + *) + echo ERROR: unrecognized sample conf file .ext $dest + exit 1 + ;; + esac + + preservedir=$PKG_INSTALL_ROOT/etc/opt/csw/preserve/$PKG + confbasename=`basename $confdest` + preservedconf=$preservedir/$confbasename + + if [ -f $confdest ] ; then + if cmp $confdest $dest >/dev/null ; then + echo $confdest is identical to sample config file $dest + echo Removing $confdest + rm $confdest + else + echo "preserving $confdest to $preservedconf" + mkdir -p $preservedir + cp -p $confdest $preservedconf && rm $confdest + fi + fi + + # Any way it shakes out, we always remove the "sample conf" + rm $dest +done This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ devel mailing list devel@lists.opencsw.org https://lists.opencsw.org/mailman/listinfo/devel