Home | History | Annotate | Download | only in lib
      1 #! /usr/bin/ksh  -p
      2 #
      3 # CDDL HEADER START
      4 #
      5 # The contents of this file are subject to the terms of the
      6 # Common Development and Distribution License (the "License").
      7 # You may not use this file except in compliance with the License.
      8 #
      9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10 # or http://www.opensolaris.org/os/licensing.
     11 # See the License for the specific language governing permissions
     12 # and limitations under the License.
     13 #
     14 # When distributing Covered Code, include this CDDL HEADER in each
     15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16 # If applicable, add the following below this CDDL HEADER, with the
     17 # fields enclosed by brackets "[]" replaced with your own identifying
     18 # information: Portions Copyright [yyyy] [name of copyright owner]
     19 #
     20 # CDDL HEADER END
     21 #
     22 
     23 #
     24 # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
     25 # Use is subject to license terms.
     26 #
     27 # ident	"@(#)ce_package.ksh	1.3	07/01/04 SMI"
     28 #
     29 
     30 #
     31 # Function ce_package
     32 #
     33 # This function checks if a package exists on the system.
     34 #
     35 # Args:
     36 #	$1: package (the name of the package which should exist on the system)
     37 #
     38 function ce_package
     39 {
     40 	package=${1}
     41 
     42 	result=PASS
     43 
     44 	# Check the argument and make sure it is as expected - abort otherwise.
     45 	errmsg="ce_package expects argument naming a package to check"
     46 	[[ $# -ne 1 ]] && abort $errmsg
     47 
     48 	# Set req values
     49 	req_label="Required package"
     50 	req_value="$package"
     51 
     52 	# If operation is to dump info, dump and return
     53 	[[ $OPERATION = "dump" ]] && {
     54 		ce_package_doc
     55 		return $PASS
     56 	}
     57 
     58 	#
     59 	# Verify that the system meets requirements - set result=[PASS|FAIL]
     60 	#
     61 	[[ $OPERATION = "verify" ]] && {
     62 		pkginfo $package > /dev/null 2>&1
     63 		[[ $? -ne 0 ]]  && result=FAIL
     64 	}
     65 
     66 	print_line $TASK "$req_label" "$req_value" "$result"
     67 	eval return \$$result
     68 }
     69 
     70 function ce_package_doc
     71 {
     72 	cat >&1 << EOF
     73 
     74 Check ce_package ($TASK)
     75 =========================
     76 Description:
     77 	Check if a package is installed on the system
     78 Arguments:
     79 	#1 - package name
     80 Requirement label (for this check):
     81 	$req_label
     82 Requirement value (for this check):
     83 	$req_value
     84 EOF
     85 }
     86