diff options
Diffstat (limited to 'usr/src/pkgdefs/SUNWrcapr/postinstall')
| -rw-r--r-- | usr/src/pkgdefs/SUNWrcapr/postinstall | 78 |
1 files changed, 73 insertions, 5 deletions
diff --git a/usr/src/pkgdefs/SUNWrcapr/postinstall b/usr/src/pkgdefs/SUNWrcapr/postinstall index 0b4d1d3faa..89507280f8 100644 --- a/usr/src/pkgdefs/SUNWrcapr/postinstall +++ b/usr/src/pkgdefs/SUNWrcapr/postinstall @@ -19,21 +19,89 @@ # CDDL HEADER END # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # #pragma ident "%Z%%M% %I% %E% SMI" # +SVCADM="/usr/sbin/svcadm" +SVCCFG="/usr/sbin/svccfg" +SVCPROP="/bin/svcprop" +PG="config" +RCAP_CONF="${PKG_INSTALL_ROOT}/etc/rcap.conf" +RCAP_FMRI="svc:/system/rcap:default" +PROFILE_UPGRADE="${PKG_INSTALL_ROOT}/var/svc/profile/upgrade" + # -# If appropriate, enable this service. We know the service should be -# enabled if the TMPFILE created by preinstall exists. +# If appropriate, enable this service. If /etc/rcap.conf exists, +# migrate the existing configuration values regardless of whether +# or not rcapd was enabled. # BASEPREFIX=`echo $BASEDIR | tr '/' '_'` FILENAME=`echo sunwrcapr"$BASEPREFIX" | cut -c 1-256` TMPFILE=/tmp/$FILENAME if [ -f $TMPFILE ]; then - echo "/usr/sbin/svcadm enable system/rcap" >> \ - ${PKG_INSTALL_ROOT}/var/svc/profile/upgrade + echo "$SVCADM enable $RCAP_FMRI" >> $PROFILE_UPGRADE + rm $TMPFILE fi + +# +# Reads existing configuration values in /etc/rcap.conf and puts +# them in repository upon reboot(via /var/svc/profile/upgrade). +# +migrate_rcap_conf() +{ + pressure=`awk '$1 == "RCAPD_MEMORY_CAP_ENFORCEMENT_PRESSURE" \ + && NF == 3 {print $3}' $RCAP_CONF` + + reconfig_int=`awk '$1 == "RCAPD_RECONFIGURATION_INTERVAL" \ + && NF == 3 {print $3}' $RCAP_CONF` + + walk_int=`awk '$1 == "RCAPD_PROC_WALK_INTERVAL" && \ + NF == 3 {print $3}' $RCAP_CONF` + + report_int=`awk '$1 == "RCAPD_REPORT_INTERVAL" && \ + NF == 3 {print $3}' $RCAP_CONF` + + rss_sample_int=`awk '$1 == "RCAPD_RSS_SAMPLE_INTERVAL" && \ + NF == 3 {print $3}' $RCAP_CONF` + + # Update default configuration values with + # pre-existing values + # + echo "# Migrating pre-existing rcap configuration" >> $PROFILE_UPGRADE + + if [ -n "$pressure" ]; then + echo "$SVCCFG -s $RCAP_FMRI setprop ${PG}/pressure = " \ + "$pressure" >> $PROFILE_UPGRADE + fi + + if [ -n "$reconfig_int" ]; then + echo "$SVCCFG -s $RCAP_FMRI setprop ${PG}/reconfig_interval = " \ + "$reconfig_int" >> $PROFILE_UPGRADE + fi + + if [ -n "$walk_int" ]; then + echo "$SVCCFG -s $RCAP_FMRI setprop ${PG}/walk_interval = " \ + "$walk_int" >> $PROFILE_UPGRADE + fi + + if [ -n "$report_int" ]; then + echo "$SVCCFG -s $RCAP_FMRI setprop ${PG}/report_interval = " \ + "$report_int" >> $PROFILE_UPGRADE + fi + + if [ -n "$rss_sample_int" ]; then + echo "$SVCCFG -s $RCAP_FMRI setprop ${PG}/rss_sample_interval = " \ + "$rss_sample_int" >> $PROFILE_UPGRADE + fi + + echo "$SVCADM refresh $RCAP_FMRI" >> $PROFILE_UPGRADE + echo "rm /etc/rcap.conf" >> $PROFILE_UPGRADE +} + +if [ -f $RCAP_CONF ]; then + migrate_rcap_conf +fi |
