#!/bin/sh
#
# Copyright 1997, Silicon Graphics, Inc.
# ALL RIGHTS RESERVED
# 
# UNPUBLISHED -- Rights reserved under the copyright laws of the United
# States.   Use of a copyright notice is precautionary only and does not
# imply publication or disclosure.
# 
# U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
# Use, duplication or disclosure by the Government is subject to restrictions
# as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
# in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
# in similar or successor clauses in the FAR, or the DOD or NASA FAR
# Supplement.  Contractor/manufacturer is Silicon Graphics, Inc.,
# 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
# 
# THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
# INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
# DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
# PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
# GRAPHICS, INC.
#
# Install the espping PMDA and/or PMNS
#
# $Id: Install,v 1.2 1999/05/26 02:38:46 kenmcd Exp $
#

# Some degree of paranoia here ...
PATH=/usr/sbin:/usr/bsd:/sbin:/usr/bin:/bin:/usr/pcp/bin
export PATH

# Get the common procedures and variable assignments
#
. /usr/pcp/lib/pmdaproc.sh

# The name of the PMDA
#
iam=espping

# Using libpcp_pmda.so.2 and PMDA_INTERFACE_2
#
pmda_interface=2

# Do it
#
pmdaSetup

# controls for installation procedures
#
daemon_opt=true		# can install as daemon
dso_opt=false
pipe_opt=true		# supports pipe IPC
socket_opt=false	# force pipe IPC

# be careful that mortals cannot write any configuration files, as
# these would present a security problem
#
umask 022


# PMDA variables
#
tmp=/tmp/$$
configfile=""
cycle=120
timeout=20
debug=0

trap "rm -f $tmp.*; exit" 0 1 2 3 15

_quit()
{
    rm -f $tmp*
    exit $1
}

do_debug=false

if $do_pmda
then

    # go figure out which configuration file to use ...
    #
    default_configfile="/var/pcp/pmdas/espping/sgm.conf"
    pmdaChooseConfigFile

    if [ ! -f "$configfile" ]
    then
	echo ""
	echo "Error: Abandoning installation as no configuration file was specified."
	_quit 1
    fi

    echo
    echo "All commands are run one after another as a group and the group is run"
    echo "once per \"cycle\" time.   Enter the cycle time in seconds [$cycle] \c"
    read ans
    if  [ ! -z "$ans" ]
    then
    	cycle=$ans
    fi

    echo
    echo "Each command must complete within a timeout period, or it will be aborted"
    echo "by the \"$iam\" PMDA.  Enter the timeout period (in seconds) [$timeout] \c"
    read ans
    if  [ ! -z "$ans" ]
    then
    	timeout=$ans
    fi

    if [ "$do_debug" = true ]
    then
	echo
	echo "Enter the debugging flag (see pmdbg(1)) [$debug] \c"
	read ans
	if [ ! -z "$ans" ]
	then
	    debug=$ans
	fi
    fi

    args="-I $cycle -t $timeout -D $debug $configfile"
fi

pmdaInstall

_quit 0
